'Window in PyQt5 has size restrictions from last windows
I had set a fixed size on my Login window however once you login in and it takes you to the LoadingBar window the size restrictions stay even though I set a new fixed size. This leaves my window with blank area. I have tried looking for similar posts but have not found any. This may have a very simple fix and I may have made a very stupid mistake. I would appreciate any help and an explantion. There is no error when running the code
#IMPORTS
import sys, os, sqlite3
import random, datetime
from PyQt5 import QtCore, QtGui, uic
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5 import QtWidgets #, QtWebEngineWidgets
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox
import sqlite3
import time
#WINDOWS
window1 = uic.loadUiType("login.ui")[0]
window2 = uic.loadUiType("SIGNUP.ui")[0]
window3 = uic.loadUiType("main.ui")[0]
window4 = uic.loadUiType("login_loadingbar.ui")[0]
#CLASSES AND MODULES
class Login(QtWidgets.QMainWindow, window1):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.setupUi(self)
#Set title
self.setWindowTitle('Login Window')
self.setFixedWidth(480)
self.setFixedHeight(620)
self.loginButton.clicked.connect(self.loginfunction)
self.password_field.setEchoMode(QtWidgets.QLineEdit.Password)
self.signupHereButton.clicked.connect(self.gotocreate)
def loginfunction(self):
username = self.username_field.text() #[email protected]
password = self.password_field.text() #ptWYccjTQSKX
if len(username) == 0 or len(password) == 0:
self.login_text.setText("Please input all fields")
else:
conn = sqlite3.connect("customersSQL.db")
cur = conn.cursor()
query = 'SELECT password FROM customer_data WHERE email = \''+username+"\'"
cur.execute(query)
result_pass = cur.fetchone()[0]
if result_pass == password:
self.login_text.setText("Successfully logged in")
gotoload = LoadingBar()
widget.addWidget(gotoload)
widget.setCurrentIndex(widget.currentIndex()+1)
gotoload.progress()
else:
self.login_text.setText("Incorrect username or password")
def gotocreate(self):
createacc=CreateAcc()
widget.addWidget(createacc)
widget.setCurrentIndex(widget.currentIndex()+1)
class CreateAcc(QtWidgets.QMainWindow, window2):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.setupUi(self)
#title
self.setWindowTitle('Signup Window')
#Push button
self.signupButton.clicked.connect(self.createaccfunction)
self.passwordSignup_field.setEchoMode(QtWidgets.QLineEdit.Password)
self.confirmPass_field.setEchoMode(QtWidgets.QLineEdit.Password)
def createaccfunction(self):
'This is the create account function where it takes the users input and addes it into the database'
email = self.usernameSignUp_field.text()
password = self.confirmPass_field.text()
if self.passwordSignup_field.text()==self.confirmPass_field.text():
password=self.passwordSignup_field.text()
self.signup_text.setText("Successfully created account")
conn = sqlite3.connect("customersSQL.db")
cur = conn.cursor()
#query1 = """INSERT INTO customer_data (email,password)
# VALUES(?,?)""", (email,password)
print (email,password)
cur.execute("""INSERT INTO customer_data (email,password)
VALUES(?,?)""", (email,password))
conn.commit()
time.sleep(3)
login=Login()
widget.addWidget(login)
widget.setCurrentIndex(widget.currentIndex()+1)
class LoadingBar(QtWidgets.QMainWindow, window4):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.setupUi(self)
#title
self.setWindowTitle('Loading')
self.setWindowFlag(Qt.FramelessWindowHint)
self.setFixedHeight(693)
self.setFixedWidth(351)
#makes progress bar go from 0-100, time scaled
def progress(self):
for i in range(100):
time.sleep(0.1)
self.login_progressBar.setValue(i)
QtWidgets.QApplication.processEvents()
class MainWindow(QtWidgets.QMainWindow, window3):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
self.setupUi(self)
app=QApplication(sys.argv)
w1=Login()
widget=QtWidgets.QStackedWidget()
widget.addWidget(w1)
widget.show()
app.exec_()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
