本文整理汇总了Python中qtpy.QtCore.QObject方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QObject方法的具体用法?Python QtCore.QObject怎么用?Python QtCore.QObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore
的用法示例。
在下文中一共展示了QtCore.QObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getattr__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QObject [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 QObject [as 别名]
def __init__(
self,
func: Callable,
*args,
SignalsClass: Type[QObject] = GeneratorWorkerSignals,
**kwargs,
):
if not inspect.isgeneratorfunction(func):
raise TypeError(
f"Regular function {func} cannot be used with "
"GeneratorWorker, use FunctionWorker instead"
)
super().__init__(SignalsClass=SignalsClass)
self._gen = func(*args, **kwargs)
self._incoming_value = None
self._pause_requested = False
self._resume_requested = False
self._paused = False
# polling interval: ONLY relevant if the user paused a running worker
self._pause_interval = 0.01
示例3: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QObject [as 别名]
def __init__(self):
"""Constructor; also constructs ZMQ stream."""
super(QObject, self).__init__()
self.context = zmq.Context()
self.socket = self.context.socket(zmq.PAIR)
self.port = self.socket.bind_to_random_port('tcp://*')
fid = self.socket.getsockopt(zmq.FD)
self.notifier = QSocketNotifier(fid, QSocketNotifier.Read, self)
self.notifier.activated.connect(self.received_message)
示例4: superQ
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QObject [as 别名]
def superQ(QClass):
""" Permits the use of super() in class hierarchies that contain Qt classes.
Unlike QObject, SuperQObject does not accept a QObject parent. If it did,
super could not be emulated properly (all other classes in the heierarchy
would have to accept the parent argument--they don't, of course, because
they don't inherit QObject.)
This class is primarily useful for attaching signals to existing non-Qt
classes. See QtKernelManagerMixin for an example.
"""
class SuperQClass(QClass):
def __new__(cls, *args, **kw):
# We initialize QClass as early as possible. Without this, Qt complains
# if SuperQClass is not the first class in the super class list.
inst = QClass.__new__(cls)
QClass.__init__(inst)
return inst
def __init__(self, *args, **kw):
# Emulate super by calling the next method in the MRO, if there is one.
mro = self.__class__.mro()
for qt_class in QClass.mro():
mro.remove(qt_class)
next_index = mro.index(SuperQClass) + 1
if next_index < len(mro):
mro[next_index].__init__(self, *args, **kw)
return SuperQClass
示例5: test_QtCore_SignalInstance
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QObject [as 别名]
def test_QtCore_SignalInstance():
class ClassWithSignal(QtCore.QObject):
signal = QtCore.Signal()
instance = ClassWithSignal()
assert isinstance(instance.signal, QtCore.SignalInstance)
示例6: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QObject [as 别名]
def __init__(self):
"""
Initialize the handler
"""
logging.Handler.__init__(self)
QtCore.QObject.__init__(self)
# set format of logged messages
self.setFormatter(logging.Formatter('%(levelname)s (%(name)s): %(message)s'))
示例7: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QObject [as 别名]
def __init__(self):
"""Anaconda Client API wrapper."""
super(QObject, self).__init__()
self._anaconda_client_api = binstar_client.utils.get_server_api(
log_level=logging.NOTSET)
self._queue = deque()
self._threads = []
self._workers = []
self._timer = QTimer()
self._conda_api = CondaAPI()
self._timer.setInterval(1000)
self._timer.timeout.connect(self._clean)
示例8: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QObject [as 别名]
def __init__(self, load_rc_func=None):
"""Download API based on requests."""
super(QObject, self).__init__()
self._conda_api = CondaAPI()
self._queue = deque()
self._threads = []
self._workers = []
self._timer = QTimer()
self._load_rc_func = load_rc_func
self._chunk_size = 1024
self._timer.setInterval(1000)
self._timer.timeout.connect(self._clean)