Tkinter event loop question

gordon nodrogbrown at gmail.com
Thu Aug 28 09:18:46 CEST 2008


On Aug 27, 10:42 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> so I guess the question here is from where you expect to call that
> method, and what you expect Tkinter to do when you call it...

thanks for the reply

i was planning to write a controller (as in MVC) that will instantiate
a gui class and show the ui.the gui will send user input back to the
controller which in turn will process it and send a result to the gui
to be displayed

something like

controllermodule.py
--------------------
class Controller:
   def createGUI(self):
      root=Tk()
      self.mygui=uimodule.MyGUI(root)
      root.mainloop()
   def sendMessageToUI(self):
      self.mygui.displayResult(someresultValue)



i don't know if this is the right way to do this..when i call
sendMessage() it tries to call displayResult() on the gui instance
which is already in an event loop.displayResult() gets called only
after the event loop is finished(when i close gui window).

is there a way to  keep the gui window open and have the controller
send a message to the gui instance so that i can pass the processed
result value to the gui instance?

thanks
gordon





More information about the Python-list mailing list