Merge pull request #33 from alexrj/master

Disable buttons that require connection until connection established
master
kliment 2011-07-09 08:24:07 -07:00
commit 61af573e27
1 changed files with 45 additions and 5 deletions

View File

@ -100,6 +100,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def online(self):
print "Printer is now online"
self.connectbtn.Disable();
for i in self.printerControls:
i.Enable()
if self.filename:
self.printbtn.Enable()
def sentcb(self,line):
if("G1" in line):
@ -203,6 +209,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.Close()
def popwindow(self):
# this list will contain all controls that should be only enabled
# when we're connected to a printer
self.printerControls = []
#sizer layout: topsizer is a column sizer containing two sections
#upper section contains the mini view buttons
#lower section contains the rest of the window - manual controls, console, visualizations
@ -236,6 +246,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.connectbtn.Bind(wx.EVT_BUTTON,self.connect)
self.disconnectbtn=wx.Button(self.panel,-1,"Disconnect",pos=(470,0))
self.disconnectbtn.Bind(wx.EVT_BUTTON,self.disconnect)
self.printerControls.append(self.disconnectbtn)
uts.Add(self.disconnectbtn)
self.resetbtn=wx.Button(self.panel,-1,"Reset",pos=(560,0))
self.resetbtn.Bind(wx.EVT_BUTTON,self.reset)
@ -260,12 +271,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
ubs.Add(self.loadbtn)
self.uploadbtn=wx.Button(self.panel,-1,"SD Upload",pos=(90,40))
self.uploadbtn.Bind(wx.EVT_BUTTON,self.upload)
self.printerControls.append(self.uploadbtn)
ubs.Add(self.uploadbtn)
self.sdprintbtn=wx.Button(self.panel,-1,"SD Print",pos=(180,40))
self.sdprintbtn.Bind(wx.EVT_BUTTON,self.sdprintfile)
self.printerControls.append(self.sdprintbtn)
ubs.Add(self.sdprintbtn)
self.printbtn=wx.Button(self.panel,-1,"Print",pos=(270,40))
self.printbtn.Bind(wx.EVT_BUTTON,self.printfile)
self.printbtn.Disable()
ubs.Add(self.printbtn)
self.pausebtn=wx.Button(self.panel,-1,"Pause",pos=(360,40))
self.pausebtn.Bind(wx.EVT_BUTTON,self.pause)
@ -290,9 +304,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lbrs=wx.BoxSizer(wx.HORIZONTAL)
self.commandbox=wx.TextCtrl(self.panel,size=(250,30),pos=(440,420),style = wx.TE_PROCESS_ENTER)
self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline)
self.printerControls.append(self.commandbox)
lbrs.Add(self.commandbox)
self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(700,420))
self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline)
self.printerControls.append(self.sendbtn)
lbrs.Add(self.sendbtn)
lrs.Add(lbrs)
@ -315,6 +331,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
btn.properties=i
btn.Bind(wx.EVT_BUTTON,self.procbutton)
self.btndict[i[1]]=btn
self.printerControls.append(btn)
lls.Add(btn,pos=i[2],span=i[4])
@ -326,6 +343,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lls.Add(self.htemp,pos=(11,1),span=(1,3))
self.settbtn=wx.Button(self.panel,-1,"Set",size=(30,-1),pos=(135,335))
self.settbtn.Bind(wx.EVT_BUTTON,self.do_settemp)
self.printerControls.append(self.settbtn)
lls.Add(self.settbtn,pos=(11,4),span=(1,2))
lls.Add(wx.StaticText(self.panel,-1,"Bed:",pos=(0,343)),pos=(12,0),span=(1,1))
self.btemp=wx.ComboBox(self.panel, -1,
@ -335,6 +353,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lls.Add(self.btemp,pos=(12,1),span=(1,3))
self.setbbtn=wx.Button(self.panel,-1,"Set",size=(30,-1),pos=(135,365))
self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp)
self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn,pos=(12,4),span=(1,2))
self.tempdisp=wx.StaticText(self.panel,-1,"")
lls.Add(self.tempdisp,pos=(12,6),span=(1,3))
@ -396,6 +415,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.topsizer.Layout()
self.topsizer.Fit(self)
# disable all printer controls until we connect to a printer
self.pausebtn.Hide()
for i in self.printerControls:
i.Disable()
#self.panel.Fit()
#uts.Layout()
@ -649,6 +673,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.f=[i.replace("\n","").replace("\r","") for i in open(name)]
self.filename=name
self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),))
self.printbtn.SetLabel("Print")
self.pausebtn.SetLabel("Pause")
self.pausebtn.Hide()
if self.p.online:
self.printbtn.Enable()
threading.Thread(target=self.loadviz).start()
def loadviz(self):
@ -663,9 +692,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def printfile(self,event):
if self.paused:
self.p.paused=0
self.pausebtn.SetLabel("Pause")
self.printbtn.SetLabel("Print")
self.paused=0
self.on_startprint()
if self.sdprinting:
self.p.send_now("M26 S0")
self.p.send_now("M24")
@ -677,10 +705,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if not self.p.online:
wx.CallAfter(self.status.SetStatusText,"Not connected to printer.")
return
self.pausebtn.Enable()
self.printbtn.SetLabel("Restart")
self.on_startprint()
self.p.startprint(self.f)
def on_startprint(self):
self.pausebtn.SetLabel("Pause")
self.pausebtn.Show()
self.printbtn.SetLabel("Restart")
def endupload(self):
self.p.send_now("M29 ")
wx.CallAfter(self.status.SetStatusText,"File upload complete")
@ -729,6 +761,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def sdprintfile(self,event):
self.on_startprint()
threading.Thread(target=self.getfiles).start()
pass
@ -765,6 +798,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def disconnect(self,event):
self.p.disconnect()
self.statuscheck=False
self.connectbtn.Enable();
self.printbtn.Disable();
self.pausebtn.Hide();
for i in self.printerControls:
i.Disable()
if self.paused:
self.p.paused=0
self.p.printing=0