6

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

0

2 Answers 2

11

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!

Sign up to request clarification or add additional context in comments.

1 Comment

WOOHOO! that did the trick! genius you solved my problem! thank you mike, i greatly appreciate it!!
1

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.

1 Comment

Thanks for the answer. The two strings it's gonna print is :"code available" and 'no code available". Do you have any example how to use the Setlabel? sorry, im a bit of a newbie. I got around this problem by restarting my program every five minutes, but i'm sure there's a more efficient way..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.