当前位置: 首页>>代码示例>>Python>>正文


Python QSocketNotifier.deleteLater方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QSocketNotifier.deleteLater方法的典型用法代码示例。如果您正苦于以下问题:Python QSocketNotifier.deleteLater方法的具体用法?Python QSocketNotifier.deleteLater怎么用?Python QSocketNotifier.deleteLater使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QSocketNotifier的用法示例。


在下文中一共展示了QSocketNotifier.deleteLater方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt4.QtCore import QSocketNotifier [as 别名]
# 或者: from PyQt4.QtCore.QSocketNotifier import deleteLater [as 别名]
class _EventDispatcherQTFD:
    """Internal fdw wrapper used by EventDispatcherQT"""

    def __init__(self, fdw):
        self.fdw = fdw
        self.qsn_read = QSocketNotifier(int(self.fdw), QSocketNotifier.Read)
        self.qsn_write = QSocketNotifier(int(self.fdw), QSocketNotifier.Read)
        self.qsn_oob = QSocketNotifier(int(self.fdw), QSocketNotifier.Exception)
        self.qsn_read.setEnabled(False)
        self.qsn_write.setEnabled(False)
        self.qsn_oob.setEnabled(False)
        connect(self.qsn_read, SIGNAL("activated(int)"), self.fd_read)
        connect(self.qsn_write, SIGNAL("activated(int)"), self.fd_write)

    def process_readability(self, fd):
        self.fdw.process_readability()

    def process_writability(self, fd):
        self.fdw.process_writability()

    def read_r(self):
        self.qsn_read.setEnabled(True)

    def write_r(self):
        self.qsn_write.setEnabled(True)

    def read_u(self):
        self.qsn_read.setEnabled(False)

    def write_u(self):
        self.qsn_write.setEnabled(False)

    def _unregister_all(self):
        for qsn in (self.qsn_read, self.qsn_write, self.qsn_oob):
            if qsn.isEnabled():
                qsn.setEnabled(False)

    def close(self):
        self._unregister_all()
        disconnect(self.qsn_read, SIGNAL("activated(int)"), self.fd_read)
        disconnect(self.qsn_write, SIGNAL("activated(int)"), self.fd_write)
        disconnect(self.qsn_oob, SIGNAL("activated(int)"), self.fd_oob)
        self.qsn_read.deleteLater()
        self.qsn_write.deleteLater()
        self.qsn_oob.deleteLater()
        self.qsn_read = None
        self.qsn_write = None
        self.qsn_oob = None
开发者ID:sh01,项目名称:gonium,代码行数:50,代码来源:__qt4.py

示例2: TwistedSocketNotifier

# 需要导入模块: from PyQt4.QtCore import QSocketNotifier [as 别名]
# 或者: from PyQt4.QtCore.QSocketNotifier import deleteLater [as 别名]
class TwistedSocketNotifier(QObject):
    """
    Connection between an fd event and reader/writer callbacks.
    """

    def __init__(self, parent, reactor, watcher, socketType):
        QObject.__init__(self, parent)
        self.reactor = reactor
        self.watcher = watcher
        fd = watcher.fileno()
        self.notifier = QSocketNotifier(fd, socketType, parent)
        self.notifier.setEnabled(True)
        if socketType == QSocketNotifier.Read:
            self.fn = self.read
        else:
            self.fn = self.write
        QObject.connect(self.notifier, SIGNAL("activated(int)"), self.fn)

    def shutdown(self):
        self.notifier.setEnabled(False)
        self.disconnect(self.notifier, SIGNAL("activated(int)"), self.fn)
        self.fn = self.watcher = None
        self.notifier.deleteLater()
        self.deleteLater()

    def read(self, fd):
        if not self.watcher:
            return
        w = self.watcher
        # doRead can cause self.shutdown to be called so keep a
        # reference to self.watcher

        def _read():
            # Don't call me again, until the data has been read
            self.notifier.setEnabled(False)
            why = None
            try:
                why = w.doRead()
                inRead = True
            except:
                inRead = False
                log.err()
                why = sys.exc_info()[1]
            if why:
                self.reactor._disconnectSelectable(w, why, inRead)
            elif self.watcher:
                # Re enable notification following sucessfull read
                self.notifier.setEnabled(True)
            self.reactor._iterate(fromqt=True)
        log.callWithLogger(w, _read)

    def write(self, sock):
        if not self.watcher:
            return
        w = self.watcher

        def _write():
            why = None
            self.notifier.setEnabled(False)

            try:
                why = w.doWrite()
            except:
                log.err()
                why = sys.exc_info()[1]
            if why:
                self.reactor._disconnectSelectable(w, why, False)
            elif self.watcher:
                self.notifier.setEnabled(True)
            self.reactor._iterate(fromqt=True)
        log.callWithLogger(w, _write)
开发者ID:cgc1983,项目名称:qtreactor,代码行数:73,代码来源:qt4reactor.py


注:本文中的PyQt4.QtCore.QSocketNotifier.deleteLater方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。