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.
master
Guillaume Seguin 2013-05-17 17:04:41 +02:00
parent 90e32562ea
commit 7fc0f1c475
3 changed files with 17 additions and 4 deletions

View File

@ -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))

View File

@ -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...

View File

@ -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)