Aug-20-2020, 02:40 AM
Hello python users:
The following code is to create a frame with four command buttons. It does this. However, before it creates the frame with four command buttons, it creates a frame with no buttons. Why does it create the frame with no buttons?
The following code is to create a frame with four command buttons. It does this. However, before it creates the frame with four command buttons, it creates a frame with no buttons. Why does it create the frame with no buttons?
import tkinter as tk myfont = "Helvitica 30" mybg = "lightskyblue" class Main: def __init__(self, root): self.root = tk.Tk() self.root.geometry("500x500") self.createfstframe() def createfstframe(self): fstframe = tk.Frame(root) fstframe.pack(padx=100, pady=100) self.Hellobn=tk.Button(fstframe,text = "Hello", bg = mybg, font = myfont) self.Hellobn.pack(fill = tk.BOTH, expand = 1) self.Howyoubn = tk.Button(fstframe, text="How are you? ",bg = mybg ,font = myfont) self.Howyoubn.pack(fill = tk.BOTH, expand = 1) self.clickherebn = tk.Button(fstframe, text = "Click here to start", bg = "deepskyblue",font = myfont) self.clickherebn.pack(fill = tk.BOTH, expand = 1) self.quitbn = tk.Button(fstframe,text = "Quit", font = myfont, bg = "red", command = fstframe.quit) self.quitbn.pack(fill = tk.BOTH, expand = 1) root = tk.Tk() b=Main(root) root.mainloop()