2013-08-07 2 views
2

작성한 ttk.Notebook에서 탭 상태를 변경하는 방법과 여러 탭을 올바르게 관리하는 방법을 알고 싶습니다.ttk.Notebook에서 탭 관리하기 (활성화, 비활성화 등)

예 :

내가 안 함 사용이 예에서
import Tkinter as tk 
import ttk 
from myWidgets import Widget1, Widget2, Widget3 

def enableTabs(notebook): 
    tabs = notebook.tabs() 
    for i, item in enumerate(tabs): 
     item['state'] = 'enabled' #This doesn't work 
     item.configure(state='enabled') #Doesn't work either 
if __name__ == '__main__': 
    root = tk.Tk() 

    notebook = ttk.Notebook(root) 

    w1 = Widget1() 
    w2 = Widget2() 
    w3 = Widget3() 

    notebook.add(w1, text='tab1', state='disabled') 
    notebook.add(w2, text='tab2', state='disabled') 
    notebook.add(w3, text='tab3', state='disabled') 

    enableTabs(notebook) #This would be called upon certain events in the real  application 

    root.mainloop() 

- 가능하지만 일반적으로 내가 한 번에 특정 설정을 변경할 수 있도록하고 싶습니다.

답변

1

itemstate 키 또는 configure 메서드가없는 식별자 (부동 소수점)입니다. 또한이 컨텍스트에서 탭 상태의 가능한 값은 enabled이 아니라 normal, disabledhidden입니다. 대신이 시도하십시오 :

for i, item in enumerate(tabs): 
    notebook.tab(item, state='normal') # Does work 
+0

내 잘못 tab() 실제 식별자가 아닌 실제 탭 개체의 목록을 반환합니다 생각. 귀하의 답변은 완벽한 감사입니다. – Asics