how to enable & disable tabs in a Tkinter/Tix Python GUI
In general how you disable widgets in Tkinter is by setting the "state" option to Tk.DISABLED
or more foolproof just setting it to a string saying "disabled"
. The following grays out and disables your tab:
notebook.tab(0, state="disabled")
with 0 being the index of the tab you want to disable, and notebook being your notebook object. Does that answer your question?
Below is a simple notebook example to demonstrate:
import Tkinterimport ttkwindow = Tkinter.Tk()notebook = ttk.Notebook(window)notebook.pack()subframe = Tkinter.Frame(window)subframe.pack()notebook.add(subframe, text="tab", state="normal")def buttonaction(): notebook.tab(0, state="disabled")button = Tkinter.Button(subframe, command=buttonaction, text="click to disable tab")button.pack()if __name__ == "__main__": window.mainloop()
This might be what you are looking for:
nb.pageconfigure('hard_disk', state=Tix.DISABLED)
http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixNoteBook.htm#M27