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