def conf_session(self): """This can be selected by the user to select both a different user and a different car. It does so by going back to the Login Dialog. """ from LoginDialog import LoginDialog login = LoginDialog(self.obd_path, self.data) self.close() login.exec_()
def check_GPS_show_users(self): """GPS FIX""" #Sets flat 'show user list button' so that the user knows the #software is still working."" self.ui.pushButtonUserList.setFlat(True) self.ui.pushButtonUserList.setText(u"Espere al FIX del GPS...") #R-pi GPSD needs to be disabled as well: """Raspbian default install already features a gpsd daemon of its own. We will be calling it on demand so it needs to be disabled due to compatibility issues, as both instances cannot be running at once.""" os.system('sudo systemctl stop gpsd.socket') os.system('sudo systemctl disable gpsd.socket') """ Communication with the GPS device takes place using the agps3 library, available through pip. This library acts as an interface to parse the raw data provided by the gpsd daemon. In order to get the data a GPS fix (i.e. a working satellite link) is required. """ try: gpsd_socket = agps3.GPSDSocket() #Opens a 'socket' form which #can be polled data_stream = agps3.DataStream() #Opens a new data stream #inside the socket gpsd_socket.connect() #Links to the socket. gpsd_socket.watch() #Watches the socket for changes. #Tries to grab an object from the data stream. #If no new objects are found inside the data stream, an #exception is issued warning the user to check the gps link. #If there's a working link but no fix, then the gps device #will be repeatedly polled until success. #Meanwhile, the user is instructed to wait patiently. for new_data in gpsd_socket: if new_data: data_stream.unpack(new_data) if data_stream.lat != 'n/a': break except (OSError, IOError): mb = QtGui.QMessageBox(u'Advertencia', u'Compruebe la conexión del GPS', QtGui.QMessageBox.Warning, QtGui.QMessageBox.Ok, 0, 0) mb.setWindowFlags(QtCore.Qt.FramelessWindowHint) mb.setAttribute(QtCore.Qt.WA_DeleteOnClose, True) # delete dialog on close mb.exec_() #prevent focus loss raise SystemExit #No gps device found -- QUIT #Now a login dialog object is created with all the #collected user data as an argument from LoginDialog import LoginDialog login = LoginDialog(self.obd_path, self.data) self.close() #closes login dialog login.exec_() #keeps focus on loginion dialog
def login(self): sender = self.sender() login = LoginDialog(parent=self, pop3=self.pop3, parentWindow=main) self.loginButton.hide() login.show() if not login.exec_(): self.statusBar().showMessage('Log in cancelled')
def main(): app = QApplication(sys.argv) dialog = LoginDialog() if dialog.exec_(): mainWindow = MainUI() mainWindow.setUsername(dialog.username) mainWindow.show() sys.exit(app.exec_())
def login(): dialog = LoginDialog() if dialog.exec_(): return True else: return False
msg["cmd"] = 'send_control_code' code = '{:04X}'.format(code) # 十进制控制代码转十六进制 msg['machine_number'] = "%d" % machine_number msg['code'] = "%s" % code message.append(msg) if __name__ == '__main__': app = QApplication([]) # 初始化应用 # # 检查是否需要验证产品密钥 # login_dial = LoginDialog() if login_dial.check() or login_dial.exec_(): # # 显示界面 # main_window = MainWindow() # 创建主窗口 # main_window.ui.show() # 按实际大小显示窗口 main_window.ui.showMaximized() # 全屏显示窗口,必须要用,不然不显示界面 # # 子线程启动 # serial_worker = SerialWorker(main_window) serial_worker.start() check_worker = CheckWorker(main_window) check_worker.start()