Results 1 to 3 of 3

Thread: How to create a window that opens another window with uic module ?? HELP!

  1. #1
    Join Date
    Apr 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Thumbs up 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
    Qt Code:
    1. import sys
    2. from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget
    3. from PyQt5 import uic
    4. import Con_pos
    5. from Registro import Registro
    6.  
    7. class Login(QWidget):
    8.  
    9. def __init__(self):
    10. QWidget.__init__(self)
    11. uic.loadUi("Login.ui", self)
    12. self.registro.clicked.connect(self.view_Registro)
    13. self.show()
    14.  
    15. def view_Registro(self):
    16. reg = Registro.Registro()
    17. reg.show()
    18.  
    19. if __name__ == "__main__":
    20. app = QApplication(sys.argv)
    21. login = Login()
    22. sys.exit(app.exec())
    To copy to clipboard, switch view to plain text mode 

    class Registro

    Qt Code:
    1. import sys
    2. from PyQt5.QtWidgets import QApplication, QMainWindow
    3. from PyQt5 import uic
    4. import Con_pos
    5. import error_log as error
    6.  
    7. ui_clase = uic.loadUi("Registro.ui")
    8. class Registro(ui_clase):
    9. con = Con_pos.con_pos()
    10. def __init__(self, parent = None):
    11. super(ui_clase, self).__init__(parent)
    12. self.setupUi(self)
    13. self.btn_reg.clicked.connect(self.validar_nombre)
    14. self.show()
    15.  
    16. def validar_nombre(self):
    17. nom = self.nom_tx_input.text()
    18. usuario = self.user_tx_input.text()
    19. password = self.pass_tx_input.text()
    20. if usuario != "":
    21. pid = self.getPID()
    22. consul = '''SELECT "id_user" FROM "User" WHERE "id_user" = '%s'; ''' % (usuario)
    23. res_con = Registro.con.consulta(consul)
    24.  
    25. if not res_con:
    26. ins_user = '''INSERT INTO "User" VALUES ('%s', '%s', '%s') ''' % (usuario, nom, password)
    27. ins_sesion = ''' INSERT INTO "sesion" VALUES (%s, '%s') ''' % (pid, usuario)
    28. Registro.con.insertar(ins_user)
    29. Registro.con.insertar(ins_sesion)
    30. else:
    31. err = error.error_dia()
    32. err.etiqueta.setText("El usuario %s ya esta en uso" % (usuario))
    33. err.exec()
    34.  
    35. def getPID(self):
    36. func = "pg_backend_pid"
    37. pid = Registro.con.call_proc(func)
    38. pid = pid[0][0]
    39. return pid
    40.  
    41. if __name__ == "__main__":
    42. app = QApplication(sys.argv)
    43. ventana = Registro()
    44. ventana.show()
    45. sys.exit(app.exec())
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,355
    Thanks
    3
    Thanked 5,009 Times in 4,788 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default 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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,896
    Thanks
    225
    Thanked 607 Times in 597 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to create a window that opens another window with uic module ?? HELP!

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 26th July 2013, 15:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.