Reputation: 120
Good Day All!
I am trying to figure out how to limit the popup box shown bellow. I am not trying to trim the text, I am however trying to set the amount of characters in the popup per line. eg: 30 Characters per line in the popup box
tkMessageBox.showinfo("Results", str(e))
Any suggestions, without modifying the text itself?
Upvotes: 0
Views: 245
Reputation: 3964
Another alternative would be to subclass the message box and add your own wraplength
option. This might not suit your needs as is, it doesn't account for spaces in your string:
class WrappedBox(object):
def __init__(self, title, message, wraplength=60):
self.title = title
self.message = message
self.wraplength = wraplength
self.messageWrapped = '\n'.join([self.message[i:i+self.wraplength] for i in xrange(0,len(self.message),self.wraplength)])
tkMessageBox.showinfo(self.title, self.messageWrapped)
WrappedBox("Results", str(e), wraplength=30)
Upvotes: 1
Reputation: 385980
There is nothing you can do with the tkMessageBox. You either have to alter the text or create your own message window. The latter isn't very difficult -- a Toplevel
, a Text
widget with a scrollbar, and a couple of buttons is about all you need.
Upvotes: 0