本文整理汇总了Python中qtpy.QtCore.Signal方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.Signal方法的具体用法?Python QtCore.Signal怎么用?Python QtCore.Signal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore
的用法示例。
在下文中一共展示了QtCore.Signal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getattr__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import Signal [as 别名]
def __getattr__(self, name):
"""Pass through attr requests to signals to simplify connection API.
The goal is to enable ``worker.signal.connect`` instead of
``worker.signals.yielded.connect``. Because multiple inheritance of Qt
classes is not well supported in PyQt, we have to use composition here
(signals are provided by QObjects, and QRunnable is not a QObject). So
this passthrough allows us to connect to signals on the ``_signals``
object.
"""
# the Signal object is actually a class attribute
attr = getattr(self._signals.__class__, name, None)
if isinstance(attr, Signal):
# but what we need to connect to is the instantiated signal
# (which is of type `SignalInstance` in PySide and
# `pyqtBoundSignal` in PyQt)
return getattr(self._signals, name)
示例2: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import Signal [as 别名]
def __init__(self, axis: str, signal_target_changed: QtCore.Signal):
""" A widget to change the tick properties
Args:
axis: whether to use the "x" or "y" axis
signal_target_changed: a signal to emit when the target changed
"""
QtWidgets.QWidget.__init__(self)
self.setWindowTitle("Figure - " + axis + "-Axis - Ticks - Pylustrator")
self.setWindowIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), "icons", "ticks.ico")))
self.layout = QtWidgets.QVBoxLayout(self)
self.axis = axis
self.label = QtWidgets.QLabel(
"Ticks can be specified, one tick pre line.\nOptionally a label can be provided, e.g. 1 \"First\",")
self.layout.addWidget(self.label)
self.layout2 = QtWidgets.QHBoxLayout()
self.layout.addLayout(self.layout2)
self.input_ticks = TextWidget(self.layout2, axis + "-Ticks:", multiline=True, horizontal=False)
self.input_ticks.editingFinished.connect(self.ticksChanged)
self.input_ticks2 = TextWidget(self.layout2, axis + "-Ticks (minor):", multiline=True, horizontal=False)
self.input_ticks2.editingFinished.connect(self.ticksChanged2)
self.input_scale = ComboWidget(self.layout, axis + "-Scale", ["linear", "log", "symlog", "logit"])
self.input_scale.link(axis + "scale", signal_target_changed)
self.input_font = TextPropertiesWidget(self.layout)
self.input_labelpad = NumberWidget(self.layout, axis + "-Labelpad", min=-999)
self.input_labelpad.link(axis + "axis.labelpad", signal_target_changed, direct=True)
self.button_ok = QtWidgets.QPushButton("Ok")
self.layout.addWidget(self.button_ok)
self.button_ok.clicked.connect(self.hide)
示例3: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import Signal [as 别名]
def __init__(self, sig_write):
"""Initialize object.
Args:
sig_write (Signal): signal to emit
"""
super(CaptureStdOutput, self).__init__()
self.sig_write = sig_write
示例4: _show_interpreter_prompt_for_reply
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import Signal [as 别名]
def _show_interpreter_prompt_for_reply(self, msg):
""" Shows a prompt for the interpreter given an 'execute_reply' message.
"""
self._show_interpreter_prompt()
#------ Signal handlers ----------------------------------------------------
示例5: test_QtCore_SignalInstance
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import Signal [as 别名]
def test_QtCore_SignalInstance():
class ClassWithSignal(QtCore.QObject):
signal = QtCore.Signal()
instance = ClassWithSignal()
assert isinstance(instance.signal, QtCore.SignalInstance)
示例6: link
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import Signal [as 别名]
def link(self, property_name: str, signal: QtCore.Signal = None, condition: callable = None, direct: bool = False):
self.element = None
self.direct = direct
if direct:
parts = property_name.split(".")
s = self
def get():
target = s.element
for part in parts:
target = getattr(target, part)
return target
def set(v):
get()
target = s.element
for part in parts[:-1]:
target = getattr(target, part)
setattr(target, parts[-1], v)
return [s.element]
self.setLinkedProperty = set
self.getLinkedProperty = get
self.serializeLinkedProperty = lambda x: "." + property_name + " = %s" % x
else:
def set(v):
elements = []
getattr(self.element, "set_" + property_name)(v)
elements.append(self.element)
for elm in self.element.figure.selection.targets:
elm = elm.target
if elm != self.element:
try:
getattr(elm, "set_" + property_name, None)(v)
except TypeError as err:
pass
else:
elements.append(elm)
return elements
self.setLinkedProperty = set # lambda text: getattr(self.element, "set_"+property_name)(text)
self.getLinkedProperty = lambda: getattr(self.element, "get_" + property_name)()
self.serializeLinkedProperty = lambda x: ".set_" + property_name + "(%s)" % x
if condition is None:
self.condition = lambda x: True
else:
self.condition = condition
self.editingFinished.connect(self.updateLink)
signal.connect(self.setTarget)