Beispiel #1
0
    asynchronous commands such as yield require an @inlineCallbacks decorator before the function,
    
    def function1(self):
        print 'do something'
        
    @inlineCallbacks    
    def function2(self):
        yield print 'do something asynchronous' 
    '''
        
    def closeEvent(self, x):
        '''
        This function is run upon the GUI being closed all cleanup should be done here such as stopping the reactor
        '''
        self.reactor.stop()#stops the reactor
        
if __name__=="__main__":
    '''
    This is the function that gets run first if the client python file is run directly, however if this client is imported by another function
    this function will not be run
    '''
    a = QtGui.QApplication( [] ) #Creates a GUI structure and can take sys arguments
    from common.lib.clients import qt4reactor #imports the PyQt4 reactor that must be integrated with twisted reactor (this must happen here)
    qt4reactor.install()#installs the pyqt4 reactor
    from twisted.internet import reactor# imports the twisted reactor
    client_shellWidget = client_shell(reactor) #instantiates a widget with the just imported reactor
    client_shellWidget.show()#shows the widget
    reactor.run()#runs the integrated reactor
        
        
        
Beispiel #2
0
        self.lcdNumber.display(value)
        
    @inlineCallbacks    
    def onNewSet(self,dummy):
        newset = yield self.server.new_data_set()
        self.lineEdit.setText(newset)
        
    @inlineCallbacks
    def on_toggled(self,value):
        if value:
            self.pushButton.setText('I')
        else: 
            self.pushButton.setText('O')
        yield self.server.toggle_counting(value)

    @inlineCallbacks
    def onNewDuration(self, value):
        yield self.server.set_update_time(self.T.Value(value, 's'))
    
    def closeEvent(self, x):
        self.reactor.stop()

if __name__=="__main__":
    a = QtGui.QApplication( [] )
    from common.lib.clients import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    pmtWidget = pmtWidget(reactor)
    pmtWidget.show()
    reactor.run()
Beispiel #3
0
        sendbutton = QtGui.QPushButton(self)
        sendbutton.setText('Send')
        sendbutton.clicked.connect(self.senddata)
        layout.addWidget(self.textbox, 0, 0)
        layout.addWidget(sendbutton, 1, 0)

        self.setLayout(layout)

    @inlineCallbacks
    def senddata(self, data):
        timetag = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        text = self.textbox.toPlainText()
        text = str(text)
        yield self.wiki.add_line_to_file(text)
        yield self.wiki.add_line_to_file("##" + timetag)
        yield self.wiki.update_wiki()
        self.textbox.setPlainText('')

    def closeEvent(self, x):
        self.reactor.stop()


if __name__ == "__main__":
    a = QtGui.QApplication([])
    from common.lib.clients import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    ELogWidget = ELog(reactor)
    ELogWidget.show()
    reactor.run()