Exemple #1
0
        self.my_client.on_message = self.on_message
        self.my_client.connect("192.168.1.131", 1883, 60)
        self.my_client.loop_start()

    def on_connect(self,client, userdata,flag, rc):
        client.subscribe(CMqtt.topic)

    def on_message(self,client, userdata, msg):
        #调用消息提示
        mainWindow.touch_sig(str(msg.payload))
        pass

if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)

    mainWindow = MainWindow()
    #登录界面
    loginWindow = login(mainWindow)
    loginWindow.setupUi(loginWindow)
    is_login_ok = False
    global user_name
    if loginWindow.exec_() == QtGui.QDialog.Accepted:
        #print "user_name:%s\n"%loginWindow.user_name
        #print "passwd:%s\n"%loginWindow.passwd
        #检查用户名和密码是否正确
        user_name = str(loginWindow.user_name)
        #开启mqtt推送
        my_mqtt = CMqtt("debug_bug/"+user_name)
        #重设左导航
        mainWindow.createToolBoxEx()
        mainWindow.my_time()
Exemple #2
0
        pass

    def on_connect(self,client, userdata,flag, rc):
        client.subscribe(CMqtt.topic)

    def on_message(self,client, userdata, msg):
        #调用消息提示
        mainWindow.touch_sig(str(msg.payload))

    # pass

if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)

    mainWindow = MainWindow()
    #登录界面
    loginWindow = login()
    loginWindow.setupUi(loginWindow)
    is_login_ok = False
    my_business = business()
    global user_name
    while not is_login_ok:
        if loginWindow.exec_():
            #print "user_name:%s\n"%loginWindow.user_name
            #print "passwd:%s\n"%loginWindow.passwd
            #检查用户名和密码是否正确
            (message,status,admin_id) = my_business.login(loginWindow.user_name, loginWindow.passwd)
            user_name = str(loginWindow.user_name)
            if status:
                #发送成功消息