试图用Tkinter的笔记本标签做一个GUI。如果我不使用笔记本标签,我可以正常使用.grid(),但是一旦我添加了标签,一切都会消失。
from tkinter import *
from tkinter import ttk
root= Tk()
root.title("Mountain Care Pharmacy CMS")
root.geometry('600x800')
root.resizable(width=False, height=False)
note = ttk.Notebook(root)
tab1 = ttk.Frame(note)
tab2 = ttk.Frame(note)
tab3 = ttk.Frame(note)
note.add(tab1, text = "CMS", compound=TOP)
note.add(tab2, text = "Other")
note.grid()
ttk.Button(tab1, text='Import PBM file', command=getPBM).grid(column = 0 , row = 1, sticky = W)
ttk.Button(tab1, text='Import Direct file', command=getDirect).grid(column = 0 , row = 2, sticky = W)
ttk.Button(tab1, text='Create CMS', command=createReport).grid(column=3, row = 4, sticky = W)
tab1.grid()
reportType = StringVar()
ttk.Combobox(tab2, textvariable=reportType)
pbm_file_path = StringVar()
direct_file_path = StringVar()
pbm_entry = ttk.Entry(tab2, textvariable=pbm_file_path)
direct_entry = ttk.Entry(tab2, textvariable=direct_file_path)
pbm_entry.grid(column=1, columnspan = 2, row=1, sticky = EW)
direct_entry.grid(column=1, columnspan = 2, row=2, sticky = EW)
for child in tab1.winfo_children():
child.grid_configure(padx=5, pady=5)
root.bind("<Return>", createReport)