Problems with WX and program loop...

M

Mr BigSmoke

Hi everybody... I have an app that has to controll some ascii files
every 10/30 seconds... I was planning to have an GUI using wxpython.
The problems is that i wasn't able to manage my application loop and
the wxApp loop, so my interface is always freezing...
My app do something like this:
- creates a new wx and wxframe instance
- loads some configuration info
- starts looping every 30 seconds (while True: sleep(30); do something,
bla,bla)
- update some labels and textboxes on my frame...

On every loop step, if i find some info in those ascii files i want to
change some labels on my wxFrame... But my frame just freezes...
because of the loop.

Any hint?

I'll post some of the code down here...

"
....
loadSystemConfiguration() # Carico la configurazione delle tag
dell'intero sistema
self.loadMonitorConfiguration() # Carico le configurazioni del
monitor
# monitorGUI.monitorGUI is my wxFrame class...
self.mG = monitorGUI.monitorGUI(None, app_path, screen_dx=1024,
screen_dy=768)
self.mG.Show()

self.monitorize = True
while self.monitorize:
time.sleep(30)
<<<do my stuff>>>
if something:
self.mG.status.SetValue("Registering new event...")
self.mG.Update()

"
 
C

Chris Mellon

Hi everybody... I have an app that has to controll some ascii files
every 10/30 seconds... I was planning to have an GUI using wxpython.
The problems is that i wasn't able to manage my application loop and
the wxApp loop, so my interface is always freezing...
My app do something like this:
- creates a new wx and wxframe instance
- loads some configuration info
- starts looping every 30 seconds (while True: sleep(30); do something,
bla,bla)
- update some labels and textboxes on my frame...

On every loop step, if i find some info in those ascii files i want to
change some labels on my wxFrame... But my frame just freezes...
because of the loop.

Any hint?

I'll post some of the code down here...

Welcome to the exciting world of event-based programming ;)

You want to use a wx.Timer to trigger your event every 30 seconds
instead of sleeping.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,276
Messages
2,571,384
Members
48,073
Latest member
ImogenePal

Latest Threads

Top