How do I change variable in a thread? - python

Here's my situation. Let's say I would like to create a thread that continually prints the number 1. When a button is clicked the value should then change to 2. My issue is that I'm unsure how I change a variable in an already running thread. Here's my code:
import wx
from threading import Thread
import time
class testThread(Thread):
def __init__(self, parent):
self.parent = parent
Thread.__init__(self)
self.start()
def run(self):
while 1:
x = 1
print x
time.sleep(1)
class testGUI(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Test", size=(500,270))
panel = wx.Panel(self, -1)
self.buttonStart = wx.Button(panel, -1, label="Start thread", pos=(0,0))
self.buttonChange = wx.Button(panel, -1, label="Change var", pos=(0,30))
panel.Bind(wx.EVT_BUTTON, self.startThread, id=self.buttonStart.GetId())
panel.Bind(wx.EVT_BUTTON, self.changeVar, id=self.buttonChange.GetId())
def startThread(self, event):
testThread(self)
def changeVar(self, event):
# DO SOMETHING HERE THAT CHANGES 'x' IN THREAD TO 2...
pass
if __name__ == '__main__':
app = wx.App(redirect=False)
frame = testGUI()
frame.Show(True)
app.MainLoop()
So the question is, what do I put in the function changeVar that will modify the contents of the variable x that is in the running thread? Thanks in advance!

You can't change local variables.
What you can do is this:
class testThread(Thread):
def __init__(self, parent):
self.parent = parent
Thread.__init__(self)
self.start()
def run(self):
self.value = 1
while 1:
print self.value
time.sleep(1)
class testGUI(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Test", size=(500,270))
panel = wx.Panel(self, -1)
self.buttonStart = wx.Button(panel, -1, label="Start thread", pos=(0,0))
self.buttonChange = wx.Button(panel, -1, label="Change var", pos=(0,30))
panel.Bind(wx.EVT_BUTTON, self.startThread, id=self.buttonStart.GetId())
panel.Bind(wx.EVT_BUTTON, self.changeVar, id=self.buttonChange.GetId())
def startThread(self, event):
self.the_thread = testThread(self)
def changeVar(self, event):
# DO SOMETHING HERE THAT CHANGES 'x' IN THREAD TO 2...
self.the_thread.value = 2
if __name__ == '__main__':
app = wx.App(redirect=False)
frame = testGUI()
frame.Show(True)
app.MainLoop()

You don't need threads for that, at all. wx includes a wx.Timer that allows you to call your function with a time interval in the same thread. Chances are that wx includes a function to do what you want, too:
import wx
class testGUI(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Test", size=(500,270))
panel = wx.Panel(self, -1)
self.buttonStart = wx.Button(panel, -1, label="Start timer", pos=(0,0))
self.buttonChange = wx.Button(panel, -1, label="Change var", pos=(0,30))
panel.Bind(wx.EVT_BUTTON, self.startTimer, id=self.buttonStart.GetId())
panel.Bind(wx.EVT_BUTTON, self.changeVar, id=self.buttonChange.GetId())
self.value = 1
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.printer, self.timer)
def startTimer(self, event):
self.timer.Start(1000) # 1 second
def printer(self, event):
print self.value
def changeVar(self, event):
self.value = 2
if __name__ == '__main__':
app = wx.App(redirect=False)
frame = testGUI()
frame.Show(True)
app.MainLoop()

Related

Why can't you call object attributes within __init__?

I'm trying to understand why you can call an object's attribute within a class' method, but not within it's constructor. For example:
class Panel1(wx.Panel):
#include Frame in the constructor
def __init__(self, parent, frame):
wx.Panel.__init__(self, parent)
#set up so objects assigned in Frame (and it's children) can be called
self.frame = frame
button = wx.Button(self, label='Test')
#button.Bind(wx.EVT_BUTTON, lambda event: self.onButton(event))
button.Bind(wx.EVT_BUTTON, self.onButton)
pprint(vars(self.frame))
def onButton(self, event):
print("Button pressed.")
pprint(vars(self.frame))
#the following fails in the constructor as panel2 for some reason is not callable
a = self.frame.panel2.a
print("123: " + str(a))
Could someone point me to a link that explains why this isn't possible in the constructor?
Thanks!
*****EDIT****
Below is functional code to help explain my question better. If you try to call Panel2 attributes via the parent within Panel1's constructor, it fails. But it works fine when done inside Panel1's onButton method. I'd like to understand why.
import wx
from pprint import pprint
class Panel1(wx.Panel):
#include Frame in the constructor
def __init__(self, parent, frame):
wx.Panel.__init__(self, parent)
self.frame = frame
self.strPanel1 = "Panel1 string"
self.intPanel1 = 0
button = wx.Button(self, label='Test')
button.Bind(wx.EVT_BUTTON, self.onButton)
self.textbox = wx.TextCtrl(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
sizer.Add(self.textbox, 0, wx.ALL, 5)
sizer.Add(button, 0, wx.ALL, 5)
#pprint self.frame attributes fail here
def onButton(self, event):
#but not here!?!
print("Panel1 button pressed.")
pprint(vars(self.frame))
Panel2str = self.frame.panel2.strPanel2
print(Panel2str)
Panel2int = self.frame.panel2.intPanel2
print(str(Panel2int))
#Panel2 button press counter
self.frame.panel2.intPanel2 += 1
self.frame.panel2.trigger()
def trigger(self):
print("Panel1 has been triggered")
class Panel2(wx.Panel):
#include Frame in the constructor
def __init__(self, parent, frame):
wx.Panel.__init__(self, parent)
self.frame = frame
self.strPanel2 = "Panel2 string"
self.intPanel2 = 0
button = wx.Button(self, label='Test')
button.Bind(wx.EVT_BUTTON, self.onButton)
self.textbox = wx.TextCtrl(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
sizer.Add(self.textbox, 0, wx.ALL, 5)
sizer.Add(button, 0, wx.ALL, 5)
#pprint self.frame attributes fail here
def onButton(self, event):
#but not here!?!
print("Panel2 button pressed.")
pprint(vars(self.frame))
Panel1str = self.frame.panel1.strPanel1
print(Panel1str)
Panel1int = self.frame.panel1.intPanel1
print(str(Panel1int))
#Panel1 button press counter
self.frame.panel1.intPanel1 += 1
self.frame.panel1.trigger()
def trigger(self):
print("Panel2 has been triggered")
class Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="My Frame")
#Spliiting the frame
splitter = wx.SplitterWindow(self)
#Send frame to children
self.panel1 = Panel1(splitter, self)
self.panel2 = Panel2(splitter, self)
splitter.SplitVertically(self.panel1, self.panel2, 0)
splitter.SetMinimumPaneSize(200)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(splitter, 1, wx.EXPAND)
self.SetSizer(sizer)
if __name__ == '__main__':
app = wx.App()
frame = Frame()
frame.Show()
frame.Centre()
app.MainLoop()
Below is functional code to help explain my question better. If you try to call Panel2 attributes via the parent within Panel1's constructor, it fails.
It fails, because at the time your Panel1.__init__ is called, frame.panel2 is not set yet. Look at your Frame class:
class Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="My Frame")
#Spliiting the frame
splitter = wx.SplitterWindow(self)
#Send frame to children
self.panel1 = Panel1(splitter, self)
self.panel2 = Panel2(splitter, self)
...
When your Panel1 is initialized, panel2 is not set yet. It will only be set once Panel1 is done initializing and has been assigned to frame.panel1. If you absolutely need to access panel2 into Panel1.__init__, then you could make it so that your Panel1 take care of it. For example:
class Panel1:
def __init__(self, frame):
# Initialize panel2 and assign it to our frame
frame.panel2 = Panel2(frame)
# Now we can do whatever with panel2
frame.panel2
class Panel2:
def __init__(self, frame):
pass
class Frame:
def __init__(self):
# This initialize panel1, and internally initialize panel2
self.panel1 = Panel1(self)
frame = Frame()

On button click open wxpython TextEntryDialog and get multiple input from user

I want to open a TextEntryDialog, when user clicks the button. So if i have a button in the parent frame which i am going to bind this way:
self.Bind(wx.EVT_BUTTON, self.OnAddNew, self.add_new_btn)
Now i have to open a TextEntryDialog when user clicks the button add_new. I want to make textentrydialog somewthing like this
Python, Using wxPython to get multiple input from user
How can i do that? Do i need to just paste that code in ` def OnAddNew(self, event):
Here is the pastebin link to my code: https://pastebin.com/UEYscgFa
I have created class inside a function, so is it possible to do in that way?
NO!
GetData is a class in its own right.
That code already provides you with the method.
The MyFrame is all fluff, to create a standalone working example.
def OnButton(self,event):
dlg = GetData(parent = self.panel)
dlg.ShowModal()
if dlg.result_name:
self.log.AppendText("Name: "+dlg.result_name+"\n")
self.log.AppendText("Surname: "+dlg.result_surname+"\n")
self.log.AppendText("Nickname: "+dlg.result_nickname+"\n")
else:
self.log.AppendText("No Input found\n")
dlg.Destroy()
Edit: I don't understand where the instructions in my comments eluded you but for my sins, here is your code cleaned up and edited as in the comments.
import sqlite3
import wx
import os
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title=title, size=(1000,800))
self.inter_list = list()
self.plot_list = list()
self.InitUI()
self.Layout()
self.Centre()
self.Show()
def InitUI(self):
self.p = wx.Panel(self)
bs = wx.BoxSizer(wx.VERTICAL)
gs = wx.GridSizer(10, 18, 5, 5)
bs.Add(gs, 1, wx.EXPAND)
self.search_btn=wx.Button(self.p,-1,"Search!")
self.search_btn.Bind(wx.EVT_BUTTON, self.OnSearch, self.search_btn)
bs.Add(self.search_btn,0,wx.ALIGN_CENTER)
self.p.SetSizer(bs)
def OnSearch(self, event):
dlg = GetData(parent = self.p)
dlg.ShowModal()
if dlg.result_name:
print "Name: "+dlg.result_name+"\n"
print "Surname: "+dlg.result_surname+"\n"
print "Nickname: "+dlg.result_nickname+"\n"
else:
print "No Input found\n"
dlg.Destroy()
class GetData(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, parent, wx.ID_ANY, "Name Input", size= (650,220))
self.p = wx.Panel(self,wx.ID_ANY)
self.lblname = wx.StaticText(self.p, label="Name", pos=(20,20))
self.name = wx.TextCtrl(self.p, value="", pos=(110,20), size=(500,-1))
self.lblsur = wx.StaticText(self.p, label="Surname", pos=(20,60))
self.surname = wx.TextCtrl(self.p, value="", pos=(110,60), size=(500,-1))
self.lblnick = wx.StaticText(self.p, label="Nickname", pos=(20,100))
self.nickname = wx.TextCtrl(self.p, value="", pos=(110,100), size=(500,-1))
self.saveButton =wx.Button(self.p, label="Save", pos=(110,160))
self.closeButton =wx.Button(self.p, label="Cancel", pos=(210,160))
self.saveButton.Bind(wx.EVT_BUTTON, self.SaveConnString)
self.closeButton.Bind(wx.EVT_BUTTON, self.OnQuit)
self.Bind(wx.EVT_CLOSE, self.OnQuit)
self.Show()
def OnQuit(self, event):
self.result_name = None
self.Destroy()
def SaveConnString(self, event):
self.result_name = self.name.GetValue()
self.result_surname = self.surname.GetValue()
self.result_nickname = self.nickname.GetValue()
self.Destroy()
app = wx.App()
Example(None, title = 'Raman Spectroscopy Database')
app.MainLoop()

Python WX - Returning user input from wx Dialog

I'm new to Python and WX. I created a simple test dialog shown below that prompts the user with a combobox. I would like to capture the value from the combox in my main program. How do I call it from my main program?
This is how I was purposing to call it that displays the dialog but does not currently capture the value from the combobox:
import highlight
highlight.create(self).Show(True)
a = highlight.OnComboBox1Combobox(self)
print a
The name of the Dialog file is "highlight". Below is the code:
#Boa:Dialog:Dialog2
import wx
def create(parent):
return Dialog2(parent)
[wxID_DIALOG2, wxID_DIALOG2COMBOBOX1, wxID_DIALOG2STATICTEXT1,
] = [wx.NewId() for _init_ctrls in range(3)]
class Dialog2(wx.Dialog):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Dialog.__init__(self, id=wxID_DIALOG2, name='', parent=prnt,
pos=wx.Point(264, 140), size=wx.Size(400, 485),
style=wx.DEFAULT_DIALOG_STYLE, title='Dialog2')
self.SetClientSize(wx.Size(384, 447))
self.comboBox1 = wx.ComboBox(choices=['test1', 'test2'],
id=wxID_DIALOG2COMBOBOX1, name='comboBox1', parent=self,
pos=wx.Point(120, 16), size=wx.Size(130, 21), style=0,
value=u'wining\n')
self.comboBox1.SetToolTipString(u'comboBox1')
self.comboBox1.SetLabel(u'wining\n')
self.comboBox1.Bind(wx.EVT_COMBOBOX, self.OnComboBox1Combobox,
id=wxID_DIALOG2COMBOBOX1)
self.staticText1 = wx.StaticText(id=wxID_DIALOG2STATICTEXT1,
label=u'test', name='staticText1', parent=self, pos=wx.Point(88,
16), size=wx.Size(19, 13), style=0)
def __init__(self, parent):
self._init_ctrls(parent)
##print get_selection
##print get_selection1
def OnComboBox1Combobox(self, event):
get_selection = self.comboBox1.GetValue()
return get_selection
There are lots of dialog examples out there. Here are a couple:
The Dialogs of wxPython (Part 1 of 2)
http://zetcode.com/wxpython/dialogs/
Basically, all you need to do is instantiate your dialog, show it and then before you close it, extract the value. The typical way to do it is something like this:
myDlg = MyDialog()
res = myDlg.ShowModal()
if res == wx.ID_OK:
value = myDlg.myCombobox.GetValue()
myDlg.Destroy()
Update: Here's a more full-fledged example:
import wx
########################################################################
class MyDialog(wx.Dialog):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Dialog.__init__(self, None, title="Dialog")
self.comboBox1 = wx.ComboBox(self,
choices=['test1', 'test2'],
value="")
okBtn = wx.Button(self, wx.ID_OK)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.comboBox1, 0, wx.ALL|wx.CENTER, 5)
sizer.Add(okBtn, 0, wx.ALL|wx.CENTER, 5)
self.SetSizer(sizer)
########################################################################
class MainProgram(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, title="Main Program")
panel = wx.Panel(self)
btn = wx.Button(panel, label="Open dialog")
btn.Bind(wx.EVT_BUTTON, self.onDialog)
self.Show()
#----------------------------------------------------------------------
def onDialog(self, event):
""""""
dlg = MyDialog()
res = dlg.ShowModal()
if res == wx.ID_OK:
print dlg.comboBox1.GetValue()
dlg.Destroy()
if __name__ == "__main__":
app = wx.App(False)
frame = MainProgram()
app.MainLoop()

Marquee style progressbar in wxPython

Could anyone tell me how to implement a marquee style progress bar in wxPython? As stated on MSDN:
you can animate it in a way that shows
activity but does not indicate what
proportion of the task is complete.
Thank you.
alt text http://i.msdn.microsoft.com/dynimg/IC100842.png
I tried this but it doesn't seem to work. The timer ticks but the gauge doesn't scroll. Any help?
import wx
import time
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "Timer Tutorial 1",
size=(500,500))
# Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.update, self.timer)
self.gauProgress = wx.Gauge(panel, range=1000, pos=(30, 50), size=(440, 20))
self.toggleBtn = wx.Button(panel, wx.ID_ANY, "Start")
self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle)
def onToggle(self, event):
btnLabel = self.toggleBtn.GetLabel()
if btnLabel == "Start":
print "starting timer..."
self.timer.Start(1000)
self.toggleBtn.SetLabel("Stop")
else:
print "timer stopped!"
self.timer.Stop()
self.toggleBtn.SetLabel("Start")
def update(self, event):
print "\nupdated: ",
print time.ctime()
self.gauProgress.Pulse()
# Run the program
if __name__ == "__main__":
app = wx.PySimpleApp()
frame = MyForm().Show()
app.MainLoop()
wxGauge has a Pulse() function
gauge.Pulse()
Here is an example:
def loadBallots(self):
self.dirtyBallots = Ballots()
self.dirtyBallots.exceptionQueue = Queue(1)
loadThread = Thread(target=self.dirtyBallots.loadUnknown, args=(self.filename,))
loadThread.start()
# Display a progress dialog
dlg = wx.ProgressDialog(\
"Loading ballots",
"Loading ballots from %s\nNumber of ballots: %d" %
(os.path.basename(self.filename), self.dirtyBallots.numBallots),
parent=self.frame, style = wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME
)
while loadThread.isAlive():
sleep(0.1)
dlg.Pulse("Loading ballots from %s\nNumber of ballots: %d" %
(os.path.basename(self.filename), self.dirtyBallots.numBallots))
dlg.Destroy()
if not self.dirtyBallots.exceptionQueue.empty():
raise RuntimeError(self.dirtyBallots.exceptionQueue.get())
This is from here.
how about something like this?
class ProgressDialog(wx.Dialog):
def __init__(self, parent, title, to_add=1):
"""Defines a gauge and a timer which updates the gauge."""
wx.Dialog.__init__(self, parent, title=title, style=wx.CAPTION)
self.count = 0
self.to_add = to_add
self.timer = wx.Timer(self)
self.gauge = wx.Gauge(self, range=100, size=(180, 30))
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.gauge, 0, wx.ALL, 10)
self.SetSizer(sizer)
sizer.Fit(self)
self.SetFocus()
self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
self.timer.Start(30) # or however often you want
def on_timer(self, event):
"""Increases the gauge's progress."""
self.count += self.to_add
if self.count > 100:
self.count = 0
self.gauge.SetValue(self.count)

Losing control of GUI upon playing a wav file

I can't understand why I am loosing control of my GUI even though I am implementing a thread to play a .wav file. Can someone pin point what is incorrect?
#!/usr/bin/env python
import wx, pyaudio, wave, easygui, thread, time, os, sys, traceback, threading
import wx.lib.delayedresult as inbg
isPaused = False
isStopped = False
class Frame(wx.Frame):
def __init__(self):
print 'Frame'
wx.Frame.__init__(self, parent=None, id=-1, title="Jasmine", size=(720, 300))
#initialize panel
panel = wx.Panel(self, -1)
#initialize grid bag
sizer = wx.GridBagSizer(hgap=20, vgap=20)
#initialize buttons
exitButton = wx.Button(panel, wx.ID_ANY, "Exit")
pauseButton = wx.Button(panel, wx.ID_ANY, 'Pause')
prevButton = wx.Button(panel, wx.ID_ANY, 'Prev')
nextButton = wx.Button(panel, wx.ID_ANY, 'Next')
stopButton = wx.Button(panel, wx.ID_ANY, 'Stop')
#add widgets to sizer
sizer.Add(pauseButton, pos=(1,10))
sizer.Add(prevButton, pos=(1,11))
sizer.Add(nextButton, pos=(1,12))
sizer.Add(stopButton, pos=(1,13))
sizer.Add(exitButton, pos=(5,13))
#initialize song time gauge
#timeGauge = wx.Gauge(panel, 20)
#sizer.Add(timeGauge, pos=(3,10), span=(0, 0))
#initialize menuFile widget
menuFile = wx.Menu()
menuFile.Append(0, "L&oad")
menuFile.Append(1, "E&xit")
menuBar = wx.MenuBar()
menuBar.Append(menuFile, "&File")
menuAbout = wx.Menu()
menuAbout.Append(2, "A&bout...")
menuAbout.AppendSeparator()
menuBar.Append(menuAbout, "Help")
self.SetMenuBar(menuBar)
self.CreateStatusBar()
self.SetStatusText("Welcome to Jasime!")
#place sizer on panel
panel.SetSizer(sizer)
#initialize icon
self.cd_image = wx.Image('cd_icon.png', wx.BITMAP_TYPE_PNG)
self.temp = self.cd_image.ConvertToBitmap()
self.size = self.temp.GetWidth(), self.temp.GetHeight()
wx.StaticBitmap(parent=panel, bitmap=self.temp)
#set binding
self.Bind(wx.EVT_BUTTON, self.OnQuit, id=exitButton.GetId())
self.Bind(wx.EVT_BUTTON, self.pause, id=pauseButton.GetId())
self.Bind(wx.EVT_BUTTON, self.stop, id=stopButton.GetId())
self.Bind(wx.EVT_MENU, self.loadFile, id=0)
self.Bind(wx.EVT_MENU, self.OnQuit, id=1)
self.Bind(wx.EVT_MENU, self.OnAbout, id=2)
#Load file using FileDialog, and create a thread for user control while running the file
def loadFile(self, event):
foo = wx.FileDialog(self, message="Open a .wav file...", defaultDir=os.getcwd(), defaultFile="", style=wx.FD_MULTIPLE)
foo.ShowModal()
self.queue = foo.GetPaths()
self.threadID = 1
while len(self.queue) != 0:
self.song = myThread(self.threadID, self.queue[0])
self.song.start()
while self.song.isAlive():
time.sleep(2)
self.queue.pop(0)
self.threadID += 1
def OnQuit(self, event):
self.Close()
def OnAbout(self, event):
wx.MessageBox("This is a great cup of tea.", "About Jasmine", wx.OK | wx.ICON_INFORMATION, self)
def pause(self, event):
global isPaused
isPaused = not isPaused
def stop(self, event):
global isStopped
isStopped = not isStopped
class myThread (threading.Thread):
def __init__(self, threadID, wf):
self.threadID = threadID
self.wf = wf
threading.Thread.__init__(self)
def run(self):
global isPaused
global isStopped
self.waveFile = wave.open(self.wf, 'rb')
#initialize stream
self.p = pyaudio.PyAudio()
self.stream = self.p.open(format = self.p.get_format_from_width(self.waveFile.getsampwidth()), channels = self.waveFile.getnchannels(), rate = self.waveFile.getframerate(), output = True)
self.data = self.waveFile.readframes(1024)
isPaused = False
isStopped = False
#main play loop, with pause event checking
while self.data != '':
# while isPaused != True:
# if isStopped == False:
self.stream.write(self.data)
self.data = self.waveFile.readframes(1024)
# elif isStopped == True:
# self.stream.close()
# self.p.terminate()
self.stream.close()
self.p.terminate()
class App(wx.App):
def OnInit(self):
self.frame = Frame()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main():
app = App()
app.MainLoop()
if __name__=='__main__':
main()
Your loadFile method, quite independently of the fact that it delegates song-playing to many threads (which it waits for in strange ways, but, that's another issue), is still monopolizing the wx event loop until it returns. Where you currently have a time.sleep, try adding app.Yield(True) (of course you need to make app visible at that point in your code: simplest though inelegant is to add a global app at the start of main.
Event-driven systems typically serve the event loop only when your various event handler methods return: if you have a long-running event handler, you need to explicitly yield control to the event loop once in a while. Various event systems offer different ways to do it: in wx, it's the Yield method which I just recommended you try. See the brief description un the docs.

Categories