Part 8b Loading Gremlin

Getting gremlin into your gui involves two things, subclassing gremlin and creating an instance of gremlin. Well three things you have to pack gremlin into a container.

Subclassing Gremlin

The gremlin subclass brings in gremlin and adds to the class. The jt_gremlin class does a couple of things the most important one is it redefines the report_gcode_error method with an addition to send the error string to the status bar. Before we can subclass gremlin we need to load it with import gremlin.

jt_gremlin class
class jt_gremlin(gremlin.Gremlin):
  def __init__(self, inifile):
    gremlin.Gremlin.__init__(self, inifile)

  def report_gcode_error(self, result, seq, filename):
    import gcode
    error_str = gcode.strerror(result)
    error = 'G-Code error in ' + os.path.basename(filename) + ' Near line ' + str(seq) + ' of ' + filename + ' ' + error_str
    jt_gui.update_statusbar(error)