import sys
from PyQt5 import QtCore, QtGui, QtWidgets
import sqlite3
from base import client_base
class Authorization_Window(object):
def auth_Form(self):
self.authwindow = QtWidgets.QMainWindow()
self.authform = Authorization_Window()
self.authform.setupUi(self.authwindow)
self.authwindow.destroy()
def client_window(self): # вызов дочернего окна
self.window = QtWidgets.QMainWindow()
self.client = client_base()
self.client.setupUi(self.window)
self.window.show()
def auth_Check(self):
username = self.lineEdit_login.text()
password = self.lineEdit_pass.text()
connection = sqlite3.connect("login.db")
result = connection.execute("SELECT * FROM USERS WHERE USERNAME = ? AND PASSWORD = ?", (username, password))
if (len(result.fetchall()) > 0): #если логин и пароль совпадают с БД, происходит вызов нового окна
print("User Found! ")
self.client_window()
self.auth_Form()
else:
print("User not Found! ")
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(220, 195)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label_login = QtWidgets.QLabel(self.centralwidget)
self.label_login.setGeometry(QtCore.QRect(50, 10, 101, 16))
self.label_login.setObjectName("label_login")
self.label_pass = QtWidgets.QLabel(self.centralwidget)
self.label_pass.setGeometry(QtCore.QRect(50, 50, 61, 16))
self.label_pass.setObjectName("label_pass")
self.lineEdit_login = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_login.setGeometry(QtCore.QRect(50, 30, 113, 20))
self.lineEdit_login.setObjectName("lineEdit_login")
self.lineEdit_pass = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_pass.setGeometry(QtCore.QRect(50, 70, 113, 20))
self.lineEdit_pass.setObjectName("lineEdit_pass")
self.Button_enter = QtWidgets.QPushButton(self.centralwidget)
self.Button_enter.setGeometry(QtCore.QRect(50, 110, 111, 23))
self.Button_enter.setObjectName("Button_enter")
###################EVENT#################
self.Button_enter.clicked.connect(self.auth_Check)
################################################
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 220, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label_login.setText(_translate("MainWindow", "Имя пользователя:"))
self.label_pass.setText(_translate("MainWindow", "Пароль:"))
self.Button_enter.setText(_translate("MainWindow", "Войти"))
def enter(): #вызов главного окна входа по логину и паролю
app = QtWidgets.QApplication(sys.argv)
enter_windows = QtWidgets.QMainWindow()
ui_window = Authorization_Window()
ui_window.setupUi(enter_windows)
enter_windows.show()
sys.exit(app.exec_())
enter()
from PyQt4 import QtGui, QtCore
import sys
class Second(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Second, self).__init__(parent)
self.pushButton2 = QtGui.QPushButton("Выход")
self.setCentralWidget(self.pushButton2)
self.connect(self.pushButton2, QtCore.SIGNAL("clicked()"), QtGui.qApp.quit)
class First(QtGui.QMainWindow):
def __init__(self, parent=None):
super(First, self).__init__(parent)
self.pushButton = QtGui.QPushButton("Ткни сюда")
self.setCentralWidget(self.pushButton)
self.pushButton.clicked.connect(self.on_pushButton_clicked, )
self.dialog = Second(self)
def on_pushButton_clicked(self):
self.hide()
self.dialog.setWindowTitle("Спрятали предыдущее")
self.dialog.resize(300, 70)
self.dialog.show()
def main():
app = QtGui.QApplication(sys.argv)
main = First()
main.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
import sqlite3
from base import client_base
class Authorization_Window(object):
def auth_Form(self):
self.authwindow = QtWidgets.QMainWindow()
self.authform = Authorization_Window()
self.authform.setupUi(self.authwindow)
self.authwindow.destroy()
def client_window(self): # вызов дочернего окна
self.window = QtWidgets.QMainWindow()
self.client = client_base()
self.client.setupUi(self.window)
self.window.show()
def auth_Check(self):
username = self.lineEdit_login.text()
password = self.lineEdit_pass.text()
connection = sqlite3.connect("login.db")
result = connection.execute("SELECT * FROM USERS WHERE USERNAME = ? AND PASSWORD = ?", (username, password))
if (len(result.fetchall()) > 0): #если логин и пароль совпадают с БД, происходит вызов нового окна
print("User Found! ")
self.client_window()
self.auth_Form()
else:
print("User not Found! ")
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(220, 195)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label_login = QtWidgets.QLabel(self.centralwidget)
self.label_login.setGeometry(QtCore.QRect(50, 10, 101, 16))
self.label_login.setObjectName("label_login")
self.label_pass = QtWidgets.QLabel(self.centralwidget)
self.label_pass.setGeometry(QtCore.QRect(50, 50, 61, 16))
self.label_pass.setObjectName("label_pass")
self.lineEdit_login = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_login.setGeometry(QtCore.QRect(50, 30, 113, 20))
self.lineEdit_login.setObjectName("lineEdit_login")
self.lineEdit_pass = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_pass.setGeometry(QtCore.QRect(50, 70, 113, 20))
self.lineEdit_pass.setObjectName("lineEdit_pass")
self.Button_enter = QtWidgets.QPushButton(self.centralwidget)
self.Button_enter.setGeometry(QtCore.QRect(50, 110, 111, 23))
self.Button_enter.setObjectName("Button_enter")
###################EVENT#################
self.Button_enter.clicked.connect(self.auth_Check)
################################################
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 220, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label_login.setText(_translate("MainWindow", "Имя пользователя:"))
self.label_pass.setText(_translate("MainWindow", "Пароль:"))
self.Button_enter.setText(_translate("MainWindow", "Войти"))
def enter(): #вызов главного окна входа по логину и паролю
app = QtWidgets.QApplication(sys.argv)
enter_windows = QtWidgets.QMainWindow()
ui_window = Authorization_Window()
ui_window.setupUi(enter_windows)
enter_windows.show()
sys.exit(app.exec_())
enter()