Why is the command bound to a Button or event executed when declared?

Consider this code: b = Button(admin, text=”as”, command=button(‘hey’)) It does exactly the same as this: result = button(‘hey’) b = button(admin, text=”as”, command=result) Likewise, if you create a binding like this: listbox.bind(“<<ListboxSelect>>”, some_function()) … it’s the same as this: result = some_function() listbox.bind(“<<ListboxSelect>>”, result) The command option takes a reference to a function, which is … Read more

Tkinter Placing And Deleting A Label

In your code, the label is placed, and after 2 seconds it is destroyed. It is never actually shown in your window however as it is not updated. This is as when entering Tk’s mainloop, it updates the window in a loop, checking if changes have been made. In your case, you are preventing this … Read more

How make a complete gui softwaree in a single windows in tkinter

To update without changing the window, you basically have to use the after method, if you use it the correct way, then it will be able update automatically. Here is an example: def someKindOfFunction(): #something happening there window.after(100,someKindOfFunction) someKindOfFunction() This way you will create a loop, you would then have to specify conditions for when … Read more

Tkinter programming 2

You forgot to use parent in widgets ie. Label(self, …) so automatically you put widgets into root (Main Window), not into self (Frame). And later you remove widgets from self but elements in root stays. from tkinter import * class Window(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.init_window() def init_window(self): self.master.title(“SAMPLE”) self.pack(expand=1) l = Button(self, text=”Log … Read more

Python collapsible sidebar on tkinter [closed]

Here is a simple example of how to create a collapsible frame. You can use the same method to create a collapsible sidebar by putting all your sidebar stuff in the frame. import tkinter as tk class Example(tk.Tk): def __init__(self): super().__init__() self.geometry(‘300×100′) self.left_frame = tk.Frame(self) self.left_frame.grid(row=0, column=0, sticky=’nsew’) self.right_frame = tk.Frame(self) self.rowconfigure(0, weight=1) for i … Read more