From 7245e54b4a09330030062c6f197893b995d85912 Mon Sep 17 00:00:00 2001 From: Keegi Date: Thu, 28 Jul 2011 12:33:39 +0300 Subject: [PATCH] Monitor command in pronterface now toggles the checkbox and sets the interval --- pronterface.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pronterface.py b/pronterface.py index 43a98ec..6bd2826 100755 --- a/pronterface.py +++ b/pronterface.py @@ -52,6 +52,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): self.statuscheck=False self.tempreport="" self.monitor=0 + self.monitor_interval=3 self.paused=False xcol=(245,245,108) ycol=(180,180,255) @@ -156,7 +157,6 @@ class PronterWindow(wx.Frame,pronsole.pronsole): except: pass - def do_settemp(self,l=""): try: if not (l.__class__=="".__class__ or l.__class__==u"".__class__) or (not len(l)): @@ -592,6 +592,23 @@ class PronterWindow(wx.Frame,pronsole.pronsole): pass self.Destroy() + def do_monitor(self,l=""): + if l.strip()=="": + self.monitorbox.SetValue(not self.monitorbox.GetValue()) + elif l.strip()=="off": + self.monitorbox.SetValue(False) + else: + try: + self.monitor_interval=float(l) + self.monitorbox.SetValue(self.monitor_interval>0) + except: + print "Invalid period given." + self.setmonitor(None) + if self.monitor: + print "Monitoring printer." + else: + print "Done monitoring." + def setmonitor(self,e): self.monitor=self.monitorbox.GetValue() @@ -626,7 +643,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): if self.sdprinting: self.p.send_now("M27") self.p.send_now("M105") - time.sleep(3) + time.sleep(self.monitor_interval) wx.CallAfter(self.status.SetStatusText,"Not connected to printer.") except: pass #if window has been closed