def showStepInfo(self): if self.input_db_name.text() == "": self.error_label.setText("Please Enter DB Name") return if self.input_db_username.text() == "": self.error_label.setText("Please Enter DB Username") return if self.input_db_password.text() == "": self.error_label.setText("Please Enter DB Password") return if self.input_admin_username.text() == "": self.error_label.setText("Please Enter Admin Username") return if self.input_admin_password.text() == "": self.error_label.setText("Please Enter Admin Password") return if self.input_two_wheeler.text() == "": self.error_label.setText("Please Enter Two Wheeler Space") return if self.input_four_wheeler.text() == "": self.error_label.setText("Please Enter Four Wheeler Space") return data = { "username": self.input_db_username.text(), "database": self.input_db_name.text(), "password": self.input_db_password.text() } file = open("./config.json", "w") file.write(json.dumps(data)) file.close() dbOperation = DBOperation() dbOperation.CreateTables() dbOperation.InsertAdmin(self.input_admin_username.text(), self.input_admin_password.text()) dbOperation.InsertOneTimeData(int(self.input_two_wheeler.text()), int(self.input_four_wheeler.text())) self.close() self.login = LoginScreen() self.login.showLoginScreen() print("Save")
class MainScreen(): def showSplashScreen(self): self.pix = QPixmap("python_vehicle.jpg") self.splassh = QSplashScreen(self.pix, Qt.WindowStaysOnTopHint) self.splassh.show() def showSetupWindow(): mainScreen.splassh.close() installWindow.show() def showLoginWindow(): mainScreen.splassh.close() login.showLoginScreen() app = QApplication(sys.argv) login = LoginScreen() mainScreen = MainScreen() mainScreen.showSplashScreen() installWindow = InstallWindow() if os.path.exists("./config.json"): QTimer.singleShot(3000, showLoginWindow) else: QTimer.singleShot(3000, showSetupWindow) sys.exit(app.exec_())
class InstallWindow(QWidget): def __init__(self): super().__init__() self.setWindowTitle("Install Vehical Parking System") self.resize(400, 200) layout = QVBoxLayout() label_db_name = QLabel("Database Name : ") label_db_username = QLabel("Database Username : "******"Database Password : "******"Admin Username : "******"Admin Password : "******"No of Two Wheeler Space : ") label_no_of_four_seater = QLabel("No. of Four Wheeler Space : ") self.input_db_name = QLineEdit() self.input_db_name.setText("vehicle_parking") self.input_db_username = QLineEdit() self.input_db_username.setText("vehicle") self.input_db_password = QLineEdit() self.input_db_password.setText("vehicle_password") self.input_admin_username = QLineEdit() self.input_admin_password = QLineEdit() self.input_two_wheeler = QLineEdit() self.input_four_wheeler = QLineEdit() buttonsave = QPushButton("save config") self.error_label = QLabel() self.error_label.setStyleSheet("color:red") layout.addWidget(label_db_name) layout.addWidget(self.input_db_name) layout.addWidget(label_db_username) layout.addWidget(self.input_db_username) layout.addWidget(label_db_password) layout.addWidget(self.input_db_password) layout.addWidget(label_admin_username) layout.addWidget(self.input_admin_username) layout.addWidget(label_admin_password) layout.addWidget(self.input_admin_password) layout.addWidget(label_no_of_two_seater) layout.addWidget(self.input_two_wheeler) layout.addWidget(label_no_of_four_seater) layout.addWidget(self.input_four_wheeler) layout.addWidget(buttonsave) layout.addWidget(self.error_label) buttonsave.clicked.connect(self.showStepInfo) self.setLayout(layout) def showStepInfo(self): if self.input_db_name.text() == "": self.error_label.setText("Please Enter DB Name") return if self.input_db_username.text() == "": self.error_label.setText("Please Enter DB Username") return if self.input_db_password.text() == "": self.error_label.setText("Please Enter DB Password") return if self.input_admin_username.text() == "": self.error_label.setText("Please Enter Admin Username") return if self.input_admin_password.text() == "": self.error_label.setText("Please Enter Admin Password") return if self.input_two_wheeler.text() == "": self.error_label.setText("Please Enter Two Wheeler Space") return if self.input_four_wheeler.text() == "": self.error_label.setText("Please Enter Four Wheeler Space") return data = { "username": self.input_db_username.text(), "database": self.input_db_name.text(), "password": self.input_db_password.text() } file = open("./config.json", "w") file.write(json.dumps(data)) file.close() dbOperation = DBOperation() dbOperation.CreateTables() dbOperation.InsertAdmin(self.input_admin_username.text(), self.input_admin_password.text()) dbOperation.InsertOneTimeData(int(self.input_two_wheeler.text()), int(self.input_four_wheeler.text())) self.close() self.login = LoginScreen() self.login.showLoginScreen() print("Save")