<br><br><div><span class="gmail_quote">On 11/2/07, <b class="gmail_sendername">tarun</b> <<a href="mailto:tarundevnani@gmail.com">tarundevnani@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><font color="#990000" face="georgia">Dear All,</font></div>
<div><font color="#990000" face="georgia"></font> </div>
<div><font color="#990000" face="georgia">I've have created a GUI (using wxPython widgets) where in I've a message log window (A TextCtrl window). I've a router.dll that helps me putting in message onto a channel. In my script that generates the GUI, I want to continuously poll the channel and populate the messages from the channel to the message log window.
</font></div>
<div><font color="#990000" face="georgia"></font> </div>
<div><font color="#990000" face="georgia">For this I've to put a while (1) loop, but when I do this, the GUI doesn't come up. I see the GUI coming when while(1) is removed. Is there any issue with usage of app.mainloop
and while(1) together.</font></div>
<div><font color="#990000" face="georgia"></font> </div>
<div><font color="#990000" face="georgia">Quick help would be really appreciated.</font></div>
<div><font color="#990000" face="georgia"></font> </div><br></blockquote></div>Hi Tarun,<br><br>The best practice to poll things in any GUI
application is to use timers provided by the GUI frameworks. All of the
GUI frameworks does provide timers, so does wxPython. Look for wx.Timer
(also look for wx.CallAfter ) and use it to poll what ever the things
you want<br><br><a href="http://www.wxpython.org/docs/api/wx.Timer-class.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.wxpython.org/docs/api/wx.Timer-class.html</a><br><br>
When you use a while(1) loop, the python interpreter enters into an
infinite local loop thus GUI events never gets processed. So your case
seems be that, the while loop is getting executed before GUI is drawn
on screen, it will never show up till the loop exits. And if while(1)
is executed after GUI is drawn on screen, it will hangup and will not
get updated till the loop exits. So avoid using while loops in your GUI
for polling long running tasks .
<br clear="all"><span class="sg"><br>-- <br>Godson Gera,<br><a href="http://godson.auroinfo.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://godson.auroinfo.com</a><br><a href="http://godson.in/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://godson.in</a></span><br clear="all"><br>-- <br>Godson Gera,<br><a href="http://godson.auroinfo.com">http://godson.auroinfo.com</a>