def __init__(self, axis_letter, dro_type=DroType.REL): Gtk.EventBox.__init__(self) self.axis_letter = axis_letter self.axis_num = 'xyzabcuvw'.index(self.axis_letter.lower()) self.joint_num = self.coords.index(self.axis_letter.lower()) self.dro_type = dro_type # Don't let the EventBox hide the entry self.set_visible_window(False) # Make expand to fill space allocated space self.set_hexpand(True) self.set_vexpand(True) # Add the actual DRO display self.entry = Gtk.Entry() self.add(self.entry) self.set_editable(False) # Default to not editable self.entry.set_alignment(1) # Move text to far right self.entry.set_width_chars(7) # 6 digits and a decimal point (99.9999) # Add style class self.style_context = self.entry.get_style_context() self.style_context.add_class("DroEntry") # Could set font like this, but CSS better # font = Pango.FontDescription('16') # self.modify_font(font) self.in_decimal_places = prefs.get('DROs', 'IN_DEC_PLCS', 4, int) self.mm_decimal_places = prefs.get('DROs', 'MM_DEC_PLCS', 3, int) self.conversion_factor = self.conversion_list[self.axis_num] self.dec_plcs = self.in_decimal_places self.factor = 1 self.has_focus = False self.selected = False self.connect('button-press-event', self.on_eventbox_clicked) self.entry.connect('button-press-event', self.on_button_press) self.entry.connect('button-release-event', self.on_button_release) self.entry.connect('focus-in-event', self.on_focus_in) self.entry.connect('focus-out-event', self.on_focus_out) self.entry.connect('key-press-event', self.on_key_press) self.entry.connect('activate', self.on_activate) status.on_changed('stat.axis-positions', self._update_dro) status.on_changed('stat.program_units', self._update_units)
def __init__(self): super(MDIEntry, self).__init__() self.buffer = self.get_buffer() self.style_context = self.get_style_context() self.show_vkb = prefs.get('MDI_ENTRY', 'SHOW_VIRTUAL_KEYBOARD', 'YES', bool) self.set_placeholder_text('MDI') self.model = Gtk.ListStore(str) self.completion = Gtk.EntryCompletion() self.completion.set_model(self.model) self.completion.set_text_column(0) # Completion popup steals focus from the VKB, and visa-versa, so # until a solution is found don't enable both at the same time. if not self.show_vkb: self.set_completion(self.completion) self.scrolled_to_bottom = False self.load_from_history_file() self.connect('activate', self.on_entry_activated) self.connect('focus-in-event', self.on_entry_gets_focus) self.connect('focus-out-event', self.on_entry_loses_focus)
def jog_start(axis): JOGMODE = 0 dir = axis[0] vel = prefs.get("JOGGING", "VELOCITY", 1, float) axis_num = "xyzabcuvw".index(axis[1]) log.debug("green<STARTED> jogging {} axis".format(axis)) command.jog(linuxcnc.JOG_CONTINUOUS, JOGMODE, axis_num, float('{}{}'.format(dir, vel)))
def __init__(self, section, option, default_value=False): Gtk.Switch.__init__(self) self.section = section self.option = option self.default_value = default_value self.connect('state-set', self.on_state_set) self.state = prefs.get(self.section, self.option, self.default_value, bool) self.set_active(self.state)
def __init__(self, section, option, default_value=False): Gtk.CheckButton.__init__(self) self.section = section self.option = option self.default_value = default_value self.connect('toggled', self.on_toggle) self.state = prefs.get(self.section, self.option, self.default_value, bool) self.set_active(self.state)
def __init__(self, section, option, default_value=''): Gtk.Entry.__init__(self) self.section = section self.option = option self.default_value = default_value self.connect('focus-out-event', self.on_focus_out) self.connect('key-press-event', self.on_key_press) self.connect('activate', self.on_activate) self.value = prefs.get(self.section, self.option, self.default_value, str) self.set_text(str(self.value))
def __init__(self, section, option, items=[], default_item=None): Gtk.ComboBox.__init__(self) self.section = section self.option = option self.items = items self.default_item = default_item self.model = Gtk.ListStore(str) self.set_model(self.model) for item in self.items: self.model.append([item]) renderer_text = Gtk.CellRendererText() self.pack_start(renderer_text, True) self.add_attribute(renderer_text, "text", 0) self.item = prefs.get(self.section, self.option, self.default_item, str) self.set_selected(self.item) self.connect("changed", self.on_selection_changed)
def on_key_press_event(widget, event): keyname = Gdk.keyval_name(event.keyval) if not keyname in KEYBINDINGS: return False if is_pressed.get(keyname, False): return True if not prefs.get('JOGGING', 'USE_KEYBOARD', 'YES', bool): return False stat.poll() if stat.task_mode != linuxcnc.MODE_MANUAL \ or not stat.enabled \ or not is_homed(): return False is_pressed[keyname] = True jog_start(KEYBINDINGS[keyname]) is_pressed[keyname] = True return True