def __init__(self, *a, **kw): inifile = os.environ.get('INI_FILE_NAME', '/dev/null') inifile = linuxcnc.ini(inifile) gremlin.Gremlin.__init__(self, inifile) self.gstat = GStat() self.gstat.connect('file-loaded', lambda w, f: self._load(f)) self.show()
def __init__(self, *a, **kw): inifile = os.environ.get('INI_FILE_NAME', '/dev/null') inifile = linuxcnc.ini(inifile) gremlin.Gremlin.__init__(self, inifile) self._reload_filename = None self.gstat = GStat() self.gstat.connect('file-loaded', self.fileloaded) self.gstat.connect('reload-display', self.reloadfile) self.show()
def __init__(self, *a, **kw): Gtk.VBox.__init__(self, *a, **kw) self.use_double_click = False self.gstat = GStat() # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) self.no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.filename = os.path.expanduser(path) self.model = Gtk.ListStore(str) self.tv = Gtk.TreeView() self.default_font = self.tv.get_style().font_desc.to_string() self.tv.modify_font(Pango.FontDescription(self.default_font)) self.tv.set_model(self.model) self.cell = Gtk.CellRendererText() self.col = Gtk.TreeViewColumn("Command") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) self.tv.get_selection().set_mode(Gtk.SelectionMode.NONE) scroll = Gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = Gtk.PolicyType.AUTOMATIC scroll.props.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC self.entry = Gtk.Entry() print("Icon from stock") self.entry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, "gtk-ok") self.entry.modify_font(Pango.FontDescription(self.default_font)) self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.tv.connect('key_press_event', self.on_key_press_event) self.connect('key_press_event', self.on_key_press_event) self.tv.connect('button_press_event', self.on_button_press_event) self.pack_start(scroll, True, True, 0) self.pack_start(self.entry, False, False, 0) self.gstat.connect('state-off', lambda w: self.set_sensitive(False)) self.gstat.connect('state-estop', lambda w: self.set_sensitive(False)) self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on())) self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode())) self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on())) # this time lambda with two parameters, as not all homed will send also the unhomed joints self.gstat.connect('not-all-homed', lambda w,uj: self.set_sensitive(self.no_home_required) ) self.reload() self.show_all()
def __init__(self, *a, **kw): gtk.VBox.__init__(self, *a, **kw) self.gstat = GStat() # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) self.no_home_required = int( self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.filename = os.path.expanduser(path) self.model = gtk.ListStore(str) self.tv = gtk.TreeView() self.tv.set_model(self.model) self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn("Command") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) scroll = gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC self.entry = gtk.Entry() self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok') self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.pack_start(scroll, True) self.pack_start(self.entry, False) self.gstat.connect('state-off', lambda w: self.set_sensitive(False)) self.gstat.connect('state-estop', lambda w: self.set_sensitive(False)) self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on())) self.gstat.connect( 'interp-run', lambda w: self.set_sensitive(not self.is_auto_mode())) self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on())) # this time lambda with two parameters, as not all homed will send also the unhomed joints self.gstat.connect( 'not-all-homed', lambda w, uj: self.set_sensitive(self.no_home_required)) self.reload() self.show_all()
def __init__(self, *a, **kw): gtk.VBox.__init__(self, *a, **kw) self.gstat = GStat() # if 'NO_FORCE_HOMING' is true, MDI commands are allowed before homing. try: inifile = os.environ.get('INI_FILE_NAME', '/dev/null') self.ini = linuxcnc.ini(inifile) no_home_required = int(self.ini.find("TRAJ", "NO_FORCE_HOMING") or 0) macros = self.inifile.findall("MACROS", "MACRO") sub_path = self.inifile.find("RS274NGC", "SUBROUTINE_PATH")or '~/linuxcnc/nc_files/macros' except: no_home_required = 1 macros = None sub_path = '~/linuxcnc/nc_files/macros' #path = self.ini.find('DISPLAY', 'MDI_HISTORY_FILE') or '~/.axis_mdi_history' self.foldername = os.path.expanduser(sub_path) self.model = gtk.ListStore(str) self.tv = gtk.TreeView() self.tv.set_model(self.model) self.cell = gtk.CellRendererText() self.col = gtk.TreeViewColumn("Macro Commands") self.col.pack_start(self.cell, True) self.col.add_attribute(self.cell, 'text', 0) self.tv.append_column(self.col) self.tv.set_search_column(0) self.tv.set_reorderable(False) self.tv.set_headers_visible(True) scroll = gtk.ScrolledWindow() scroll.add(self.tv) scroll.props.hscrollbar_policy = gtk.POLICY_AUTOMATIC scroll.props.vscrollbar_policy = gtk.POLICY_AUTOMATIC self.entry = gtk.Entry() self.entry.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, 'gtk-ok') self.entry.connect('activate', self.submit) self.entry.connect('icon-press', self.submit) self.tv.connect('cursor-changed', self.select) self.tv.connect('key_press_event', self.on_key_press_event) self.tv.connect('button_press_event', self.on_button_press_event) self.pack_start(scroll, True) self.pack_start(self.entry, False) self.gstat.connect('state-off', lambda w: self.set_sensitive(False)) self.gstat.connect('state-estop', lambda w: self.set_sensitive(False)) self.gstat.connect('interp-idle', lambda w: self.set_sensitive(self.machine_on() and ( self.is_all_homed() or no_home_required ) )) self.gstat.connect('interp-run', lambda w: self.set_sensitive(not self.is_auto_mode())) self.gstat.connect('all-homed', lambda w: self.set_sensitive(self.machine_on())) self.reload() self.show_all()
def __init__(self, *a, **kw): gobject.GObject.__init__(self) ini_filename = os.environ.get('INI_FILE_NAME') if ini_filename is None: ini_filename = get_linuxcnc_ini_file() if ini_filename is not None: os.putenv('INI_FILE_NAME', ini_filename) os.environ['INI_FILE_NAME'] = ini_filename os.chdir(os.path.dirname(ini_filename)) inifile = linuxcnc.ini(ini_filename) gremlin.Gremlin.__init__(self, inifile) self._reload_filename = None self.gstat = GStat() self.gstat.connect('file-loaded', self.fileloaded) self.gstat.connect('reload-display', self.reloadfile) self.init_glcanondraw( trajcoordinates=self.inifile.find('TRAJ', 'COORDINATES'), kinsmodule=self.inifile.find('KINS', 'KINEMATICS')) self.show()
def __init__(self, filename=None, *a, **kw): super(OffsetPage, self).__init__() self.gstat = GStat() self.filename = filename self.linuxcnc = linuxcnc self.status = linuxcnc.stat() self.cmd = linuxcnc.command() self.hash_check = None self.display_units_mm = 0 # imperial self.machine_units_mm = 0 # imperial self.program_units = 0 # imperial self.display_follows_program = False # display units are chosen indepenadently of G20/G21 self.font = "sans 12" self.editing_mode = False self.highlight_color = gtk.gdk.Color("lightblue") self.foreground_color = gtk.gdk.Color("red") self.unselectable_color = gtk.gdk.Color("lightgray") self.hidejointslist = [] self.hidecollist = [] self.wTree = gtk.Builder() self.wTree.set_translation_domain( "linuxcnc") # for locale translations self.wTree.add_from_file(os.path.join(datadir, "offsetpage.glade")) self.current_system = None self.selection_mask = () self.axisletters = ["x", "y", "z", "a", "b", "c", "u", "v", "w"] # global references self.store = self.wTree.get_object("liststore2") self.all_window = self.wTree.get_object("all_window") self.view2 = self.wTree.get_object("treeview2") self.view2.connect('button_press_event', self.on_treeview2_button_press_event) self.selection = self.view2.get_selection() self.selection.set_mode(gtk.SELECTION_SINGLE) self.selection.connect("changed", self.on_selection_changed) self.modelfilter = self.wTree.get_object("modelfilter") self.edit_button = self.wTree.get_object("edit_button") self.edit_button.connect('toggled', self.set_editing) zero_g92_button = self.wTree.get_object("zero_g92_button") zero_g92_button.connect('clicked', self.zero_g92) zero_rot_button = self.wTree.get_object("zero_rot_button") zero_rot_button.connect('clicked', self.zero_rot) self.set_font(self.font) self.modelfilter.set_visible_column(10) self.buttonbox = self.wTree.get_object("buttonbox") for col, name in enumerate(AXISLIST): if col > 9: break temp = self.wTree.get_object("cell_%s" % name) temp.connect('edited', self.col_editted, col) temp = self.wTree.get_object("cell_name") temp.connect('edited', self.col_editted, 10) # reparent offsetpage box from Glades top level window to widgets VBox window = self.wTree.get_object("offsetpage_box") window.reparent(self) # check the ini file if UNITS are set to mm # first check the global settings # if not available then the X axis units try: self.inifile = self.linuxcnc.ini(INIPATH) units = self.inifile.find("TRAJ", "LINEAR_UNITS") if units == None: units = self.inifile.find("AXIS_X", "UNITS") except: print "**** Offsetpage widget ERROR: LINEAR_UNITS not found in INI's TRAJ section" units = "inch" # now setup the conversion array depending on the machine native units if units == "mm" or units == "metric" or units == "1.0": self.machine_units_mm = 1 self.conversion = [1.0 / 25.4] * 3 + [1] * 3 + [1.0 / 25.4] * 3 else: self.machine_units_mm = 0 self.conversion = [25.4] * 3 + [1] * 3 + [25.4] * 3 # check linuxcnc status every half second gobject.timeout_add(500, self.periodic_check)
def __init__(self, joint_number = 0): super(Combi_DRO, self).__init__() # get the necessary connections to linuxcnc self.joint_number = self.joint = joint_number self.linuxcnc = linuxcnc self.status = linuxcnc.stat() self.gstat = GStat() self.get_ini_info = getiniinfo.GetIniInfo() # set some default values' self._ORDER = ["Rel", "Abs", "DTG"] self.system = "Rel" self.homed = False self.homed_color = gtk.gdk.Color("green") self.unhomed_color = gtk.gdk.Color("red") self.abs_color = gtk.gdk.Color("blue") self.rel_color = gtk.gdk.Color("black") self.dtg_color = gtk.gdk.Color("yellow") self.mm_text_template = "%10.3f" self.imperial_text_template = "%9.4f" self.font_size = 25 self.metric_units = True self.machine_units = _MM self.unit_convert = 1 self._auto_units = True self.toggle_readout = True self.cycle_time = 150 # Make the GUI and connect signals self.eventbox = gtk.EventBox() self.eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black")) self.add(self.eventbox) vbox_main = gtk.VBox(False, 0) self.eventbox.add(vbox_main) hbox_up = gtk.HBox(False, 0) vbox_main.pack_start(hbox_up) attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (self.font_size * 1000, 0, -1), (600, 0, -1)) self.lbl_axisletter = gtk.Label(_AXISLETTERS[self.joint_number]) self.lbl_axisletter.set_attributes(attr) hbox_up.pack_start(self.lbl_axisletter, False, False) vbox_ref_type = gtk.VBox(False, 0) hbox_up.pack_start(vbox_ref_type, False, False) lbl_space = gtk.Label("") vbox_ref_type.pack_start(lbl_space) attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (int(self.font_size * 1000 / 2.5), 0, -1), (600, 0, -1)) self.lbl_sys_main = gtk.Label(self.system) vbox_ref_type.pack_start(self.lbl_sys_main, False, False) self.lbl_sys_main.set_attributes(attr) self.main_dro = gtk.Label("9999.999") hbox_up.pack_start(self.main_dro) self.main_dro.set_alignment(1.0, 0.5) attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (self.font_size, 0, -1), (600, 0, -1)) self.main_dro.set_attributes(attr) hbox_down = gtk.HBox(False, 5) vbox_main.pack_start(hbox_down) self.lbl_sys_left = gtk.Label("Abs") hbox_down.pack_start(self.lbl_sys_left) attr = self._set_attributes((0, 0, 0), (65535, 0, 0), (int(self.font_size * 1000 / 2.5), 0, -1), (600, 0, -1)) self.lbl_sys_left.set_attributes(attr) self.dro_left = gtk.Label("-11.111") hbox_down.pack_start(self.dro_left) self.dro_left.set_alignment(1.0, 0.5) self.dro_left.set_attributes(attr) self.lbl_sys_right = gtk.Label("DTG") hbox_down.pack_start(self.lbl_sys_right) self.lbl_sys_right.set_attributes(attr) self.dro_right = gtk.Label("22.222") hbox_down.pack_start(self.dro_right) self.dro_right.set_alignment(1.0, 0.5) self.dro_right.set_attributes(attr) self.eventbox.connect("button_press_event", self._on_eventbox_clicked) self.show_all() self.gstat.connect('not-all-homed', self._not_all_homed ) self.gstat.connect('all-homed', self._all_homed ) self.gstat.connect('homed', self._homed ) # This try is only needed because while working with glade # linuxcnc may not be working try: self.inifile = self.linuxcnc.ini(INIPATH) # check the ini file if UNITS are set to mm" # first check the global settings units = self.inifile.find("TRAJ", "LINEAR_UNITS") if units == None: # else then the X axis units units = self.inifile.find("AXIS_0", "UNITS") except: units = "inch" if units == "mm" or units == "metric" or units == "1.0": self.machine_units = _MM else: self.machine_units = _INCH # add the timer at a period of 100 ms gobject.timeout_add(self.cycle_time, self._periodic)
def get(self): if not self.linuxcnc: self.linuxcnc = linuxcnc.command() if not self.gstat: self.gstat = GStat() return self.linuxcnc, self.gstat.stat, self.gstat
# the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. import gobject import gtk import hal from hal_widgets import _HalWidgetBase from hal_glib import GStat GSTAT = GStat() class State_Label(gtk.Label, _HalWidgetBase): __gtype_name__ = "State_Label" __gproperties__ = { 'label_type': (gobject.TYPE_INT, 'Label type', '0:metric mode 1:Diameter mode 2:CSS Mode', 0, 2, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT), 'true_text': (gobject.TYPE_STRING, 'True Text', 'Text to display when state is True', "True", gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT), 'false_text': (gobject.TYPE_STRING, 'False Text', 'Text to display when state is False', "False", gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT), }
def __init__(self, joint_number=0): super(Combi_DRO, self).__init__() # we have to distinguish this, as we use the joints number to check homing # and we do need the axis to check for the positions # this is needed if non trivial kinematics are used or just a lathe, # as the lathe has only two joints, but Z will be the third value in position feedback self.axis_no = self.joint_number = joint_number # get the necessary connections to linuxcnc self.linuxcnc = linuxcnc self.status = linuxcnc.stat() self.gstat = GStat() # set some default values' self._ORDER = ["Rel", "Abs", "DTG"] self.system = "Rel" self.homed = False self.homed_color = "#00FF00" self.unhomed_color = "#FF0000" self.abs_color = "#0000FF" self.rel_color = "#000000" self.dtg_color = "#FFFF00" self.mm_text_template = "%10.3f" self.imperial_text_template = "%9.4f" self.font_size = 25 self.metric_units = True self.machine_units = _MM self.unit_convert = 1 self._auto_units = True self.toggle_readout = True self.cycle_time = 150 self.diameter = False self.actual = True self.widgets = {} # will hold all our widgets we need to style # Make the GUI and connect signals self.css = Gtk.CssProvider() self.css_text = """ .background {background-color: #000000;} .labelcolor {color: #FF0000;} .size_big {font-size: 25px;font-weight: bold;} .size_small {font-size: 10px;font-weight: bold;} """ self.css = Gtk.CssProvider() self.css.load_from_data(bytes(self.css_text, 'utf-8')) eventbox = Gtk.EventBox() eventbox.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) eventbox.get_style_context().add_class('background') self.add(eventbox) vbox_main = Gtk.VBox(homogeneous=False, spacing=0) eventbox.add(vbox_main) hbox_up = Gtk.HBox(homogeneous=False, spacing=5) vbox_main.pack_start(hbox_up, True, True, 0) self.widgets["eventbox"] = eventbox lbl_axisletter = Gtk.Label(label=_AXISLETTERS[self.axis_no]) lbl_axisletter.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) lbl_axisletter.get_style_context().add_class('background') lbl_axisletter.get_style_context().add_class('labelcolor') lbl_axisletter.get_style_context().add_class('size_big') hbox_up.pack_start(lbl_axisletter, False, False, 0) self.widgets["lbl_axisletter"] = lbl_axisletter vbox_ref_type = Gtk.VBox(homogeneous=False, spacing=0) hbox_up.pack_start(vbox_ref_type, False, False, 0) # This label is needed to press the main index (rel,Abs;Dtg) to the upper part lbl_space = Gtk.Label(label="") vbox_ref_type.pack_start(lbl_space, True, True, 0) lbl_sys_main = Gtk.Label(label=self.system) lbl_sys_main.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) lbl_sys_main.get_style_context().add_class('background') lbl_sys_main.get_style_context().add_class('labelcolor') lbl_sys_main.get_style_context().add_class("size_small") vbox_ref_type.pack_start(lbl_sys_main, False, False, 0) self.widgets["lbl_sys_main"] = lbl_sys_main main_dro = Gtk.Label(label="9999.999") main_dro.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) main_dro.get_style_context().add_class('background') main_dro.get_style_context().add_class('labelcolor') main_dro.get_style_context().add_class("size_big") main_dro.set_xalign(1.0) hbox_up.pack_start(main_dro, True, True, 0) self.widgets["main_dro"] = main_dro hbox_down = Gtk.HBox(homogeneous=True, spacing=5) vbox_main.pack_start(hbox_down, False, False, 0) lbl_sys_left = Gtk.Label(label="Abs") lbl_sys_left.set_xalign(0.0) lbl_sys_left.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) lbl_sys_left.get_style_context().add_class('background') lbl_sys_left.get_style_context().add_class('labelcolor') lbl_sys_left.get_style_context().add_class('size_small') hbox_down.pack_start(lbl_sys_left, True, True, 0) self.widgets["lbl_sys_left"] = lbl_sys_left dro_left = Gtk.Label(label="-11.111") dro_left.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) dro_left.get_style_context().add_class('background') dro_left.get_style_context().add_class('labelcolor') dro_left.get_style_context().add_class('size_small') dro_left.set_xalign(1.0) hbox_down.pack_start(dro_left, True, True, 0) self.widgets["dro_left"] = dro_left lbl_sys_right = Gtk.Label(label="DTG") lbl_sys_right.set_xalign(0.0) lbl_sys_right.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) lbl_sys_right.get_style_context().add_class('background') lbl_sys_right.get_style_context().add_class('labelcolor') lbl_sys_right.get_style_context().add_class('size_small') hbox_down.pack_start(lbl_sys_right, False, False, 0) self.widgets["lbl_sys_right"] = lbl_sys_right dro_right = Gtk.Label(label="22.222") dro_right.get_style_context().add_provider( self.css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) dro_right.get_style_context().add_class('background') dro_right.get_style_context().add_class('labelcolor') dro_right.get_style_context().add_class('size_small') dro_right.set_xalign(1.0) hbox_down.pack_start(dro_right, True, True, 0) self.widgets["dro_right"] = dro_right eventbox.connect("button_press_event", self._on_eventbox_clicked) self.show_all() self.gstat.connect('not-all-homed', self._not_all_homed) self.gstat.connect('all-homed', self._all_homed) self.gstat.connect('homed', self._homed) self.gstat.connect('current-position', self._position) # This try is only needed because while working with glade # linuxcnc may not be working try: self.inifile = self.linuxcnc.ini(INIPATH) # check the ini file if UNITS are set to mm" # first check the global settings units = self.inifile.find("TRAJ", "LINEAR_UNITS") if units == None: # else then the X axis units units = self.inifile.find("AXIS_0", "UNITS") except: units = "inch" if units == "mm" or units == "metric" or units == "1.0": self.machine_units = _MM else: self.machine_units = _INCH