How to create a window that opens another window with uic module ?? HELP!
Hi all, I have a problem when trying to develop a GUI with PyQt5 and QT desginer.
I want to use the "uic" module, I have a .ui file called "registro.ui", and another "login.ui", as I can call from "login.ui" to the "registry.ui",by clicking on registry
My intention is to click the register button, and open the registration window
Using only the uic.loadUI () method?
Here I show my code
Ventana Login
Code:
import sys
from PyQt5 import uic
import Con_pos
from Registro import Registro
def __init__(self):
uic.loadUi("Login.ui", self)
self.registro.clicked.connect(self.view_Registro)
self.show()
def view_Registro(self):
reg = Registro.Registro()
reg.show()
if __name__ == "__main__":
login = Login()
sys.exit(app.exec())
class Registro
Code:
import sys
from PyQt5 import uic
import Con_pos
import error_log as error
ui_clase = uic.loadUi("Registro.ui")
class Registro(ui_clase):
con = Con_pos.con_pos()
def __init__(self, parent = None):
super(ui_clase, self).__init__(parent)
self.setupUi(self)
self.btn_reg.clicked.connect(self.validar_nombre)
self.show()
def validar_nombre(self):
nom = self.nom_tx_input.text()
usuario = self.user_tx_input.text()
password = self.pass_tx_input.text()
if usuario != "":
pid = self.getPID()
consul = '''SELECT "id_user" FROM "User" WHERE "id_user" = '%s'; ''' % (usuario)
res_con = Registro.con.consulta(consul)
if not res_con:
ins_user = '''INSERT INTO "User" VALUES ('%s', '%s', '%s') ''' % (usuario, nom, password)
ins_sesion = ''' INSERT INTO "sesion" VALUES (%s, '%s') ''' % (pid, usuario)
Registro.con.insertar(ins_user)
Registro.con.insertar(ins_sesion)
else:
err = error.error_dia()
err.etiqueta.setText("El usuario %s ya esta en uso" % (usuario))
err.exec()
def getPID(self):
func = "pg_backend_pid"
pid = Registro.con.call_proc(func)
pid = pid[0][0]
return pid
if __name__ == "__main__":
ventana = Registro()
ventana.show()
sys.exit(app.exec())
Re: How to create a window that opens another window with uic module ?? HELP!
I'm not sure what you mean. The code you posted seems to be correct.
Re: How to create a window that opens another window with uic module ?? HELP!
Quote:
The code you posted seems to be correct
except that in the post, the OP says the files are named "registro.ui" and "login.ui", while the code refers to them as "Registro.ui" and "Login.ui". If the file system is case sensitive and the files are really named in lowercase, then they won't be found. The OP also refers to "registry.ui", which isn't anywhere in the code.