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


Python QtCore.QSocketNotifier类代码示例

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


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

示例1: _addNotifier

 def _addNotifier(self, descriptor, descmap, type):
     if descriptor not in descmap:
         fd = descriptor.fileno()
         if fd == -1:
             raise RuntimeError("Invalid file descriptor")
         notifier = QSocketNotifier(fd, type)
         descmap[descriptor] = notifier
         notifier._descriptor = descriptor
         self.connect(notifier, SIGNAL("activated(int)"), self._notifierSlot)
         notifier.setEnabled(True)
开发者ID:nnemkin,项目名称:deluge_qt,代码行数:10,代码来源:qt4reactor.py

示例2: __init__

 def __init__(self, reactor, watcher, type):
     QSocketNotifier.__init__(self, watcher.fileno(), type)
     self.reactor = reactor
     self.watcher = watcher
     self.fn = None
     if type == QSocketNotifier.Read:
         self.fn = self.read
     elif type == QSocketNotifier.Write:
         self.fn = self.write
     QObject.connect(self, SIGNAL("activated(int)"), self.fn)
开发者ID:AlickHill,项目名称:Lantern,代码行数:10,代码来源:qt4reactor.py

示例3: __init__

 def __init__(self, reactor, watcher, type):
     QSocketNotifier.__init__(self, watcher.fileno(), type)
     self.reactor = reactor
     self.watcher = watcher
     self.fn = None
     if type == QSocketNotifier.Read:
         self.fn = self.read
     elif type == QSocketNotifier.Write:
         self.fn = self.write
     self.activated[int].connect(self.fn)
开发者ID:Pesa,项目名称:forse,代码行数:10,代码来源:qt4reactor.py

示例4: __init__

 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)
开发者ID:sh01,项目名称:gonium,代码行数:10,代码来源:__qt4.py

示例5: Signal

class Signal(QObject):
    signal = pyqtSignal(int)
    fds = {}
    
    def __init__(self, signum, parent):
        super(Signal,self).__init__(parent)
        self.signum = signum
        self.sn = None
        self.fd = [None,None]
        if self.setupHandler() < 0:
            return

        self.sn = QSocketNotifier(self.fd[1].fileno(), QSocketNotifier.Read, parent)
        self.sn.activated.connect( self.handleSignal)

    def __del__(self):
        signal.signal( self.signum, signal.SIG_DFL)
        if Signal.fds.has_key( self.signum):
            Signal.fds.pop(self.signum)
        if self.fd[0] is not None:
            self.fd[0].close()
        if self.fd[1] is not None:
            self.fd[1].close()
        super(Signal,self).__del__()

    @staticmethod
    def create(signum,parent):
        if Signal.fds.has_key(signum):
            if Signal.fds[signum].sn:
                sip.delete(Signal.fds[signum].sn)
            del(Signal.fds[signum])
        return Signal(signum,parent)
    
    def handleSignal(self):
        self.sn.setEnabled(False)
        self.fd[1].recv(1)
        self.signal.emit(self.signum)
        self.sn.setEnabled(True)

    def setupHandler(self):
        self.fd = socket.socketpair(socket.AF_UNIX,socket.SOCK_STREAM,0)
        if not self.fd:
            return -1
        Signal.fds[self.signum] = self
        signal.signal(self.signum,self.handler)
        signal.siginterrupt(self.signum,False)
        return 0

    @staticmethod
    def handler(signum,frame):
        Signal.fds[signum].fd[0].send(chr(1))
开发者ID:jmechnich,项目名称:appletlib,代码行数:51,代码来源:posixsignal.py

示例6: connect

 def connect(self, address):
     """Connect to a JSON-RPC server at *address*."""
     if isinstance(address, socket.socket):
         sock = address
     else:
         sock = util.create_connection(address, self._timeout)
     sock.settimeout(0)
     self._read_notifier = QSocketNotifier(sock.fileno(), QSocketNotifier.Read, self)
     self._read_notifier.activated.connect(self._do_read)
     self._read_notifier.setEnabled(True)
     self._write_notifier = QSocketNotifier(sock.fileno(), QSocketNotifier.Write, self)
     self._write_notifier.activated.connect(self._do_write)
     self._write_notifier.setEnabled(False)
     self._socket = sock
开发者ID:geertj,项目名称:bluepass,代码行数:14,代码来源:qjsonrpc.py

示例7: run

    def run(self):
        botlog.info('RFIDReaderThread Running.')

        self.blinkPhase = False
        self.blinkTimer = QTimer()
        self.blinkTimer.timeout.connect(self.blink)        

        self.latchTimer = QTimer()
        self.latchTimer.timeout.connect(self.unlatch)
        self.latchTimer.setSingleShot(True)

        self.delayTimer = QTimer()
        self.delayTimer.timeout.connect(self.undelay)
        self.delayTimer.setSingleShot(True)
        
        self.notifier = QSocketNotifier(self.reader.fileno(), QSocketNotifier.Read)
        self.notifier.activated.connect(self.onData)
        
        self.blinkTimer.start(250)
        self.notifier.setEnabled(True)

        self.setStatus(Status.READY)
        self.exec()
        
        botlog.info('RFIDReaderThread Stopped.')
开发者ID:MomentumV,项目名称:doorbot,代码行数:25,代码来源:qdoor.py

示例8: __init__

class QtListener:
    def __init__(self, evtype, fileno, cb):
        self.evtype, self.fileno, self.cb = evtype, fileno, cb
        self.notifier = QSocketNotifier(fileno, self.eventType(evtype))
        self.notifier.activated.connect(cb)

    def __del__(self):
        self.notifier.setEnabled(False)
        self.notifier = None

    def eventType(self, evtype):
        assert evtype in (BaseHub.READ, BaseHub.WRITE)
        if evtype == BaseHub.READ:
            return QSocketNotifier.Read
        elif evtype == BaseHub.WRITE:
            return QSocketNotifier.Write
开发者ID:OSUser,项目名称:eventlet-pyqt,代码行数:16,代码来源:eventlet.py

示例9: register_io

    def register_io(self, fd, callback, mode, *args, **kwargs):
        handler = six.next(self._handlers)
        notifier = QSocketNotifier(self.fd_number(fd), self.constants[mode])
        with self._mutex:
            self._io_handlers[handler] = notifier

        def _io_cb(*_):
            if not self._safe_callback(callback, fd, *args, **kwargs):
                self.unregister_io(handler)

        with self._mutex:
            # we need to store the closure callback to avoid the garbage collector
            # from collecting the closure
            self._io_handlers[handler] = (notifier, _io_cb)

        notifier.setEnabled(True)
        notifier.activated.connect(_io_cb)
开发者ID:caetanus,项目名称:pygel,代码行数:17,代码来源:qt4_reactor.py

示例10: __init__

    def __init__(self, signum, parent):
        super(Signal,self).__init__(parent)
        self.signum = signum
        self.sn = None
        self.fd = [None,None]
        if self.setupHandler() < 0:
            return

        self.sn = QSocketNotifier(self.fd[1].fileno(), QSocketNotifier.Read, parent)
        self.sn.activated.connect( self.handleSignal)
开发者ID:jmechnich,项目名称:appletlib,代码行数:10,代码来源:posixsignal.py

示例11: __init__

 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)
开发者ID:cgc1983,项目名称:qtreactor,代码行数:12,代码来源:qt4reactor.py

示例12: _SH_ThreadStarted

 def _SH_ThreadStarted(self):
     self.started.emit()
     notification_center = NotificationCenter()
     notification_center.post_notification('VNCClientWillStart', sender=self)
     self.rfb_client = RFBClient(parent=self)
     try:
         self.rfb_client.connect()
     except RFBClientError:
         self.thread.quit()
     else:
         self.socket_notifier = QSocketNotifier(self.rfb_client.socket, QSocketNotifier.Read, self)
         self.socket_notifier.activated.connect(self._SH_SocketNotifierActivated)
         notification_center.post_notification('VNCClientDidStart', sender=self)
开发者ID:scudella,项目名称:blink-qt,代码行数:13,代码来源:vncclient.py

示例13: __init__

    def __init__(self):
        self.com = comar.Link()

        # Notification
        self.com.ask_notify("System.Upgrader.progress")
        self.com.ask_notify("System.Upgrader.error")
        self.com.ask_notify("System.Upgrader.warning")
        self.com.ask_notify("System.Upgrader.notify")
        self.com.ask_notify("System.Upgrader.started")
        self.com.ask_notify("System.Upgrader.finished")
        self.com.ask_notify("System.Upgrader.cancelled")

        self.notifier = QSocketNotifier(self.com.sock.fileno(), QSocketNotifier.Read)

        self.connect(self.notifier, SIGNAL("activated(int)"), self.slotComar)
开发者ID:Tayyib,项目名称:uludag,代码行数:15,代码来源:comariface.py

示例14: FdEvent

class FdEvent(Event):
    def __init__(self, *args, **kw):
        self.note = QSocketNotifier(*args, **kw)
        self.note.setEnabled(False)
        Event.__init__(self, self.note.activated)
    def arm(self, *args):
        Event.arm(self, *args)
        self.note.setEnabled(True)
    def close(self, *args):
        self.note.setEnabled(False)
        Event.close(self, *args)
开发者ID:vadmium,项目名称:webvi-qt,代码行数:11,代码来源:qtwrap.py

示例15: TwistedSocketNotifier

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,代码行数:71,代码来源:qt4reactor.py


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