I have been reading about refreshing tkinter windows but all the examples I have found have been for changing the color of a screen or updating a line of text. I have a problem where I need to update a set of dynamically created buttons. In my example, the user chooses a directory and then the buttons are created based on the files in the directory. They can change the directory multiple times so the buttons need to change. Here is what I'm working with:

Here's an example of the buttons being created that I need to update.

def restore(self):
        self.restoreWindow = Toplevel()
        self.restoreWindow.grab_set()
        self.restoreWindow.transient(root)

        chooseFrame = Frame(self.restoreWindow)
        chooseFrame.pack(fill=X, expand=True)

        message = "Select an available Backup to Restore to."
        Label(chooseFrame, text=message).pack()

        button_list = []
        button_num = -1
        os.chdir('C:\\')
        for name in os.listdir('.'): 
            if os.path.isdir(name):
                button_list.append(name)
                self.button = Button(chooseFrame, text=name,command=lambda j=button_num+1:
                    self.restoreCallBack(button_list[j]))
                self.button.pack(side=LEFT, padx=10, pady=10)
                button_num = button_num + 1
        os.chdir('..')

Thanks for all your help, let me know of any questions!

share|improve this question
Although what you ask is doable, why not just use the tkFileDialog module? – Steven Rumbalski Jul 3 '12 at 17:57
In order the replace the buttons in the first place? I suppose I could, it was a general design decision to use the buttons. – Brad Conyers Jul 3 '12 at 19:02
1  
So, you have code to create the buttons. What more do you need? Is deleting and recreating the buttons not a good nough solution for you? – Bryan Oakley Jul 4 '12 at 12:24

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.