<font color="#000000">Hello,<br><br>I'm trying my hand at creating a Tkinter application, but not having much luck. I'm trying to have my top level window be a series of buttons with different options on them. Every time a button is pressed, it opens up a new window with options. While that new window is open, all of the buttons on the original window are disabled. However, I want all of those buttons to become active again once I quit my new window. I can't seem to reactivate those buttons no matter what I do.<br>
<br>This is the approach I'm trying:<br><br>#!/usr/bin/env python<br><br>from Tkinter import *<br><br>class ActionButton(Button):<br> def __init__(self, frame, text):<br> self.frame = frame<br> Button.__init__(self, master=self.frame, text=text, command=self.execute)<br>
def execute(self):<br> window = Toplevel()<br> new_button = ActionButton(window, '2nd level button')<br> quit_button = Button(window, text='Quit!', command=window.destroy)<br> window.buttons = [new_button, quit_button]<br>
for button in window.buttons: button.pack()<br> # Deactivate buttons from containing shell<br> for button in self.frame.buttons: button.config(state=DISABLED)<br> window.mainloop()<br> for button in self.frame.buttons: button.config(state=ACTIVE)<br>
<br><br>top = Tk()<br>top_button = ActionButton(top, 'Button on top!')<br>top_button.pack()<br>quit_button = Button(top, text='Quit', command=top.destroy)<br>quit_button.pack()<br><br>top.buttons = [top_button, quit_button]<br>
<br>top.mainloop()<br><br>I'm really kind of running around in the dark here, so any advice or explanation is appreciated.<br><br>Thanks!<br>Jason</font><br>