Move all button enable/disable/setlabel calls inside wx.CallAfter() to avoid threading issues
parent
fba262be54
commit
9e11e5eef0
|
@ -119,11 +119,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
|
|
||||||
def online(self):
|
def online(self):
|
||||||
print "Printer is now online"
|
print "Printer is now online"
|
||||||
self.connectbtn.Disable();
|
wx.CallAfter(self.connectbtn.Disable)
|
||||||
for i in self.printerControls:
|
for i in self.printerControls:
|
||||||
i.Enable()
|
wx.CallAfter(i.Enable)
|
||||||
if self.filename:
|
if self.filename:
|
||||||
self.printbtn.Enable()
|
wx.CallAfter(self.printbtn.Enable)
|
||||||
|
|
||||||
|
|
||||||
def sentcb(self,line):
|
def sentcb(self,line):
|
||||||
|
@ -561,14 +561,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
self.topsizer.Fit(self)
|
self.topsizer.Fit(self)
|
||||||
|
|
||||||
#self.SetSize(winsize)
|
#self.SetSize(winsize)
|
||||||
self.minibtn.SetLabel("Mini mode")
|
wx.CallAfter(self.minibtn.SetLabel, "Mini mode")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.mini=True
|
self.mini=True
|
||||||
self.uppersizer.Fit(self)
|
self.uppersizer.Fit(self)
|
||||||
|
|
||||||
#self.SetSize(winssize)
|
#self.SetSize(winssize)
|
||||||
self.minibtn.SetLabel("Full mode")
|
wx.CallAfter(self.minibtn.SetLabel, "Full mode")
|
||||||
|
|
||||||
|
|
||||||
def procbutton(self,e):
|
def procbutton(self,e):
|
||||||
|
@ -794,11 +794,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
self.f=[i.replace("\n","").replace("\r","") for i in open(name)]
|
self.f=[i.replace("\n","").replace("\r","") for i in open(name)]
|
||||||
self.filename=name
|
self.filename=name
|
||||||
self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),))
|
self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),))
|
||||||
self.printbtn.SetLabel("Print")
|
wx.CallAfter(self.printbtn.SetLabel, "Print")
|
||||||
self.pausebtn.SetLabel("Pause")
|
wx.CallAfter(self.pausebtn.SetLabel, "Pause")
|
||||||
self.pausebtn.Hide()
|
wx.CallAfter(self.pausebtn.Hide)
|
||||||
if self.p.online:
|
if self.p.online:
|
||||||
self.printbtn.Enable()
|
wx.CallAfter(self.printbtn.Enable)
|
||||||
threading.Thread(target=self.loadviz).start()
|
threading.Thread(target=self.loadviz).start()
|
||||||
|
|
||||||
def loadviz(self):
|
def loadviz(self):
|
||||||
|
@ -830,9 +830,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
self.p.startprint(self.f)
|
self.p.startprint(self.f)
|
||||||
|
|
||||||
def on_startprint(self):
|
def on_startprint(self):
|
||||||
self.pausebtn.SetLabel("Pause")
|
wx.CallAfter(self.pausebtn.SetLabel, "Pause")
|
||||||
self.pausebtn.Show()
|
wx.CallAfter(self.pausebtn.Show)
|
||||||
self.printbtn.SetLabel("Restart")
|
wx.CallAfter(self.printbtn.SetLabel, "Restart")
|
||||||
|
|
||||||
def endupload(self):
|
def endupload(self):
|
||||||
self.p.send_now("M29 ")
|
self.p.send_now("M29 ")
|
||||||
|
@ -871,14 +871,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
return
|
return
|
||||||
self.p.pause()
|
self.p.pause()
|
||||||
self.paused=True
|
self.paused=True
|
||||||
self.pausebtn.SetLabel("Resume")
|
wx.CallAfter(self.pausebtn.SetLabel, "Resume")
|
||||||
else:
|
else:
|
||||||
self.paused=False
|
self.paused=False
|
||||||
if self.sdprinting:
|
if self.sdprinting:
|
||||||
self.p.send_now("M24")
|
self.p.send_now("M24")
|
||||||
else:
|
else:
|
||||||
self.p.resume()
|
self.p.resume()
|
||||||
self.pausebtn.SetLabel("Pause")
|
wx.CallAfter(self.pausebtn.SetLabel, "Pause")
|
||||||
|
|
||||||
|
|
||||||
def sdprintfile(self,event):
|
def sdprintfile(self,event):
|
||||||
|
@ -902,8 +902,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
if self.paused:
|
if self.paused:
|
||||||
self.p.paused=0
|
self.p.paused=0
|
||||||
self.p.printing=0
|
self.p.printing=0
|
||||||
self.pausebtn.SetLabel("Pause")
|
wx.CallAfter(self.pausebtn.SetLabel, "Pause")
|
||||||
self.printbtn.SetLabel("Print")
|
wx.CallAfter(self.printbtn.SetLabel, "Print")
|
||||||
self.paused=0
|
self.paused=0
|
||||||
if self.sdprinting:
|
if self.sdprinting:
|
||||||
self.p.send_now("M26 S0")
|
self.p.send_now("M26 S0")
|
||||||
|
@ -920,17 +920,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
self.p.disconnect()
|
self.p.disconnect()
|
||||||
self.statuscheck=False
|
self.statuscheck=False
|
||||||
|
|
||||||
self.connectbtn.Enable();
|
wx.CallAfter(self.connectbtn.Enable);
|
||||||
self.printbtn.Disable();
|
wx.CallAfter(self.printbtn.Disable);
|
||||||
self.pausebtn.Hide();
|
wx.CallAfter(self.pausebtn.Hide);
|
||||||
for i in self.printerControls:
|
for i in self.printerControls:
|
||||||
i.Disable()
|
wx.CallAfter(i.Disable)
|
||||||
|
|
||||||
if self.paused:
|
if self.paused:
|
||||||
self.p.paused=0
|
self.p.paused=0
|
||||||
self.p.printing=0
|
self.p.printing=0
|
||||||
self.pausebtn.SetLabel("Pause")
|
wx.CallAfter(self.pausebtn.SetLabel, "Pause")
|
||||||
self.printbtn.SetLabel("Print")
|
wx.CallAfter(self.printbtn.SetLabel, "Print")
|
||||||
self.paused=0
|
self.paused=0
|
||||||
if self.sdprinting:
|
if self.sdprinting:
|
||||||
self.p.send_now("M26 S0")
|
self.p.send_now("M26 S0")
|
||||||
|
@ -943,8 +943,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
|
||||||
if self.paused:
|
if self.paused:
|
||||||
self.p.paused=0
|
self.p.paused=0
|
||||||
self.p.printing=0
|
self.p.printing=0
|
||||||
self.pausebtn.SetLabel("Pause")
|
wx.CallAfter(self.pausebtn.SetLabel, "Pause")
|
||||||
self.printbtn.SetLabel("Print")
|
wx.CallAfter(self.printbtn.SetLabel, "Print")
|
||||||
self.paused=0
|
self.paused=0
|
||||||
|
|
||||||
class macroed(wx.Dialog):
|
class macroed(wx.Dialog):
|
||||||
|
|
Loading…
Reference in New Issue