Question

I'm pretty new to python, especially using tkinter. So far I have put together a ttk notebook with the help of this page http://www.pyinmyeye.com/2012/08/tkinter-notebook-demo.html.

What I am essentially asking is- can I dynamically set the second tab's state from "disabled" to "normal" when I press a ttk button in the first "Welcome" tab?

What the tabs are initially set to:

nb.add(frame, text='Welcome', underline=0, padding=2, state="normal")
nb.add(frame, text='Tab Two', underline=0, padding=2, state="disabled")

If it helps to put this into context, I am trying to make a pizza ordering program for a school project, and I want each step of the process in a different tab. I want the state of these tabs to depend on whether the pizzas are to be delivered or picked up; in which case some steps are not needed. Thanks to anyone who even takes the time to read this :)

Was it helpful?

Solution

To change the state of a tab, use the tab method with the appropiate index and the options (in this case, the state). Since tabs are zero-index based, you should pass 1 to enable the second one:

nb.tab(1, state="normal")

You might also want to focus the corresponding tab. For that, you can use the select method:

nb.select(1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top