JDoe
JDoe

Reputation: 96

How to change the layout of a window on changing its size (tkinter, python)?

For an analogy, like the media-queries in CSS. I am trying to find an event that gets fired on changing the size of the window.

Upvotes: 2

Views: 1296

Answers (1)

SneakyTurtle
SneakyTurtle

Reputation: 1857

It looks like you're interested in configure. This, as you've described, is an event which is called when the root window is resized.

You can utilize this by binding to it, i.e. call a function when the window is resized. This would look like root.bind("<Configure>", resize), where resize is your function to deal with this.

In this case, resize would be passed the new windows event, which contains the new width and height of the window (by using event.width and event.height).

This is described with other events and bindings here.

Upvotes: 3

Related Questions