Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import linuxcnc
- import os
- import hal
- import hal_glib
- from gladevcp.persistence import IniFile,widget_defaults,set_debug,select_widgets
- class HandlerClass:
- def __init__(self, halcomp,builder,useropts):
- self.halcomp = halcomp
- self.builder = builder
- self.useropts = useropts
- self.defaults = {
- # the following names will be saved/restored as method attributes
- # the save/restore mechanism is strongly typed - the variables type will be derived from the type of the
- # initialization value. Currently supported types are: int, float, bool, string
- #IniFile.vars : { 'var1' : 1.11, 'var2' : 1.22, 'var3' : 0.333 },
- # Retains all HAL output widgets' state:
- IniFile.widgets: widget_defaults(select_widgets(self.builder.get_objects(), hal_only=True,output_only = True)),
- }
- self.ini_filename = __name__ + '.ini'
- self.ini = IniFile(self.ini_filename,self.defaults,self.builder)
- self.ini.restore_state(self)
- # Override startup defaults:
- #self.builder.get_object('hal_spinbutton1').set_value(self.Travel_Offset)
- self.builder.get_object('hal_led1').set_blink_rate(150) # Homing LED
- self.builder.get_object('hal_led7').set_blink_rate(300) # EStop LED
- self.builder.get_object('ForceTHCActiveCheckButton').set_active(False) # turn off debug states by default
- self.builder.get_object('ForceTorchOnCheckButton').set_active(False) # turn off debug states by default
- def vbox1_destroy_cb(self,obj,data=None):
- self.ini.save_state(self)
- def get_handlers(halcomp,builder,useropts):
- return [HandlerClass(halcomp,builder,useropts)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement