How to update the image of a Tkinter Label widget?

The method label.configure does work in panel.configure(image=img). What I forgot to do was include the panel.image=img, to prevent garbage collection from deleting the image. The following is the new version: import Tkinter as tk import ImageTk root = tk.Tk() img = ImageTk.PhotoImage(Image.open(path)) panel = tk.Label(root, image=img) panel.pack(side=”bottom”, fill=”both”, expand=”yes”) def callback(e): img2 = ImageTk.PhotoImage(Image.open(path2)) panel.configure(image=img2) … Read more

Tkinter: How to use threads to preventing main event loop from “freezing”

When you join the new thread in the main thread, it will wait until the thread finishes, so the GUI will block even though you are using multithreading. If you want to place the logic portion in a different class, you can subclass Thread directly, and then start a new object of this class when … Read more

What is the difference between the widgets of tkinter and tkinter.ttk in Python?

The widgets in tkinter are highly and easily configurable. You have almost complete control over how they look – border widths, fonts, images, colors, etc. ttk widgets use styles to define how they look, so it takes a bit more work if you want a non-standard button. ttk widgets are also a little under-documented. Understanding … Read more

List of All Tkinter Events

A general list for Bindings and Events can be found on effbot.org or in the docs provided by New Mexico Tech whereas the name of several keys are listed here in addition to the original documentation. Here’s a summary of the most common events with some keypress names explained: Event Description <Button-1> Button 1 is … Read more

Why does Tkinter image not show up if created in a function?

The variable photo is a local variable which gets garbage collected after the class is instantiated. Save a reference to the photo, for example: self.photo = tkinter.PhotoImage(…) If you do a Google search on “tkinter image doesn’t display”, the first result is this: Why do my Tkinter images not appear? (The FAQ answer is currently … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)