gordon | 28 Aug 09:18

Re: Tkinter event loop question

On Aug 27, 10:42 pm, Fredrik Lundh <fred...@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
(Continue reading)

Russell E. Owen | 29 Aug 01:45

Re: Tkinter event loop question

In article 
<c180cdc1-66b3-45b5-9ece-e606755d8e81 <at> r15g2000prd.googlegroups.com>,
 gordon <nodrogbrown <at> gmail.com> wrote:

> On Aug 27, 10:42 pm, Fredrik Lundh <fred...@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
(Continue reading)

gordon | 29 Aug 19:18

Re: Tkinter event loop question

On Aug 29, 4:45 am, "Russell E. Owen" <ro...@u.washington.edu> wrote:
>your Controller object should not create root nor should
> it call mainloop to start the event loop.

guys
thanks for the helpful replies..I rewrote the code as you advised. It
creates a controller object and a gui object from main script.However
i had to chain some method calls in my code.i am
wondering if that can be avoided in some way.

this is the sequence
1.user enters some value in the textfield,and clicks OKbutton
2.on OKbuttonclick ,the gui takes userinput value and quits
eventloop.It then calls controller and pass the userinputvalue.
3.controller does some calculation(i shd have an external program to
do calculation,but for simplicity i just wrote a method inside
controller) with the given value,obtains the result and calls gui's
updateDisplay(), passing the result value.
4.the gui creates the result as text on a canvas.then the mainloop()
is called to resume event loop

again user enters some value in the textfield,and clicks OKbutton ...

I exit the application by clicking quitButton that calls destroy() on
top level window.
 I tried my application by entering some value on text field and then
clicking OKbutton ,the calculated result is displayed on canvas .I do
this process say 3 times ..Then i click the Quit button and the window
closes.
I have put a print statement inside the gui's updateDisplay()method
(Continue reading)

Russell E. Owen | 29 Aug 19:46

Re: Tkinter event loop question

In article 
<759a12fe-75c8-429a-9a64-19dc73a0b779 <at> b30g2000prf.googlegroups.com>,
 gordon <nodrogbrown <at> gmail.com> wrote:

> On Aug 29, 4:45 am, "Russell E. Owen" <ro...@u.washington.edu> wrote:
> >your Controller object should not create root nor should
> > it call mainloop to start the event loop.
> 
> guys
> thanks for the helpful replies..I rewrote the code as you advised. It
> creates a controller object and a gui object from main script.However
> i had to chain some method calls in my code.i am
> wondering if that can be avoided in some way.
> 
> this is the sequence
> 1.user enters some value in the textfield,and clicks OKbutton
> 2.on OKbuttonclick ,the gui takes userinput value and quits
> eventloop.It then calls controller and pass the userinputvalue.
> 3.controller does some calculation(i shd have an external program to
> do calculation,but for simplicity i just wrote a method inside
> controller) with the given value,obtains the result and calls gui's
> updateDisplay(), passing the result value.
> 4.the gui creates the result as text on a canvas.then the mainloop()
> is called to resume event loop
> 
> again user enters some value in the textfield,and clicks OKbutton ...
> 
> I exit the application by clicking quitButton that calls destroy() on
> top level window.
>  I tried my application by entering some value on text field and then
(Continue reading)

gordon | 30 Aug 19:56

Re: Tkinter event loop question

On Aug 29, 10:46 pm, "Russell E. Owen" <ro...@u.washington.edu> wrote:
you
> can safely compute stuff with a background thread and display it from> the main thread). But cross that
bridge later.>
> -- Russell

thanks Russel
gordon
--
http://mail.python.org/mailman/listinfo/python-list


Gmane