osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TKinter Newbie question


Why does the button frame in the code below not show?

I intend to have it displayed in between the notebook at the top and the fake statusbar at the bottom.

Thanks for any help!


from tkinter import ttk
import tkinter as tk

class MainForm():
    
    def __init__(self, master):
        
        self.master = master
        self.master.title('Test')

        nb = ttk.Notebook(self.master)
        
        page_1 = ttk.Frame(nb)
        
        nframe = ttk.LabelFrame(page_1, text='Frame', padding = 10)
        tk.Label(nframe, padx = 10, pady = 5, text = 'Name').pack()
        tk.Entry(nframe, width = 30).pack()
        tk.Label(nframe, padx = 10, pady = 5, text = 'City').pack()
        tk.Entry(nframe, width = 30).pack()
        #
        nframe.pack(fill="both", expand="yes", padx = 10, pady = 10)  # pad around the frame        
        
        nb.add(page_1, text = 'Tab #1')
        
        nb.pack(expand = True, fill = "both")        

        #-------------------------------------------------------------------------------------------
        # button frame for Help button  >>>>>>>> why does it not show? <<<<<<<<<<<<<<<<<<<<
        #-------------------------------------------------------------------------------------------
        bf = ttk.Frame(self.master, relief = tk.SUNKEN)
        tk.Button(bf, padx = 10, relief = tk.GROOVE, text = 'Help')
        bf.pack(side = tk.BOTTOM, fill = tk.X)

        #-------------------------------------------------------------------------------------------
        # fake a status bar from a label
        #-------------------------------------------------------------------------------------------
        sb = tk.Label(self.master, text = ' Waiting for rain ...', bd = 1, anchor = tk.W, relief = tk.SUNKEN)
        sb.pack(side = tk.BOTTOM, fill = tk.X)

    def CloseApplication(self):
        self.master.destroy()

def StartApplication():
    root = tk.Tk()
    
    MainForm(root)        
    root.mainloop()

if __name__ == '__main__':
    StartApplication()