I want to open a form that is represented in a register file that is opened by a click in register button in the login window (main.py) but when the registration form is closed, it can not be opened again in the same session.
But I have to close the whole program and then open it again so that I can get rid of the register only once... and so on.
As well as how to become the register form child of the main model.
If you need to register some users when you open the application then close the form and do some transactions in the same application. And then return to register another person by clicking on the register button to open its from, The problem occurs that the register file is not imported again and therefore do not open the registration form.
So how do I solve this problem so I can open the registration form or any other form I import several times (in the same session) without closing. The program and opens it again.
This file indicated into main.py:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton
from PyQt5.QtGui import QPixmap, QIcon
app = QApplication(sys.argv)
mainRoot = QWidget()
mainRoot.setWindowTitle('Login')
mainRoot.setWindowIcon(QIcon('image\icon2.png'))
lblBackground = QLabel(mainRoot)
pic = QPixmap('image\pic-1.jpg')
lblBackground.setPixmap(pic)
mainRoot.setGeometry(600, 300, 322, 220)
user = QLabel('user name', mainRoot)
user.move(50, 50)
password = QLabel('password', mainRoot)
password.move(50, 80)
username_edt = QLineEdit(mainRoot)
username_edt.move(110, 50)
password_edt = QLineEdit(mainRoot)
password_edt.setEchoMode(QLineEdit.Password)
password_edt.move(110, 75)
signin = QPushButton('sign in', mainRoot)
signin.move(20, 110)
registerBtn = QPushButton('register ', mainRoot)
registerBtn.move(120, 110)
qut_btn = QPushButton('Quit', mainRoot)
qut_btn.move(220, 110)
def registerUser():
import register
registerBtn.clicked.connect(registerUser)
qut_btn.clicked.connect(quit)
mainRoot.show()
sys.exit(app.exec_())
This file indicated into register.py:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QLineEdit, QPushButton, QComboBox, QRadioButton
from PyQt5.QtGui import QPixmap
app = QApplication(sys.argv)
signRoot = QWidget()
signRoot.setWindowTitle('Registration')
lblBackground = QLabel(signRoot)
pix = QPixmap('image\pic-10.jpg')
lblBackground.setPixmap(pix)
signRoot.setGeometry(600, 300, 400, 300)
fullNameLbl = QLabel('Full Name', signRoot)
fullNameLbl.move(100, 50)
userNameLbl = QLabel('User Name', signRoot)
userNameLbl.move(100, 80)
passWord = QLabel('password', signRoot)
passWord.move(100, 110)
typeLbl = QLabel('Type', signRoot)
typeLbl.move(100, 140)
departmentLbl = QLabel('Department', signRoot)
departmentLbl.move(100, 180)
fullName = QLineEdit(signRoot)
fullName.move(200, 50)
userName = QLineEdit(signRoot)
userName.move(200, 80)
passWord = QLineEdit(signRoot)
passWord.setEchoMode(QLineEdit.Password)
passWord.move(200, 110)
maleType = QRadioButton('Male', signRoot)
maleType.move(200, 140)
femaleType = QRadioButton('Female', signRoot)
femaleType.move(270, 140)
department = QComboBox(signRoot)
department.move(200, 180)
submitted = QPushButton('Submit', signRoot)
submitted.move(150, 240)
qut_btn = QPushButton('Quit', signRoot)
qut_btn.move(250, 240)
def qutRegisterForm():
signRoot.close()
qut_btn.clicked.connect(qutRegisterForm)
signRoot.show()
After run menu form and appear then click on file and register
After register form appear and close it by clicked on exit button
Can't open register form again when I repeat clicked on file and register