您能否请一看这个演示,让我知道如何向Tkinter笔记本添加组合框cm
到tab2
?
import Tkinter
from Tkinter import *
import ttk
from ttk import *
app = Tk()
app.configure(background='DimGray')
app.geometry('600x600')
app.resizable(width=False, height=False)
note = Notebook(app)
tab1 = Frame(note)
tab2 = Frame(note)
tab3 = Frame(note)
note.add(tab1, text = "Tracing", compound=TOP)
note.add(tab2, text = "Network Details")
note.add(tab3, text = "Tab Three")
note.pack(fill=BOTH, expand=True)
variable = StringVar(app)
variable.set("Select From List")
variable.trace('w', OptionCallBack)
cm = ttk.Combobox(app, textvariable=variable)
cm.config(values =('Select From Phase A', 'Select From Phase B'))
cm.pack()
app.mainloop()
答案 0 :(得分:1)
任何tkinter小部件中的第一个变量是父小部件。如果你想在框架而不是主框架中使用组合框,只需更改父框架:
cm = ttk.Combobox(tab2, textvariable=variable)