How can I prevent a window from being resized with tkinter?

前端 未结 6 1343
野趣味
野趣味 2020-12-01 03:18

I have a program which creates a window where a message is displayed according to a check box.

How can I make the window size constant when the message is displayed

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 03:55

    This code makes a window with the conditions that the user cannot change the dimensions of the Tk() window, and also disables the maximise button.

    import tkinter as tk
    
    root = tk.Tk()
    root.resizable(width=False, height=False)
    root.mainloop()
    

    Within the program you can change the window dimensions with @Carpetsmoker's answer, or by doing this:

    root.geometry('{}x{}'.format(, ))
    

    It should be fairly easy for you to implement that into your code. :)

提交回复
热议问题