Пример #1
0
    def __init__(self):
        QMainWindow.__init__(self)
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
            "myappid")  # 系统图标
        self.setWindowIcon(QIcon('.\images\Iron.png'))

        self.main_ui = Ui_login()
        self.main_ui.setupUi(self)
Пример #2
0
	def __init__(self):
		QMainWindow.__init__(self)
		self.msg = QMessageBox()
		self.connect_Account()
		self.login = Ui_login()
		self.login.setupUi(self)
		self.vet = Veterinary()
		self.adm = Admin()
		self.ref = Refuge()
		self.connections = []
		self.login.loginPushButton.clicked.connect(self.compare_Account)
		self.tcpServer = QTcpServer()
		self.tcpServer.listen(QHostAddress("0.0.0.0"),9999)
		self.tcpServer.newConnection.connect(self.addConnections)
Пример #3
0
class LoginWindow(QWidget):
    def __init__(self):
        QMainWindow.__init__(self)
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
            "myappid")  # 系统图标
        self.setWindowIcon(QIcon('.\images\Iron.png'))

        self.main_ui = Ui_login()
        self.main_ui.setupUi(self)

    def paintEvent(self, event):  # set background_img
        painter = QPainter(self)
        painter.drawRect(self.rect())
        pixmap = QPixmap(login_imgpath)  # 换成自己的图片的相对路径
        painter.drawPixmap(self.rect(), pixmap)
Пример #4
0
class LoginWindow(QDialog):
    def __init__(self):
        super(LoginWindow, self).__init__()
        self.li = Ui_login()
        self.li.setupUi(self)
        self.li.ok.clicked.connect(self.Login)

#function for login called when pressed 'ok' on login window

    def Login(self):
        key = self.li.password.text()
        user = self.li.username.text()
        #print(key)
        if key == 'eid' and user == 'shreya':
            print('Logged in')
            self.accept()
            print('closed')
        elif key == 'eid' and user != 'shreya':
            self.li.username.setText('Wrong Username')
        elif key != 'eid' and user == 'shreya':
            self.li.username.setText('Wrong Password')
        else:
            self.li.username.setText('Wrong User & Password')
Пример #5
0
class Login(QMainWindow):
	def __init__(self):
		QMainWindow.__init__(self)
		self.msg = QMessageBox()
		self.connect_Account()
		self.login = Ui_login()
		self.login.setupUi(self)
		self.vet = Veterinary()
		self.adm = Admin()
		self.ref = Refuge()
		self.connections = []
		self.login.loginPushButton.clicked.connect(self.compare_Account)
		self.tcpServer = QTcpServer()
		self.tcpServer.listen(QHostAddress("0.0.0.0"),9999)
		self.tcpServer.newConnection.connect(self.addConnections)

	def addConnections(self):
		clientConnection = self.tcpServer.nextPendingConnection()
		clientConnection.nextBlockSize = 0
		self.connections.append(clientConnection)
		self.connect(clientConnection, SIGNAL("readyRead()"), 
                self.receiveMessage)
	
	def receiveMessage(self):
		for s in self.connections:
			if s.bytesAvailable() > 0:
				stream = QDataStream(s)
				stream.setVersion(QDataStream.Qt_4_2)
				if s.nextBlockSize == 0:
					if s.bytesAvailable() < 4:
						return
					s.nextBlockSize = stream.readUInt32()
				if s.bytesAvailable() < s.nextBlockSize:
					return

				textFromClient = stream.readQString()
				s.nextBlockSize = 0
				self.sendMessage(textFromClient, 
                                 s.socketDescriptor())
				s.nextBlockSize = 0

	def sendMessage(self, text, socketId):
		for s in self.connections:
			if s.socketDescriptor() == socketId:
				message = "Tu> {}".format(text)
			else:
				message = "{}> {}".format(socketId, text)
			reply = QByteArray()
			stream = QDataStream(reply, QIODevice.WriteOnly)
			stream.setVersion(QDataStream.Qt_4_2)
			stream.writeUInt32(0)
			stream.writeQString(message)
			stream.device().seek(0)
			stream.writeUInt32(reply.size() - 4)
			s.write(reply)
		
	def connect_Account(self):
		db = QSqlDatabase.addDatabase('QSQLITE')
		db.setDatabaseName('database.db')
		if db.open() == False:
			self.msg.information(self,"informativo","No se conecto la base de datos")

	def compare_Account(self):
		try:
			query = "SELECT * FROM admin"
			sql = QSqlQuery()
			sql.prepare(query)
			state = sql.exec_()
			sig = False
			while sql.next():
				if self.login.userLineEdit.text() == sql.value(5) and self.login.passLineEdit.text() == sql.value(9) and self.login.loginComboBox.currentText() == 'Veterinaria':
					sig = True	
					self.vet.show()					
				elif self.login.userLineEdit.text() == sql.value(5) and self.login.passLineEdit.text() == sql.value(9) and self.login.loginComboBox.currentText() == 'Adm':
					self.adm.show()
					sig = True					
				elif self.login.userLineEdit.text() == sql.value(5) and self.login.passLineEdit.text() == sql.value(9) and self.login.loginComboBox.currentText() == 'Refugio':
					self.ref.show()
					sig = True	
			if sig == False:
				self.msg.information(self,"informativo","usuario o contraseña erronea")
				self.login.userLineEdit.setFocus()
		except:
			self.msg.information(self,"informativo","Error en la consulta")
		finally:
			self.login.userLineEdit.clear()
			self.login.passLineEdit.clear()
 def openWindow1(self):
     self.window = QtWidgets.QMainWindow()
     self.ui = Ui_login()
     self.ui.setupUi(self.window)
     self.window.show()
sys.path.append("A:/Desktop/myProject/Python/UI forms")
from myExcel import myExcel
from myGUI import myGUI
from PyQt4 import QtGui
from PyQt4 import QtCore
from charWindow import Ui_characterWindow
from login import Ui_login
from mainWindow import Ui_MainWindow

app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
characterWindow = QtGui.QWidget()
login = QtGui.QWidget()
mw = Ui_MainWindow()
li = Ui_login()
cw = Ui_characterWindow()


class WindowController():
    def login(self):
        print("test")

    def openWindow(self):

        mw.setupUi(MainWindow)

        li.setupUi(login)

        cw.setupUi(characterWindow)
Пример #8
0
 def __init__(self):
     super(LoginWindow, self).__init__()
     self.li = Ui_login()
     self.li.setupUi(self)
     self.li.ok.clicked.connect(self.Login)
 def login(self, Form):
     self.window = QtWidgets.QWidget()
     self.ui = Ui_login()
     self.ui.setupUi(self.window)
     Form.hide()
     self.window.show()