Hi, I'm a newbie struggling to understand wxpython, much appreciated if you guys can solved my problem. Try googling but still does not have any clue on how to stop the loop by pressing the stop button.
Window XP / Python 2.5 /wxpython 2.8
[CODE=python]import wx
global OK
def Start(event):
OK=1
while OK:
# Hopefully this GUI take input from external device
print "Testing"
# close port
def Stop(event):
OK=0
app=wx.App()
win=wx.Frame(No ne,title="Simpl e Editor",size=(4 10,335))
bkg=wx.Panel(wi n)
loadButton=wx.B utton(bkg,label ='Start')
loadButton.Bind (wx.EVT_BUTTON, Start)
saveButton=wx.B utton(bkg,label ='Stop')
saveButton.Bind (wx.EVT_BUTTON, Stop)
contents=wx.Tex tCtrl(bkg,style =wx.TE_MULTILIN E)
hbox = wx.BoxSizer()
hbox.Add(loadBu tton,proportion =0,border=2)
hbox.Add(saveBu tton,proportion =0,border=2)
vbox = wx.BoxSizer(wx. VERTICAL)
vbox.Add(conten ts,proportion=1 ,flag=wx.EXPAND |wx.LEFT|wx.RIG HT,border=5)
vbox.Add(hbox,p roportion=0,fla g=wx.EXPAND|wx. ALL,border=5)
bkg.SetSizer(vb ox)
win.Show()
app.MainLoop()
[/CODE]
Window XP / Python 2.5 /wxpython 2.8
[CODE=python]import wx
global OK
def Start(event):
OK=1
while OK:
# Hopefully this GUI take input from external device
print "Testing"
# close port
def Stop(event):
OK=0
app=wx.App()
win=wx.Frame(No ne,title="Simpl e Editor",size=(4 10,335))
bkg=wx.Panel(wi n)
loadButton=wx.B utton(bkg,label ='Start')
loadButton.Bind (wx.EVT_BUTTON, Start)
saveButton=wx.B utton(bkg,label ='Stop')
saveButton.Bind (wx.EVT_BUTTON, Stop)
contents=wx.Tex tCtrl(bkg,style =wx.TE_MULTILIN E)
hbox = wx.BoxSizer()
hbox.Add(loadBu tton,proportion =0,border=2)
hbox.Add(saveBu tton,proportion =0,border=2)
vbox = wx.BoxSizer(wx. VERTICAL)
vbox.Add(conten ts,proportion=1 ,flag=wx.EXPAND |wx.LEFT|wx.RIG HT,border=5)
vbox.Add(hbox,p roportion=0,fla g=wx.EXPAND|wx. ALL,border=5)
bkg.SetSizer(vb ox)
win.Show()
app.MainLoop()
[/CODE]
Comment