本文整理汇总了Python中gi.repository.GObject.signal_new方法的典型用法代码示例。如果您正苦于以下问题:Python GObject.signal_new方法的具体用法?Python GObject.signal_new怎么用?Python GObject.signal_new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GObject
的用法示例。
在下文中一共展示了GObject.signal_new方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _connect_stat_callback
# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import signal_new [as 别名]
def _connect_stat_callback(self, attribute, callback):
if hasattr(self.stat, attribute) \
or attribute.replace('_', '-') in self.signals:
if attribute.replace('_', '-') not in self.signals \
and attribute not in self.registry:
GObject.signal_new(attribute, self, GObject.SignalFlags.RUN_FIRST, None, (object,))
self.registry.append(attribute)
self.connect(attribute, callback)
# Cause update
if attribute in SIGNALS.keys():
self.old[SIGNALS[attribute]] = None
else:
self.old[attribute] = None
else:
log.error('linuxcnc.stat object has no attribute "{}"'.format(attribute))
示例2: __init__
# 需要导入模块: from gi.repository import GObject [as 别名]
# 或者: from gi.repository.GObject import signal_new [as 别名]
def __init__(self, stat=None):
GObject.GObject.__init__(self)
self.signals = GObject.signal_list_names(self)
self.stat = stat or linuxcnc.stat()
self.error = linuxcnc.error_channel()
self.report_actual_position = ini_info.get_position_feedback()
axes = ini_info.get_axis_list()
self.axis_list = ['xyzabcuvw'.index(axis) for axis in axes]
self.num_joints = ini_info.get_num_joints()
self.file = None
self.registry = []
self.old = {}
self.old['joint'] = getattr(self.stat, 'joint')
# Setup joint dict signals
self.joint_keys = self.old['joint'][0].keys() # keys() is slow, but we only use it on init
for key in self.joint_keys:
key = 'joint-{}'.format(key)
GObject.signal_new(key.replace('_', '-'), self, GObject.SignalFlags.RUN_FIRST, None, (int, object))
self.max_time = 0
self.counter = 0
# Connect internally used signal callbacks
self.on_changed('stat.gcodes', self._update_active_gcodes)
self.on_changed('stat.mcodes', self._update_active_mcodes)
self.on_changed('stat.file', self._update_file)
GLib.timeout_add(50, self._periodic)
# This allows monitoring any of the linuxcnc.stat attributes
# and connecting a callback to be called on attribute value change