Це відео не доступне.
Перепрошуємо.
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
▶️ 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
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!
Glad it was helpful!
Great Python PyQt5 tutorial! Thanks for these!
Feed the algorithm! its free and it helps our favorite creators.
Thanks!
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")
Thank you! I thought I was loosing my mind as I could access the labels defined by their object name in Qt Designer
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!!! 🙏
welcome!
Thanks a lot, I searched a ton of videos literally , Thanks a lot again, Liked & Subscribed 🙂
Thanks for making these great videos. They are very helpful and instructive.
Glad you like them!
I always struggled to covert and reconvert every time .....thanks for the video it was a significant help.
welcome
dude you saved my project, you're the best
Glad you found what you needed!
Very helpful, thanks a ton!
Welcome!
nice! thats what I was looking for
Happy to hear it!
That's precisely what I'm looking for.
Thank you very much 😄
welcome
Лысый, ваще красавчик респект таким как ты!
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
Thx a lot! This video really inspires me about how to start my homework!
Glad you enjoyed it!
Yohoooo a new video...!!! Pleaseee speed uploading the videos up ,, I really need this course ,pleasee !!
I upload videos every single weekday, I'm not going to go any faster. Pyqt5 videos are every Thursday...
awesome vid! Thanks for breaking this down! made me love Python again! :-)
Awesome
Very helpful thank you so much I'm now following your every video.
Awesome!
Awesome! Thanks!
Welcome!
Amazing video! Thank you very much!
Very welcome!
Sweet. Worked like a charm. How do I add my image that goes with QmainWindow Qpixmap?
It's really easier! Thank you so much!!!
Sure thing!
Man....... you saved my life!
sir these tutorials are very nice !!!
Thanks! Glad you like them!
Love From India ❤️
Thanks!
Me too
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?
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
Thank you so much.
Very Welcome!
that , What I'm looking for ,thank you very much , but is there any way to convert python script to GUI ?
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?
I use a module called auto-py-to-exe, it’s very easy to use
Hi,why i'm gettiing just a empty frame while i'm running that code?
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.
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
I mean, it depends on the changes you make in the designer whether or not the code will still work.
This comment may seem like an ordinary “thank you” but it really really means more than a “thank you” 😅🙏
Glad you enjoyed it!
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?
I wish to learn this method before dev lots of pyqt apps.
more clean for managing.
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
Thanks!
Welcome!
i got error
TypeError: ('Wrong base class of toplevel widget', (, 'QDialog'))
what can i do
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?
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:) ).
For some reason none of the images are showing in my application.
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?
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.
Is anyone else getting the error where the app crashes on startup with no error? What should I do?
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)...
Where that 'QDialog' coming from...?
For some reason it does not recognise the .clicked attribute. Any idea?
You typed something wrong somewhere
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
You're using pycharm...no clue what pycharm is doing. I would never use that.
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?
Why I would never use PyCharm
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 ??
We don't have our py file in qt creator...
@@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?
@@rahmadbisma Stop using pycharm
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!
Don't use pycharm, it sucks.
Make sure the interpreter you configured in PyCharm is the same one which you installed all PyQT5 stuff
@@bardub1 Thanks! Yes, I have it working now...
How to open a second window with this way?
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
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?
Yes, further along in this playlist you'll see a solution.
Id like a more ellaborate video with multiple different uses. Such as labels, inputs, notifications etc
@@againstthegrain5914 Yes, of course I do all of that on the playlist.
Upload Daily!
I do!
Done thanks
welcome
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.
How to connect two different programs two ui files in two different py program
This is one I am really struggling to figure out. The biggest struggle I am finding with PyQt is using popups or dialogs .
i have a resource.qrc file how do i import that
I don't have any videos on that
For some reson the window doesn't even show up here
what did you do differently from the video?
thanks!
Heisenberg ?
lol
breaking bad?
He will pin my comment.
Will he?
Do you think?
No, I don't think so
thx
wlcm
Great Python PyQt5 tutorial! Thanks for these!
Feed the algorithm! its free and it helps our favorite creators.
Thanks!