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
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())
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget
from PyQt5 import uic
import Con_pos
from Registro import Registro
class Login(QWidget):
def __init__(self):
QWidget.__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__":
app = QApplication(sys.argv)
login = Login()
sys.exit(app.exec())
To copy to clipboard, switch view to plain text mode
class Registro
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())
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
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__":
app = QApplication(sys.argv)
ventana = Registro()
ventana.show()
sys.exit(app.exec())
To copy to clipboard, switch view to plain text mode
Bookmarks