使用pyqt5在Windows之间切换

时间:2019-08-07 17:54:08

标签: python pyqt5

我想用pyqt5成功登录后打开一个新窗口 登录窗口(LOGIN)--->关闭->新窗口(LOAD窗口)

程序从登录窗口开始。如何通过单击登录窗口上的登录按钮切换到主菜单窗口?

main.py

from PyQt5.QtWidgets import QApplication
import PyQt5.uic as uic
import sys
from ui_list import Ui_lists
from events.login import event


app = QApplication(sys.argv)

login_form = uic.loadUi(Ui_lists.LOGIN)
load_form = uic.loadUi(Ui_lists.LOAD)


login_event = event.Event(login_form)
login = login_event.response




login_form.login.clicked.connect(login)
login_form.show()


app.exec_()

event.py

import sqlite3
import sys

from PyQt5 import uic
from PyQt5.QtWidgets import QApplication

from ui_list import Ui_lists



class Event:


    def __init__(self, form):
        self.form = form

    def on_login(self):

        username = self.form.username.text()
        password = self.form.password.text()

        db = sqlite3.connect("inv.db")
        c = db.cursor()
        c.execute('SELECT * FROM users WHERE username = ? AND password = ?', (username, password))

        if (len(c.fetchall()) > 0):
            print("Welcome : "+username)


        else:
            print("Login failed for : "+username)



    def response(self):
        self.on_login()

ui_lists.py

import os

class Ui_lists:
    FOLDER_NAME = "ui"
    SEP = os.sep

    FOLDER = FOLDER_NAME+SEP

    LOGIN = FOLDER+'login.ui'
    LOAD = FOLDER+"load.ui"

0 个答案:

没有答案