1

is there any way how to force to update main frame? I just need this:

if(saved(0)):
    Tk.Button(self.frame, text="Continue", command=self.pokracovat, relief="groove").grid()  

First, I open main window. Function "saved" returns false, so button is not created. Then i open some another window using toplevel. Main window is vanished. Then I close that window and open main window - function "saved" now returns true, but still button doesnt appear. I use self.root.update(), but it doesnt work.

Trsak
  • 303
  • 1
  • 4
  • 8
  • 1
    Just as an alternate idea would you be against setting the button "state" to tk.disabled when saved option not set thus making the button appear but in a DISABLED state unless the saved(0) option was set? – Amazingred Apr 13 '14 at 11:46
  • It is likely that this `if` statement is only being evaluated once. You should put a print statement in it to see when it is being called. – ebarr Apr 13 '14 at 11:47
  • Problem is that function saved is still returning False. If i close window and start program again, then it returns True. – Trsak Apr 13 '14 at 11:51
  • @ebarr Function is evaluted only when window is created. I use this: [link](http://www.blog.pythonlibrary.org/2012/07/26/tkinter-how-to-show-hide-a-window/) – Trsak Apr 13 '14 at 11:59
  • There is not enough information for us to help you. We would need to see more code. If `saved(0)` returns True and the above code is executed, the button absolutely will be added to `self.frame`. There's much more to the problem than what you are showing us. – Bryan Oakley Apr 13 '14 at 12:01
  • I looked at the link you sent, but I can't see your code on that page. Please post your code (or at least the amount of code necessary to recreate your problem) in the question. – ebarr Apr 13 '14 at 12:08
  • @BryanOakley So I uploaded code here: [code](http://codeshare.io/hNrrK) – Trsak Apr 13 '14 at 12:24

1 Answers1

-1

To create a button when saved changes to True you can do the following:

  1. You can use a loop that checks for the value and when the value changes then the loop does something. tkinter loop and serial write
  2. you know where the value is changed and at this positions you insert some code that does what you want. For this the observer pattern can be interesing.
Community
  • 1
  • 1
User
  • 14,131
  • 2
  • 40
  • 59