I have a nice design for my GUI. I would want to be able to select the text displayed in Message widgets. The only suggestions I saw are to either use an Entry widget in the read only mode, but this looks completely different than a Message widget or to use a Text widget which again looks completely different. How can I select the text in a Message widget?
If this is not possible, how would I get a Text or Entry widget to look and behave the same as a Message widget?
Short answer is no, you can't. You might be able to do some clever workaround with event capturing but it's much more work than you might be anticipating.
The most likely way to implement this as you mentioned is just emulate the
Message
look on anEntry
orText
widget. An easy way is usingttk.Style
to copy the look and feel of the widgets underttk
instead. However there's noMessage
widget underttk
, butLabel
cuts pretty close:Your
Entry
widget will now look like aMessage
widget with the text'message here'
to copy without write access.Edit: If you want to resize the entry based on the characters, assuming you have a fixed-length font, you can try this:
If your font is not fixed-length you can guestimate an average/max width per character increase and multiply the ratio to the
len()
: