class MyLogin(QtGui.QMainWindow): DB = DbManager() def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Login() self.ui.setupUi(self) QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.login) def getUserType(self): if self.ui.radioButton.isChecked(): return 'superadmin' elif self.ui.radioButton_2.isChecked(): return 'administrator' elif self.ui.radioButton_3.isChecked(): return 'operator' def login(self): name = self.ui.lineEdit.text() pwd = self.ui.lineEdit_2.text() check = MyLogin.DB.getUserManager().checkUser(self.getUserType(), name, pwd) if not check: self.ui.lineEdit.setText('') self.ui.lineEdit_2.setText('') if check: StatusManager.setLoginId1(name) if self.getUserType()[0] == 'a': MyMainW(MyLogin.DB, self).show() elif self.getUserType()[0] == 'o': MyOMainW(MyLogin.DB, self).show() else: MySMainW(MyLogin.DB, self).show() self.hide()
self.openAboutInfo) def openAboutInfo(self): message = QtGui.QMessageBox(self) message.setText("version:2.0\nCopyright (c) 2012 Lv Kaiyang") message.exec_() def openStockInfo(self): MyStockInfo(MyMainW.DB, self).show() def openAddBookInfo(self): row = [] MyAABook(MyMainW.DB, self, row).show() def openBookInfo(self): MyBookInfo(MyMainW.DB, self).show() def openSupplierInfo(self): MySupplierInfo(MyMainW.DB, self).show() def openCusInfo(self): MyCusInfo(MyMainW.DB, self).show() if __name__ == '__main__': DB = DbManager() app = QtGui.QApplication(sys.argv) myapp = MyMainW(DB) myapp.show() sys.exit(app.exec_())