From cf8c8ffa428b3624dcb4161421f57498c5a6c4e5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Jul 2011 15:13:11 +0200 Subject: [PATCH 1/6] Rename Restart/Resume buttons back to Print/Pause when a new GCode file was loaded. --- pronterface.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pronterface.py b/pronterface.py index 8421a8d..e4bb8ff 100644 --- a/pronterface.py +++ b/pronterface.py @@ -649,6 +649,8 @@ 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") threading.Thread(target=self.loadviz).start() def loadviz(self): From 38f34ac9344e88a65223b3a48bd6034545e6e42a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Jul 2011 15:18:03 +0200 Subject: [PATCH 2/6] Enable and disable Print and Pause buttons consistently. --- pronterface.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pronterface.py b/pronterface.py index e4bb8ff..300eb96 100644 --- a/pronterface.py +++ b/pronterface.py @@ -266,9 +266,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): 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) + self.pausebtn.Disable() ubs.Add(self.pausebtn) ubs.Add((50,-1),flag=wx.EXPAND) try: @@ -651,6 +653,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),)) self.printbtn.SetLabel("Print") self.pausebtn.SetLabel("Pause") + self.printbtn.Enable() threading.Thread(target=self.loadviz).start() def loadviz(self): From 1c8f97cc2011ce4b0fba88b08616505ace0552e9 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Jul 2011 15:20:33 +0200 Subject: [PATCH 3/6] Enable/disable Connect/Disconnect buttons alternatively. --- pronterface.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pronterface.py b/pronterface.py index 300eb96..db5e3c3 100644 --- a/pronterface.py +++ b/pronterface.py @@ -236,6 +236,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.disconnectbtn.Disable(); uts.Add(self.disconnectbtn) self.resetbtn=wx.Button(self.panel,-1,"Reset",pos=(560,0)) self.resetbtn.Bind(wx.EVT_BUTTON,self.reset) @@ -764,12 +765,16 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.set("port",port) if baud != self.settings.baudrate: self.set("baudrate",str(baud)) + self.disconnectbtn.Enable(); + self.connectbtn.Disable(); threading.Thread(target=self.statuschecker).start() def disconnect(self,event): self.p.disconnect() self.statuscheck=False + self.disconnectbtn.Disable(); + self.connectbtn.Enable(); if self.paused: self.p.paused=0 self.p.printing=0 From cac5f9bc71211aeb771588ef7e5c79775bda41cf Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Jul 2011 15:38:49 +0200 Subject: [PATCH 4/6] Enable/disable all printer controls when we're connected or disconnected. --- pronterface.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/pronterface.py b/pronterface.py index db5e3c3..38e4306 100644 --- a/pronterface.py +++ b/pronterface.py @@ -100,6 +100,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): def online(self): print "Printer is now online" + self.connectbtn.Disable(); + for i in self.printerControls: + i.Enable() + def sentcb(self,line): if("G1" in line): @@ -203,6 +207,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,10 +244,11 @@ 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.disconnectbtn.Disable(); + 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) + self.printerControls.append(self.resetbtn) uts.Add(self.resetbtn) self.minibtn=wx.Button(self.panel,-1,"Mini mode",pos=(690,0)) self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview) @@ -258,12 +267,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.loadbtn=wx.Button(self.panel,-1,"Load file",pos=(0,40)) self.loadbtn.Bind(wx.EVT_BUTTON,self.loadfile) + self.printerControls.append(self.loadbtn) 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) @@ -293,9 +305,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) @@ -318,6 +332,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]) @@ -329,6 +344,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, @@ -338,6 +354,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)) @@ -399,6 +416,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.topsizer.Layout() self.topsizer.Fit(self) + # disable all printer controls until we connect to a printer + for i in self.printerControls: + i.Disable() + #self.panel.Fit() #uts.Layout() @@ -765,16 +786,17 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.set("port",port) if baud != self.settings.baudrate: self.set("baudrate",str(baud)) - self.disconnectbtn.Enable(); - self.connectbtn.Disable(); threading.Thread(target=self.statuschecker).start() def disconnect(self,event): self.p.disconnect() self.statuscheck=False - self.disconnectbtn.Disable(); + self.connectbtn.Enable(); + for i in self.printerControls: + i.Disable() + if self.paused: self.p.paused=0 self.p.printing=0 From 6d78deeab25dec0ed94a2b4573b21eaf0c49f611 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Jul 2011 15:54:59 +0200 Subject: [PATCH 5/6] Leave Reset enabled and allow loading a GCode file without connecting to the printer. --- pronterface.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pronterface.py b/pronterface.py index 38e4306..bbce091 100644 --- a/pronterface.py +++ b/pronterface.py @@ -103,6 +103,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.connectbtn.Disable(); for i in self.printerControls: i.Enable() + if self.filename: + self.printbtn.Enable() def sentcb(self,line): @@ -248,7 +250,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole): uts.Add(self.disconnectbtn) self.resetbtn=wx.Button(self.panel,-1,"Reset",pos=(560,0)) self.resetbtn.Bind(wx.EVT_BUTTON,self.reset) - self.printerControls.append(self.resetbtn) uts.Add(self.resetbtn) self.minibtn=wx.Button(self.panel,-1,"Mini mode",pos=(690,0)) self.minibtn.Bind(wx.EVT_BUTTON,self.toggleview) @@ -267,7 +268,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.loadbtn=wx.Button(self.panel,-1,"Load file",pos=(0,40)) self.loadbtn.Bind(wx.EVT_BUTTON,self.loadfile) - self.printerControls.append(self.loadbtn) ubs.Add(self.loadbtn) self.uploadbtn=wx.Button(self.panel,-1,"SD Upload",pos=(90,40)) self.uploadbtn.Bind(wx.EVT_BUTTON,self.upload) @@ -675,7 +675,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),)) self.printbtn.SetLabel("Print") self.pausebtn.SetLabel("Pause") - self.printbtn.Enable() + if self.p.online: + self.printbtn.Enable() threading.Thread(target=self.loadviz).start() def loadviz(self): @@ -690,9 +691,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") @@ -707,7 +707,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.pausebtn.Enable() self.printbtn.SetLabel("Restart") self.p.startprint(self.f) - + + def on_startprint(self): + self.pausebtn.SetLabel("Pause") + self.printbtn.SetLabel("Print") + def endupload(self): self.p.send_now("M29 ") wx.CallAfter(self.status.SetStatusText,"File upload complete") @@ -756,6 +760,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): def sdprintfile(self,event): + self.on_startprint() threading.Thread(target=self.getfiles).start() pass @@ -794,6 +799,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.statuscheck=False self.connectbtn.Enable(); + self.printbtn.Disable(); + self.pausebtn.Disable(); for i in self.printerControls: i.Disable() From 4724fc0c049f9c7531494899521bbad1bdb3a6d9 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 9 Jul 2011 16:07:17 +0200 Subject: [PATCH 6/6] Hide the pause button until needed. --- pronterface.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pronterface.py b/pronterface.py index bbce091..94028f9 100644 --- a/pronterface.py +++ b/pronterface.py @@ -283,7 +283,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ubs.Add(self.printbtn) self.pausebtn=wx.Button(self.panel,-1,"Pause",pos=(360,40)) self.pausebtn.Bind(wx.EVT_BUTTON,self.pause) - self.pausebtn.Disable() ubs.Add(self.pausebtn) ubs.Add((50,-1),flag=wx.EXPAND) try: @@ -417,6 +416,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.topsizer.Fit(self) # disable all printer controls until we connect to a printer + self.pausebtn.Hide() for i in self.printerControls: i.Disable() @@ -675,6 +675,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): 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() @@ -704,13 +705,13 @@ 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.printbtn.SetLabel("Print") + self.pausebtn.Show() + self.printbtn.SetLabel("Restart") def endupload(self): self.p.send_now("M29 ") @@ -800,7 +801,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.connectbtn.Enable(); self.printbtn.Disable(); - self.pausebtn.Disable(); + self.pausebtn.Hide(); for i in self.printerControls: i.Disable()