Ask Your Question
0

In Tkinter, what is the method to identify the resizing of the main window?

asked 2022-06-28 11:00:00 +0000

plato gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-03-28 22:00:00 +0000

woof gravatar image

The method to identify the resizing of the main window in Tkinter is <Configure>. This method is associated with the main window widget and is triggered whenever the geometry of the main window is changed, including when it is resized.

To use this method, you first need to bind it to the main window widget:

root.bind('<Configure>', function_name)

function_name is the name of the function that will be executed whenever the main window is resized. Inside this function, you can add code to perform tasks that need to be done when the window is resized.

For example, if you want to track the size of the main window, you can define a function as follows:

def on_resize(event):
    print('New window size: %d x %d' % (event.width, event.height))

Then, you can bind this function to the main window widget as follows:

root.bind('<Configure>', on_resize)

Now, whenever the main window is resized, the on_resize function will be executed and will print the new size of the window.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-06-28 11:00:00 +0000

Seen: 8 times

Last updated: Mar 28 '22