Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically update wxPython staticText

i was wondering how to update a StaticText dynamically in wxpython? I have a script that goes every five minutes and reads a status from a webpage, then prints using wxpython the status in a static input. How would i dynamically, every 5 minutes update the statictext to reflect the status?

thanks alot

-soule

like image 376
Souleiman Avatar asked Jul 26 '10 21:07

Souleiman


2 Answers

Use a wx.Timer. You bind the timer to an event and in the event handler you call the StaticText control's SetLabel.

See the following page for an example on timers:

http://www.blog.pythonlibrary.org/2009/08/25/wxpython-using-wx-timers/

As for setting the label, the code would look something like this:

self.myStaticText.SetLabel("foobar")

Hope that helps!

like image 165
Mike Driscoll Avatar answered Oct 01 '22 16:10

Mike Driscoll


Call the SetLabel method in your static text instance. So you don't run into conflict with the size, make sure your StaticText instance is created with enough space to write the future labels you'll want to write to it.

like image 22
tom10 Avatar answered Oct 01 '22 18:10

tom10