本文整理匯總了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