The tkinter.Message widget, proposed by some people, DOES NOT use TTK styling, which means that it will look like garbage in the TTK (theme) interface.
You can manually apply the background and foreground colors from your TTK theme, but it's not worth it ... because the ancient Message widget has zero advantages over the regular TTK ttk.Label .
The tkinter.Message widget has an aspect ratio property that determines the number of pixels before it is transferred.
Instead, ttk.Label has a wraplength= property, which determines how many pixels there are before word wraplength= . You should also use its anchor= and justify= properties to customize it to your desires.
Example: ttk.Label(root, wraplength=220, anchor=tkinter.NW, justify=tkinter.LEFT) . Creates a beautifully designed label that constantly wraps text after a width of 220 pixels.
Regarding automatic length updates? Well, you should join the <Configure> event, as people have said ... However, if you have a fully resizable window (which resizes to fit all the content), or a grid / frame that is fluid and contains a label, then you cannot automatically calculate it this way, because the parent WINDOW / CONTAINER expands itself whenever the label gets too wide. This means that the size of the label will always change to the maximum width necessary to accommodate all the text. Thus, automatic updating of the length of the wrapper is possible only if the label itself has some restrictions on how wide it can grow (either because the parent container has a fixed size / maximum size, or the fixed size / maximum size). In this case, of course, you can use configure to calculate new hyphenation numbers to ensure that the text is always hyphenated ... However, the code example from t7ko does not work and is no longer valid, just fyi.
source share