From 7fc0f1c4759899a018801b5ac87d949a01ef6acb Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Fri, 17 May 2013 17:04:41 +0200 Subject: [PATCH] Add -g/--gauges CLI argument for temp gauges, and improved argparsing. The gauges options is a CLI parameter as having it as an option would be too painful to handle for now. Argument parsing has been improved so that pronterface can add its own CLI parameters in addition to pronsole's ones. --- printrun/gui.py | 1 - pronsole.py | 12 +++++++++--- pronterface.py | 8 ++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/printrun/gui.py b/printrun/gui.py index 28bc1a5..c44c148 100644 --- a/printrun/gui.py +++ b/printrun/gui.py @@ -165,7 +165,6 @@ class LeftPane(wx.GridBagSizer): root.zfeedc.SetBackgroundColour((180, 255, 180)) root.zfeedc.SetForegroundColour("black") - root.display_gauges = True # FIXME : move to options or CLI options if root.display_gauges: root.hottgauge = TempGauge(root.panel, size = (200, 24), title = _("Heater:"), maxval = 300) self.Add(root.hottgauge, pos = (6, 0), span = (1, 6)) diff --git a/pronsole.py b/pronsole.py index dfa93d7..96ca97c 100755 --- a/pronsole.py +++ b/pronsole.py @@ -1207,12 +1207,12 @@ class pronsole(cmd.Cmd): self.log("home e - set extruder position to zero (Using G92)") self.log("home xyze - homes all axes and zeroes the extruder (Using G28 and G92)") - def parse_cmdline(self, args): - parser = argparse.ArgumentParser(description = 'Printrun 3D printer interface') + def add_cmdline_arguments(self, parser): parser.add_argument('-c','--conf','--config', help = _("load this file on startup instead of .pronsolerc ; you may chain config files, if so settings auto-save will use the last specified file"), action = "append", default = []) parser.add_argument('-e','--execute', help = _("executes command after configuration/.pronsolerc is loaded ; macros/settings from these commands are not autosaved"), action = "append", default = []) parser.add_argument('filename', nargs='?', help = _("file to load")) - args = parser.parse_args() + + def process_cmdline_arguments(self, args): for config in args.conf: self.load_rc(config) if not self.rc_loaded: @@ -1224,6 +1224,12 @@ class pronsole(cmd.Cmd): if args.filename: self.do_load(args.filename) + def parse_cmdline(self, args): + parser = argparse.ArgumentParser(description = 'Printrun 3D printer interface') + self.add_cmdline_arguments(parser) + args = parser.parse_args() + self.process_cmdline_arguments(args) + # We replace this function, defined in cmd.py . # It's default behavior with reagrds to Ctr-C # and Ctr-D doesn't make much sense... diff --git a/pronterface.py b/pronterface.py index bbcb5e8..360c8a1 100755 --- a/pronterface.py +++ b/pronterface.py @@ -198,6 +198,14 @@ class PronterWindow(MainWindow, pronsole.pronsole): if self.filename is not None: self.do_load(self.filename) + def add_cmdline_arguments(self, parser): + pronsole.pronsole.add_cmdline_arguments(self, parser) + parser.add_argument('-g','--gauges', help = _("display graphical temperature gauges in addition to the temperatures graph"), action = "store_true") + + def process_cmdline_arguments(self, args): + pronsole.pronsole.process_cmdline_arguments(self, args) + self.display_gauges = args.gauges + def startcb(self): self.starttime = time.time() print "Print Started at: " + format_time(self.starttime)