【发布时间】:2015-01-01 11:48:12
【问题描述】:
我有一个ttk.Notebook,我想通过一个按钮切换到另一个标签。
我怎样才能做到这一点?
看起来更改标签状态(normal、disabled 和 hidden)并不能解决我的问题,因为我不想禁用任何标签。
这是我的代码:
import time
import ttk as ttk
import Tkinter as tk
root=tk.Tk()
root.config(width=300,height=220)
notebook=ttk.Notebook(root)
notebook.place(x=0,y=0)
tabList=[]
i=0
while i<6:
tabList.append(tk.Frame(root))
tabList[i].config(width=300,height=150,background='white')
i+=1
i=0
while i<6:
notebook.add(tabList[i],text='tab'+str(i))
i+=1
def fLoopTabs():
i=0
while i<6:
notebook.select(i)
time.sleep(2)
#Here goes the Screenshot function
i+=1
button=ttk.Button(root,text='Loop',command=fLoopTabs)
button.place(x=20,y=180)
root.mainloop()
【问题讨论】: