當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。