Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Handling widget resize with <Configure>

There might be occasions when you <indexentry content="window responsiveness:widget resize, handling with ">want to do some specific action when a user resizes a window or a widget. Tkinter provides an event named <Configure>, which can be bound to a callback to react to changes in widget size.

Here is a simple example (see handle_widget_resize.py):

from tkinter import Tk, Label, Packroot= Tk()label = Label(root, text = 'I am a Frame', bg='red')label.pack(fill='both', expand=True)def on_label_resized(event):  print('New Width', label.winfo_width())  print('New Height', label.winfo_height())label.bind("<Configure>", on_label_resized)root.mainloop()

The description of the code is as follows:

  • We have a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content