def onAddUser(self): data = Database() user = User() user.name = self.editName.text() user.username = self.editUsername.text() user.passWord = self.editPass.text() try: data.insertUser(user) except sqlite3.IntegrityError: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText("Your username has already existed !!!") msg.setInformativeText("Please choose another username !!!") msg.setStandardButtons(QtWidgets.QMessageBox.Ok) msg.exec() return self.addUserIntoTable(user) data.closeDatabase() self.editName.clear() self.editPass.clear() self.editUsername.clear()
def onCellClick(self, row, col): user = User() user.name = self.tableUser.item(row, 0).text() user.username = self.tableUser.item(row, 1).text() user.passWord = self.tableUser.item(row, 2).text() self.editName.setText(user.name) self.editUsername.setText(user.username) self.editPass.setText(user.passWord)