In particular, the Text widget is of interest. In the following example, the Text widget, if you set the font size too large, stretches the widget. How to give it a fixed size, regardless of the font size?

import Tkinter from ScrolledText import ScrolledText class DialogMessages(): def __init__(self): self.text = "Your text!" * 100 # текст окна self.size_font = "12" # размер шрифта окна self.root = Tkinter.Tk() self.width_screen = self.root.winfo_screenwidth() self.height_screen = self.root.winfo_screenheight() self.body = Tkinter.Canvas(self.root, width=437, height=250) self.body.pack() self.rectangle_text = Tkinter.Frame(self.body) self.rectangle_text.pack() self.body_text = ScrolledText(self.rectangle_text, width=1, height=1) self.body_text.pack() self.root.geometry("%sx%s+%s+%s" % (437, 267, int(self.width_screen * 0.35), int(self.height_screen * 0.35) )) def show(self): self.body_text.insert("1.0", self.text) self.body_text.config(font=("family", self.size_font), state="disabled") self.root.mainloop() window = DialogMessages() # Варьируя данную переменную, можно видеть, # как текстовое поле уменьшается либо увеличивается. window.size_font = "5" window.show() 

    1 answer 1

    The solution is to set the size not for the text field (for it the size is specified in characters), but for the frame in which the text field lies, and disable resizing for this frame when resizing nested controls using the pack_propagate() or grid_propagate() .

    In the case described in the question, it will look like this:

     self.rectangle_text = Tkinter.Frame(self.body, width=100, height=100) self.rectangle_text.pack() self.rectangle_text.pack_propagate(False) self.body_text = ScrolledText(self.rectangle_text) self.body_text.pack() 

    If the controls inside the frame are placed using the grid , then resizing the frame must be disabled using self.rectangle_text.grid_propagate(False) .