Це відео не доступне.
Перепрошуємо.

How To Load PYQT5 Designer UI File - PyQt5 GUI Thursdays #27

Поділитися
Вставка
  • Опубліковано 18 сер 2024
  • In this video I'll show you how to load a PYQT5 Designer UI file into your app with Python.
    In the past we converted our UI files into python. That only works if you never plan on making any changes to your GUI in the designer later on.
    If you make changes and generate a new UI file, your old code will be destroyed when you convert it into a python file!
    In this video I'll show you how to get around that problem by instead importing your UI file into a Python file.
    #pyqt5 #codemy #JohnElder
    Timecodes
    0:00​​ - Introduction
    1:28 - Create GUI With Designer
    3:10 - Create Python File
    3:50 - Import PyQT5 Widgets and UIC and sys
    5:06 - Create Main UI Class
    5:45 - Load UI File and Show App
    6:33 - Initialize App
    7:34 - Define Widgets with findChild()
    9:37 - Make Button Clickable with clicked.connect()
    10:09 - Create clicker() Function
    11:45 - Update UI File Add Button
    12:40 - Integrate New Button To Python File
    13:31 - Clicked.connect() The New Button
    13:45 - Create Clearer Function
    14:34 - Conclusion

КОМЕНТАРІ • 120

  • @Codemycom
    @Codemycom  3 роки тому +1

    ▶️ Watch Entire PyQt5 GUI Thursdays Playlist ✅ Subscribe To My UA-cam Channel:
    bit.ly/3sHT8dc bit.ly/2IGzvOR
    ▶️ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN
    ▶️ Get The Code:
    bit.ly/394NQ3R

  • @rancidbeef582
    @rancidbeef582 2 роки тому +4

    THIS is the info I've needed and never found an any other Qt Designer videos I've watched (which all seem to stop after "Hello World"). I kept wondering how you could ever go back and edit a UI (without doing it manually in the code), but not lose all your application code. Thanks!

    • @Codemycom
      @Codemycom  2 роки тому +2

      Glad it was helpful!

  • @RyanDanielG
    @RyanDanielG 2 роки тому +2

    Great Python PyQt5 tutorial! Thanks for these!
    Feed the algorithm! its free and it helps our favorite creators.

  • @edgoodson3174
    @edgoodson3174 Рік тому +13

    You can completely skip defining all those widgets. Those widgets are defined and NAMED inside of designer.
    You call them by their EXACT custom name inside of the python file.
    Such as
    self.MY_CUSTOM_NAME_Label.setText("Some Text or variable")

    • @andrewcameron2135
      @andrewcameron2135 10 місяців тому

      Thank you! I thought I was loosing my mind as I could access the labels defined by their object name in Qt Designer

  • @danilodelucio
    @danilodelucio Рік тому

    Maaaan this is really insane, I didn't know that was possible to work without converting to python file.
    You are amazing, thank you so much!!! 🙏

  • @arjungoud3450
    @arjungoud3450 Рік тому

    Thanks a lot, I searched a ton of videos literally , Thanks a lot again, Liked & Subscribed 🙂

  • @salarghaffarian4914
    @salarghaffarian4914 2 роки тому +2

    Thanks for making these great videos. They are very helpful and instructive.

  • @saralagab4036
    @saralagab4036 Рік тому

    I always struggled to covert and reconvert every time .....thanks for the video it was a significant help.

  • @mirai_jpg
    @mirai_jpg 2 роки тому

    dude you saved my project, you're the best

    • @Codemycom
      @Codemycom  2 роки тому

      Glad you found what you needed!

  • @aamano7439
    @aamano7439 4 місяці тому

    Very helpful, thanks a ton!

  • @vyacheslavboyko6114
    @vyacheslavboyko6114 Рік тому

    nice! thats what I was looking for

  • @kaoburawich
    @kaoburawich Рік тому

    That's precisely what I'm looking for.
    Thank you very much 😄

  • @user-xp4zl7tf7o
    @user-xp4zl7tf7o 2 роки тому +1

    Лысый, ваще красавчик респект таким как ты!

  • @user-jf8if6fi1f
    @user-jf8if6fi1f Рік тому

    Suppose it have to the first tutorial in pyqt and only then other functions, since load ui is a fundamental of pyqt idea.
    Great tutorial, thanks a lot

  • @user-wo8wx5ts6n
    @user-wo8wx5ts6n Рік тому

    Thx a lot! This video really inspires me about how to start my homework!

  • @sia9664
    @sia9664 3 роки тому

    Yohoooo a new video...!!! Pleaseee speed uploading the videos up ,, I really need this course ,pleasee !!

    • @Codemycom
      @Codemycom  3 роки тому +1

      I upload videos every single weekday, I'm not going to go any faster. Pyqt5 videos are every Thursday...

  • @IzzyRock
    @IzzyRock 2 роки тому

    awesome vid! Thanks for breaking this down! made me love Python again! :-)

  • @robodev6033
    @robodev6033 2 роки тому

    Very helpful thank you so much I'm now following your every video.

  • @avivbello5016
    @avivbello5016 Рік тому

    Awesome! Thanks!

  • @marcelohpinheiro
    @marcelohpinheiro 2 роки тому

    Amazing video! Thank you very much!

  • @fjt020795
    @fjt020795 2 місяці тому

    Sweet. Worked like a charm. How do I add my image that goes with QmainWindow Qpixmap?

  • @laurentreynaud4404
    @laurentreynaud4404 3 роки тому

    It's really easier! Thank you so much!!!

  • @neocial
    @neocial 2 роки тому

    Man....... you saved my life!

  • @krdshow8278
    @krdshow8278 2 роки тому

    sir these tutorials are very nice !!!

    • @Codemycom
      @Codemycom  2 роки тому

      Thanks! Glad you like them!

  • @techsmit
    @techsmit 3 роки тому +2

    Love From India ❤️

  • @garyt2185
    @garyt2185 2 роки тому

    Do you have a video showing how to open a second window (a different .ui file) from your main py code you are showing in this video?

  • @07poojam1cse4
    @07poojam1cse4 Рік тому

    I have plot a graph from excel using python code and i have created a gui using qt designer, how can i plot this graph inside qt graphics view of gui .Please suggest

  • @bahmanmirzakhani1549
    @bahmanmirzakhani1549 2 роки тому

    Thank you so much.

  • @Angry_Cat00
    @Angry_Cat00 Рік тому

    that , What I'm looking for ,thank you very much , but is there any way to convert python script to GUI ?

  • @epifanioperol8833
    @epifanioperol8833 2 роки тому +1

    Hi sir, it really helps me out in our project, Thank you so much. Just 1 question Sir how can I convert the final code to .exe file?

    • @brennancurrier806
      @brennancurrier806 2 роки тому

      I use a module called auto-py-to-exe, it’s very easy to use

  • @sajiinsta2026
    @sajiinsta2026 2 роки тому

    Hi,why i'm gettiing just a empty frame while i'm running that code?

  • @RoadsterLoverMedia
    @RoadsterLoverMedia 2 роки тому

    Hello. Trying to understand the connection between the UI file and the PY file. Is it correct that the UI is an XML that gets processed by the Qt package and Qt has a graphic render engine which consumes the XML and creates one form per UI?
    If yes, is there a manual of the XML commands?
    Thanks. Love this format.

  • @romankovalchyk3620
    @romankovalchyk3620 Рік тому

    Good video! If I want to change the GUI in Qt designer, should I upload the new version of file with ui extension, or everything will be updated automatically since we linked file "loadui" with Python code? So, if I am updating the GUI via Qt designer I merely need to click "save" button to make changes? Then I can run my app with these changes and all previously coded functionality will be working

    • @Codemycom
      @Codemycom  Рік тому

      I mean, it depends on the changes you make in the designer whether or not the code will still work.

  • @umuts5
    @umuts5 Рік тому

    This comment may seem like an ordinary “thank you” but it really really means more than a “thank you” 😅🙏

  • @TheFpdragon
    @TheFpdragon 2 роки тому

    Why are you using the self.findChild method? I can access the objects directly after uic.loadUi with "self.textEdit", "self.pushButton" and so on. No need for creating new variables and setting them with findChild. Maybe I am using a newer version?

  • @atahirince
    @atahirince 2 роки тому

    I wish to learn this method before dev lots of pyqt apps.
    more clean for managing.

  • @maumau4369
    @maumau4369 2 роки тому

    hey so when i try to make the button clicked thing I get the error "argument 1 has unexpected type 'QPushButton'" but I imported all right so yeah idk what is the problem

  • @arjungoud3450
    @arjungoud3450 Рік тому

    Thanks!

  • @marz4964
    @marz4964 2 роки тому

    i got error
    TypeError: ('Wrong base class of toplevel widget', (, 'QDialog'))
    what can i do

  • @christressler3857
    @christressler3857 Рік тому

    Thanks for the info! When I first did this (and couple times afterward actually, respecting folder structure) it worked. Not too bad.
    However, whenever I move the files to a different folder, it can't find the .ui file.
    Even in same folder.
    Instead of looking at relative folders like imports do, it instead relies on the folder that vscode is in (terminal at bottom) (haven't tried it with other ide's studios etc)
    Is there a cleaner way to tell the py file where to find the ui file?

    • @christressler3857
      @christressler3857 Рік тому

      This can work:
      import os
      This is supposed to be,
      underscore underscore file underscore underscore
      But reads it as italicize, sorry it gets around it second time but not this first:
      __file__ will refer to the py file's actual directory path (AND name)
      But when using the following,
      path1 = os.path.dirname(__file__)
      this will just refer ONLY to the directory, and not include the file's filename.
      As long as both files are kept together in the same subfolder (or ui is in sub-subfolder from your py file), you can refer to the ui file using the above, as a string + ui file's name (or + sub-subfolder/uifile.ui etc)
      ie,
      fullpath1 = path1 + 'loadui.ui'
      This looks like an absolute path technique - it is an absolute path - but is initially relative using the py file's location stored as a variable, which THEN becomes absolute path.
      This might also be flexible enough to add portability for your programs (I'm not 100% sure it will work but I'm pretty sure:) ).

  • @Jdeadevil
    @Jdeadevil Рік тому

    For some reason none of the images are showing in my application.

  • @TheKobi209
    @TheKobi209 Рік тому

    Great video, thanks! What if your GUI contains multiple windows, where each window represented by its own ui file? How would you import to the .py file those multiple ui files?

    • @danilodelucio
      @danilodelucio Рік тому

      I guess you have to do the same process for each ui file, and manipulate them with different python files as well (for exemple, if you have a menu.ui, creates a menu.py, if you have register.ui, creates register.py and so on), like the video. So probably you will have to create a "master" python file to call them (like a "main.py"), and makes the transition of each one.
      This is what I guess because Im learning too.

  • @phillymapmaker3891
    @phillymapmaker3891 Рік тому

    Is anyone else getting the error where the app crashes on startup with no error? What should I do?

  • @drorgold512
    @drorgold512 2 роки тому

    Hello, John...
    Thank you so much about all your wonderfull gifts: These videoes...
    I have a problem running your program:
    TypeError: ('Wrong base class of toplevel widget', (, 'QDialog'))
    -----
    (I did exactly what you did)...

    • @drorgold512
      @drorgold512 2 роки тому

      Where that 'QDialog' coming from...?

  • @leventefarkas4163
    @leventefarkas4163 2 роки тому

    For some reason it does not recognise the .clicked attribute. Any idea?

    • @Codemycom
      @Codemycom  2 роки тому

      You typed something wrong somewhere

  • @parniansrb59
    @parniansrb59 Рік тому

    I did everything you explained using pycharm. But when I got to the part that we pass MainWindow to the second window. I got an error saying:
    Ui_SecondWindow.setupUi() missing 1 required positional argument: ‘MainWindow’
    But I actually did everything right

    • @Codemycom
      @Codemycom  Рік тому

      You're using pycharm...no clue what pycharm is doing. I would never use that.

  • @jockfaire
    @jockfaire 2 роки тому

    I get 3 errors in PyCharm when i run my main.py file. They are 1. "Cannot find reference 'uic' in '__init__py'
    2. 'Unresolved reference loadUi'
    3. FileNotFoundError: [Errno 2] No such file or directory: '[file_name].ui, self
    Any idea how i can fix these errors?

    • @Codemycom
      @Codemycom  2 роки тому

      Why I would never use PyCharm

  • @Ahmedyashar
    @Ahmedyashar 2 роки тому

    Hi John, thank you for the great tutorial, I have one question, what i don't understand is if you have both py and ui files in qt creator why do you compleating coding in another editor, is there any problem completing both ui and py file in qt creator ??

    • @Codemycom
      @Codemycom  2 роки тому

      We don't have our py file in qt creator...

    • @rahmadbisma
      @rahmadbisma 2 роки тому

      @@Codemycom sir i i cant import uic module it says module not found im using pycharm and python 3.9.7 how do i can fix this?

    • @Codemycom
      @Codemycom  2 роки тому

      @@rahmadbisma Stop using pycharm

  • @HugoCervantes-HARO
    @HugoCervantes-HARO 2 роки тому

    Hey John, whenever I try "from PyQt5 import uic" I get an error: uic is underlined in red, so when I try to do the uic.loadUi("load.ui", self), I get several errors. As I have been investigating, this seems to be a pretty common issue for lots of people. I have checked my Python and PyQT5 installation/configuration and they seem to be fine. In fact, I can run the line "from PyQt5 import uic" from the Python console with no problem. It is only from within the scrip in PyCharm that I am getting this problem. YOUR HELP WILL BE HIGHLY APPRECIATED!

    • @Codemycom
      @Codemycom  2 роки тому +3

      Don't use pycharm, it sucks.

    • @bardub1
      @bardub1 2 роки тому +1

      Make sure the interpreter you configured in PyCharm is the same one which you installed all PyQT5 stuff

    • @Scanito
      @Scanito 2 роки тому

      @@bardub1 Thanks! Yes, I have it working now...

  • @kirpi2019
    @kirpi2019 2 роки тому

    How to open a second window with this way?

  • @codeKeshav
    @codeKeshav 3 роки тому

    John Elder, please make a video how can we control the second window from 1st using *LOAD UI* method.
    Please show how can we create responsive gui using PYQT5

  • @againstthegrain5914
    @againstthegrain5914 Рік тому

    Is there anywhere else that I can go research about this subject? This video works, but is alittle outdated. I used the QtDesigner, all blown out widgets and all, but trying to add them all inside those widgets I made is VERY challenging. Is there a place I can go? Does anyone know?

    • @Codemycom
      @Codemycom  Рік тому +1

      Yes, further along in this playlist you'll see a solution.

    • @againstthegrain5914
      @againstthegrain5914 Рік тому

      Id like a more ellaborate video with multiple different uses. Such as labels, inputs, notifications etc

    • @Codemycom
      @Codemycom  Рік тому

      @@againstthegrain5914 Yes, of course I do all of that on the playlist.

  • @jenilchudgar
    @jenilchudgar 3 роки тому

    Upload Daily!

  • @anjuchoudhary2860
    @anjuchoudhary2860 2 роки тому

    Done thanks

  • @samrusso8259
    @samrusso8259 2 роки тому

    Hi John,
    Thanks heaps for you video.
    I have a loadUi question relating to a Homepage.py and 2 other windows that load ui files:
    Like this:
    * HomePage.py (this has a button labelled Goto_Window1.py that loads Window1.ui, and another button Goto_Window2 that loads Window2.ui.
    * When clicking on the Goto_Windows1.py it opens the Window1 window (and hides itself ie: HomePage.py) OR when when clicking on the Goto_Windows2.py it opens the Window2 (and hides itself ie: HomePage.py)
    * Both Goto_WIndows1.py and Goto_WIndows2.py have a "HOME" button which takes you back to the Homepage.py
    Can you please help me get a rough template for such an app.

  • @anoopjose142
    @anoopjose142 2 роки тому

    How to connect two different programs two ui files in two different py program

    • @conorman75
      @conorman75 2 роки тому

      This is one I am really struggling to figure out. The biggest struggle I am finding with PyQt is using popups or dialogs .

  • @thanushkarthik_tk
    @thanushkarthik_tk 2 роки тому

    i have a resource.qrc file how do i import that

    • @Codemycom
      @Codemycom  2 роки тому

      I don't have any videos on that

  • @joimarbritogoncalvesfilho8336
    @joimarbritogoncalvesfilho8336 8 місяців тому

    For some reson the window doesn't even show up here

    • @Codemycom
      @Codemycom  8 місяців тому

      what did you do differently from the video?

  • @adrianhochla3664
    @adrianhochla3664 2 роки тому

  •  2 роки тому

    Heisenberg ?

  • @charchitdahiya986
    @charchitdahiya986 3 роки тому +2

    He will pin my comment.
    Will he?

  • @adammustapha3142
    @adammustapha3142 2 роки тому

    thx

  • @miguelfigueiredo8031
    @miguelfigueiredo8031 Рік тому

    Great Python PyQt5 tutorial! Thanks for these!
    Feed the algorithm! its free and it helps our favorite creators.