本文整理匯總了Python中hal_glib.GStat.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python GStat.connect方法的具體用法?Python GStat.connect怎麽用?Python GStat.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hal_glib.GStat
的用法示例。
在下文中一共展示了GStat.connect方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: HAL_Gremlin
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class HAL_Gremlin(gremlin.Gremlin, _EMC_ActionBase):
__gtype_name__ = "HAL_Gremlin"
__gproperties__ = {
'view' : ( gobject.TYPE_STRING, 'View type', 'Default view: p, x, y, y2, z, z2',
'p', gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'enable_dro' : ( gobject.TYPE_BOOLEAN, 'Enable DRO', 'Show DRO on graphics',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'metric_units' : ( gobject.TYPE_BOOLEAN, 'Use Metric Units', 'Show DRO in metric or imperial units',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_relative' : ( gobject.TYPE_BOOLEAN, 'Show Relative', 'Show DRO relative to active system or machine origin',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_commanded' : ( gobject.TYPE_BOOLEAN, 'Show Commanded', 'Show commanded or actual position',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_extents_option' : ( gobject.TYPE_BOOLEAN, 'Show Extents', 'Show machine extents',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_limits' : ( gobject.TYPE_BOOLEAN, 'Show limits', 'Show machine limits',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_live_plot' : ( gobject.TYPE_BOOLEAN, 'Show live plot', 'Show machine plot',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_velocity' : ( gobject.TYPE_BOOLEAN, 'Show tool speed', 'Show tool velocity',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_program' : ( gobject.TYPE_BOOLEAN, 'Show program', 'Show program',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_rapids' : ( gobject.TYPE_BOOLEAN, 'Show rapids', 'Show rapid moves',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_tool' : ( gobject.TYPE_BOOLEAN, 'Show tool', 'Show tool',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_dtg' : ( gobject.TYPE_BOOLEAN, 'Show DTG', 'Show Distance To Go',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_lathe_radius' : ( gobject.TYPE_BOOLEAN, 'Show Lathe Radius', 'Show X axis in Radius',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'grid_size' : ( gobject.TYPE_FLOAT, 'Grid Size', 'Grid Size',
0, 100, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_joints_mode' : ( gobject.TYPE_BOOLEAN, 'Use joints mode', 'Use joints mode',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_default_controls' : ( gobject.TYPE_BOOLEAN, 'Use Default Mouse Controls', 'Use Default Mouse Controls',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
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', self.fileloaded)
self.show()
def fileloaded(self,w,f):
try:
self._load(f)
except AttributeError,detail:
#AttributeError: 'NoneType' object has no attribute 'gl_end'
print 'hal_gremlin: continuing after',detail
示例2: EMC_MDIHistory
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class EMC_MDIHistory(gtk.VBox, _EMC_ActionBase):
__gtype_name__ = 'EMC_MDIHistory'
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)
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() 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 reload(self):
self.model.clear()
try:
fp = open(self.filename)
except:
return
lines = map(str.strip, fp.readlines())
fp.close()
lines = filter(bool, lines)
for l in lines:
self.model.append((l,))
path = (len(lines)-1,)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
def submit(self, *a):
cmd = self.entry.get_text()
if not cmd:
return
ensure_mode(self.stat, self.linuxcnc, linuxcnc.MODE_MDI)
try:
fp = open(self.filename, 'a')
fp.write(cmd + "\n")
fp.close()
except:
pass
self.linuxcnc.mdi(cmd)
last = self.model.append((cmd,))
path = self.model.get_path(last)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
self.entry.grab_focus()
def select(self, w):
idx = w.get_cursor()[0]
if idx is None:
return
self.entry.set_text(self.model[idx][0])
示例3: HAL_Gremlin
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class HAL_Gremlin(gremlin.Gremlin, _EMC_ActionBase):
__gtype_name__ = "HAL_Gremlin"
__gsignals__ = {
'line-clicked': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
'gcode_error': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)),
}
__gproperties__ = {
'view' : ( gobject.TYPE_STRING, 'View type', 'Default view: p, x, y, y2, z, z2',
'p', gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'enable_dro' : ( gobject.TYPE_BOOLEAN, 'Enable DRO', 'Show DRO on graphics',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'metric_units' : ( gobject.TYPE_BOOLEAN, 'Use Metric Units', 'Show DRO in metric or imperial units',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_relative' : ( gobject.TYPE_BOOLEAN, 'Show Relative', 'Show DRO relative to active system or machine origin',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_commanded' : ( gobject.TYPE_BOOLEAN, 'Show Commanded', 'Show commanded or actual position',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_extents_option' : ( gobject.TYPE_BOOLEAN, 'Show Extents', 'Show machine extents',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_limits' : ( gobject.TYPE_BOOLEAN, 'Show limits', 'Show machine limits',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_live_plot' : ( gobject.TYPE_BOOLEAN, 'Show live plot', 'Show machine plot',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_velocity' : ( gobject.TYPE_BOOLEAN, 'Show tool speed', 'Show tool velocity',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_program' : ( gobject.TYPE_BOOLEAN, 'Show program', 'Show program',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_rapids' : ( gobject.TYPE_BOOLEAN, 'Show rapids', 'Show rapid moves',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_tool' : ( gobject.TYPE_BOOLEAN, 'Show tool', 'Show tool',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_dtg' : ( gobject.TYPE_BOOLEAN, 'Show DTG', 'Show Distance To Go',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_lathe_radius' : ( gobject.TYPE_BOOLEAN, 'Show Lathe Radius', 'Show X axis in Radius',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'grid_size' : ( gobject.TYPE_FLOAT, 'Grid Size', 'Grid Size',
0, 100, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_joints_mode' : ( gobject.TYPE_BOOLEAN, 'Use joints mode', 'Use joints mode',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_default_controls' : ( gobject.TYPE_BOOLEAN, 'Use Default Mouse Controls', 'Use Default Mouse Controls',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'mouse_btn_mode' : ( gobject.TYPE_INT, 'Mouse Button Mode',
('Mousebutton assignment, l means left, m middle, r right \n'
'0 = default: l-rotate, m-move, r-zoom \n'
'1 = l-zoom, m-move, r-rotate\n'
'2 = l-move, m-rotate, r-zoom\n'
'3 = l-zoom, m-rotate, r-move\n'
'4 = l-move, m-zoom, r-rotate\n'
'5 = l-rotate, m-zoom, r-move\n'
'6 = l-move, m-zoom, r-zoom'),
0, 6, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
def __init__(self, *a, **kw):
gobject.GObject.__init__(self)
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 reloadfile(self,w):
try:
self.fileloaded(None,self._reload_filename)
except:
pass
def fileloaded(self,w,f):
self._reload_filename=f
try:
self._load(f)
except AttributeError,detail:
#AttributeError: 'NoneType' object has no attribute 'gl_end'
print 'hal_gremlin: continuing after',detail
示例4: EMC_MDIHistory
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class EMC_MDIHistory(gtk.VBox, _EMC_ActionBase):
__gtype_name__ = 'EMC_MDIHistory'
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.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()))
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 reload(self):
self.model.clear()
try:
fp = open(self.filename)
except:
return
lines = map(str.strip, fp.readlines())
fp.close()
lines = filter(bool, lines)
for l in lines:
self.model.append((l,))
path = (len(lines)-1,)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
def submit(self, *a):
cmd = self.entry.get_text()
if cmd == 'HALMETER':
self.load_halmeter()
return
elif cmd == 'STATUS':
self.load_status()
return
elif cmd == 'HALSHOW':
self.load_halshow()
return
if not cmd:
return
ensure_mode(self.stat, self.linuxcnc, linuxcnc.MODE_MDI)
try:
fp = open(self.filename, 'a')
fp.write(cmd + "\n")
fp.close()
except:
pass
self.linuxcnc.mdi(cmd)
last = self.model.append((cmd,))
path = self.model.get_path(last)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
self.entry.grab_focus()
#.........這裏部分代碼省略.........
示例5: Combi_DRO
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
#.........這裏部分代碼省略.........
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)
# make an pango attribute to be used with several labels
def _set_attributes(self, bgcolor, fgcolor, size, weight):
attr = pango.AttrList()
bg_color = pango.AttrBackground(bgcolor[0], bgcolor[1], bgcolor[2], 0, -1)
示例6: HAL_Gremlin
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class HAL_Gremlin(gremlin.Gremlin, _EMC_ActionBase):
__gtype_name__ = "HAL_Gremlin"
__gproperties__ = {
'view' : ( gobject.TYPE_STRING, 'View type', 'Default view: p, x, y, y2, z, z2',
'p', gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'enable_dro' : ( gobject.TYPE_BOOLEAN, 'Enable DRO', 'Show DRO on graphics',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'metric_units' : ( gobject.TYPE_BOOLEAN, 'Use Metric Units', 'Show DRO in metric or imperial units',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_relative' : ( gobject.TYPE_BOOLEAN, 'Show Relative', 'Show DRO relative to active system or machine origin',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_commanded' : ( gobject.TYPE_BOOLEAN, 'Show Commanded', 'Show commanded or actual position',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_extents_option' : ( gobject.TYPE_BOOLEAN, 'Show Extents', 'Show machine extents',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_limits' : ( gobject.TYPE_BOOLEAN, 'Show limits', 'Show machine limits',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_live_plot' : ( gobject.TYPE_BOOLEAN, 'Show live plot', 'Show machine plot',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_velocity' : ( gobject.TYPE_BOOLEAN, 'Show tool speed', 'Show tool velocity',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_program' : ( gobject.TYPE_BOOLEAN, 'Show program', 'Show program',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_rapids' : ( gobject.TYPE_BOOLEAN, 'Show rapids', 'Show rapid moves',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_tool' : ( gobject.TYPE_BOOLEAN, 'Show tool', 'Show tool',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_dtg' : ( gobject.TYPE_BOOLEAN, 'Show DTG', 'Show Distance To Go',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_lathe_radius' : ( gobject.TYPE_BOOLEAN, 'Show Lathe Radius', 'Show X axis in Radius',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'grid_size' : ( gobject.TYPE_FLOAT, 'Grid Size', 'Grid Size',
0, 100, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_joints_mode' : ( gobject.TYPE_BOOLEAN, 'Use joints mode', 'Use joints mode',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_default_controls' : ( gobject.TYPE_BOOLEAN, 'Use Default Mouse Controls', 'Use Default Mouse Controls',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
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 do_get_property(self, property):
name = property.name.replace('-', '_')
if name == 'view':
return self.current_view
elif name in self.__gproperties.keys():
return getattr(self, name)
else:
raise AttributeError('unknown property %s' % property.name)
def do_set_property(self, property, value):
name = property.name.replace('-', '_')
if name == 'view':
view = value.lower()
if self.lathe_option:
if view not in ['p','y','y2']:
return False
elif view not in ['p', 'x', 'y', 'z', 'z2']:
return False
self.current_view = view
if self.initialised:
self.set_current_view()
elif name == 'enable_dro':
self.enable_dro = value
elif name == 'metric_units':
self.metric_units = value
elif name in self.__gproperties.keys():
setattr(self, name, value)
else:
raise AttributeError('unknown property %s' % property.name)
self.queue_draw()
return True
# This overrides glcannon.py method so we can change the DRO
def dro_format(self,s,spd,dtg,limit,homed,positions,axisdtg,g5x_offset,g92_offset,tlo_offset):
if not self.enable_dro:
return limit, homed, [''], ['']
if self.metric_units:
format = "% 6s:% 9.3f"
if self.show_dtg:
droformat = " " + format + " DTG %1s:% 9.3f"
else:
droformat = " " + format
offsetformat = "% 5s %1s:% 9.3f G92 %1s:% 9.3f"
rotformat = "% 5s %1s:% 9.3f"
else:
format = "% 6s:% 9.4f"
if self.show_dtg:
droformat = " " + format + " DTG %1s:% 9.4f"
#.........這裏部分代碼省略.........
示例7: HAL_Gremlin
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class HAL_Gremlin(gremlin.Gremlin, _EMC_ActionBase):
__gtype_name__ = "HAL_Gremlin"
__gproperties__ = {
'view' : ( gobject.TYPE_STRING, 'View type', 'Default view: x, y, z, p',
'p', gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'enable_dro' : ( gobject.TYPE_BOOLEAN, 'Enable DRO', 'Show DRO on graphics',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'metric_units' : ( gobject.TYPE_BOOLEAN, 'Use Metric Units', 'Show DRO in metric or imperial units',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_relative' : ( gobject.TYPE_BOOLEAN, 'Show Relative', 'Show DRO relative to active system or machine origin',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_commanded' : ( gobject.TYPE_BOOLEAN, 'Show Commanded', 'Show commanded or actual position',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_extents_option' : ( gobject.TYPE_BOOLEAN, 'Show Extents', 'Show machine extents',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_limits' : ( gobject.TYPE_BOOLEAN, 'Show limits', 'Show machine limits',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_live_plot' : ( gobject.TYPE_BOOLEAN, 'Show live plot', 'Show machine plot',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_velocity' : ( gobject.TYPE_BOOLEAN, 'Show tool speed', 'Show tool velocity',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_program' : ( gobject.TYPE_BOOLEAN, 'Show program', 'Show program',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_rapids' : ( gobject.TYPE_BOOLEAN, 'Show rapids', 'Show rapid moves',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_tool' : ( gobject.TYPE_BOOLEAN, 'Show tool', 'Show tool',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'show_dtg' : ( gobject.TYPE_BOOLEAN, 'Show DTG', 'Show Distance To Go',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'grid_size' : ( gobject.TYPE_FLOAT, 'Grid Size', 'Grid Size',
0, 100, 0, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_joints_mode' : ( gobject.TYPE_BOOLEAN, 'Use joints mode', 'Use joints mode',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_default_controls' : ( gobject.TYPE_BOOLEAN, 'Use Default Mouse Controls', 'Use Default Mouse Controls',
True, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
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 do_get_property(self, property):
name = property.name.replace('-', '_')
if name == 'view':
return self.current_view
elif name in self.__gproperties.keys():
return getattr(self, name)
else:
raise AttributeError('unknown property %s' % property.name)
def do_set_property(self, property, value):
name = property.name.replace('-', '_')
if name == 'view':
view = value.lower()
if self.lathe_option and view not in ['p','y']:
return False
if view not in ['x', 'y', 'z', 'p']:
return False
self.current_view = view
if self.initialised:
self.set_current_view()
elif name == 'enable_dro':
self.enable_dro = value
elif name == 'metric_units':
self.metric_units = value
elif name in self.__gproperties.keys():
setattr(self, name, value)
else:
raise AttributeError('unknown property %s' % property.name)
self.queue_draw()
return True
def posstrs(self):
l, h, p, d = gremlin.Gremlin.posstrs(self)
if self.enable_dro:
return l, h, p, d
return l, h, [''], ['']
def realize(self, widget):
gremlin.Gremlin.realize(self, widget)
@rs274.glcanon.with_context
def _load(self, filename):
return self.load(filename)
示例8: EMC_MDIHistory
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class EMC_MDIHistory(gtk.VBox, _EMC_ActionBase):
'''
EMC_MDIHistory will store each MDI command to a file on your hard drive
and display the grabbed commands in a treeview so they can be used again
without typing the complete comand again
'''
__gtype_name__ = 'EMC_MDIHistory'
__gproperties__ = {
'font_size_tree' : (gobject.TYPE_INT, 'Font Size', 'The font size of the tree view text',
8, 96, 10, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'font_size_entry' : (gobject.TYPE_INT, 'Font Size', 'The font size of the entry text',
8, 96, 10, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
'use_double_click' : (gobject.TYPE_BOOLEAN, 'Enable submit a command using a double click', 'A double click on an entry will submit the selected command directly\nIt is not recommended to use this on real machines',
False, gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT),
}
__gproperties = __gproperties__
__gsignals__ = {
'exit': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()),
}
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.SELECTION_NONE)
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.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)
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 reload(self):
self.model.clear()
try:
fp = open(self.filename)
except:
return
lines = map(str.strip, fp.readlines())
fp.close()
lines = filter(bool, lines)
for l in lines:
self.model.append((l,))
path = (len(lines)-1,)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
def submit(self, *a):
cmd = self.entry.get_text()
if cmd == 'HALMETER' or cmd == 'halmeter':
#.........這裏部分代碼省略.........
示例9: MacroSelect
# 需要導入模塊: from hal_glib import GStat [as 別名]
# 或者: from hal_glib.GStat import connect [as 別名]
class MacroSelect(gtk.VBox, _EMC_ActionBase):
__gtype_name__ = 'MacroSelect'
__gsignals__ = {
'macro-submitted': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,gobject.TYPE_STRING,)),
}
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 reload(self):
self.model.clear()
files = []
try:
for f in os.listdir(self.foldername):
if f.endswith('.ngc'):
with open(os.path.join(self.foldername, f), 'r') as temp:
first_line = temp.readline().strip()
print first_line
if 'MACROCOMMAND' in first_line:
files.append(first_line.strip('; MACROCOMMAND='))
except:
pass
lines = filter(bool, files)
for l in lines:
self.model.append((l,))
path = (len(lines)-1,)
self.tv.scroll_to_cell(path)
self.tv.set_cursor(path)
self.entry.set_text('')
def submit(self, *a):
cmd = self.entry.get_text()
if cmd == 'HALMETER':
self.load_halmeter()
return
elif cmd == 'STATUS':
self.load_status()
return
elif cmd == 'HALSHOW':
self.load_halshow()
return
if not cmd:
return
#ensure_mode(self.stat, self.linuxcnc, linuxcnc.MODE_MDI)
name = cmd.split()
path = self.foldername+ "/" + name[0] + ".ngc"
#.........這裏部分代碼省略.........