Master PyQt5 part 8: Using Qt Resource files

  Рет қаралды 6,755

Alan D Moore Codes

Alan D Moore Codes

Күн бұрын

Author Alan D Moore shows you how to deal with file paths in your applications using Qt Resources files and other tricks.
Follow Alan at www.alandmoore.com
Purchase a copy of Mastering GUI Programming with Python here: amzn.to/3Dr8cAy
Example code for this video can be found here: github.com/alandmoore/PyQt-Vi...
Previous video in this series: • Master PyQt5 part 7: U...
Thanks for watching!

Пікірлер: 20
@drivebuss8079
@drivebuss8079 4 жыл бұрын
Thank you very much
@freecode.ai-
@freecode.ai- 2 жыл бұрын
Is it possible to list what resources are available? I mean I know whats in the resource file but I want to know if I can see that list from inside the code. Like listing all the files in a directory..
@rwbazillion
@rwbazillion 3 жыл бұрын
In the playlist for PyQT prgogramming you are missing Part 7, it's in the Mastering PtQT playlist.
@alandmoorecodes3585
@alandmoorecodes3585 3 жыл бұрын
Thanks for letting me know, just got it fixed!
@DA_CSF
@DA_CSF 2 жыл бұрын
As always awesome explanation. Thanks for taking the time for creating such an informative video. Unfortunately if you are using the QT Designer to generate the UI (I am lazy), then one needs to create the linkages for Qpixmap and icons directly in the designer. Else as you have mentioned in your previous videos this inofrmation would be lost during reworks of the GUI Fortunately, the rc file can be created, edited and maintained in QT Designer. For normal elements (not buttons) the linkage can be made under Qlabel --> pixmap. For buttons, Maintittle etc. one has to select an icon (.ico file). This can generated online from png's with realtive ease. All this inofrmation ofcourse can be stored in the rc file which need to be compiled with pyside6-rcc (6 or higher as pyrcc5 is not supported)
@jond532
@jond532 3 жыл бұрын
instead of using just images in resource file can i add other python files that i also need to access?
@alandmoorecodes3585
@alandmoorecodes3585 3 жыл бұрын
You can put any kind of file in a resource, but I would not recommend putting Python files in there. It would make more sense to use standard Python package/module structure for including Python. Also, just a caveat, currently PyQt6 does not include the resource system, as according to the developer Python already has resource systems and it's redundant. I'm not actually sure what he's referring to, but at the moment it doesn't look like this is a good tool to rely on for the future.
@jond532
@jond532 3 жыл бұрын
@@alandmoorecodes3585 i see! that makes sense, thankyou!
@za012345678998765432
@za012345678998765432 3 жыл бұрын
I used the designer and created a resource file through there, then when i convert the UI file it has a this line at the end "#import resources_rc" which throws an error. what do i do with it?
@alandmoore4306
@alandmoore4306 3 жыл бұрын
A line that starts with a # is a comment, so that can't be throwing an error. What error are you getting?
@za012345678998765432
@za012345678998765432 3 жыл бұрын
@@alandmoore4306 Whopps, sorry, i added the comment so it won't throw the error (i know it would get deleted the moment i update the file, it was temporary). the error is "ModuleNotFoundError: No module named 'resources_rc'"
@alandmoore4306
@alandmoore4306 3 жыл бұрын
​@@za012345678998765432 TBQH, I'm not a fan of using Designer, so I haven't dealt with using resource files in it. (I removed most of my comment after rereading your original comment; sorry, operating on less than a cup of coffee today). When you create a resource file, does it compile the resource file for you?
@anonjohnnyG
@anonjohnnyG 4 жыл бұрын
after i convert the qrc file to resource.py, i always get error no module named resource.
@alandmoorecodes3585
@alandmoorecodes3585 4 жыл бұрын
Make sure resource.py is in the same directory as your script, or put it in a module in your program. Just like importing any other file in Python.
@anonjohnnyG
@anonjohnnyG 4 жыл бұрын
@@alandmoorecodes3585 I managed to finally fix the error with the following code: THIS_DIR = dirname(__file__) CODE_DIR = abspath(join(THIS_DIR, '..', 'Documents')) sys.path.append(CODE_DIR)
@NoobTanker523
@NoobTanker523 3 жыл бұрын
@@anonjohnnyG hello. i get the same error. Can you give me a lead to fix if you have a free time.
@NoobTanker523
@NoobTanker523 3 жыл бұрын
sdilhara@protonmail.ch
@anonjohnnyG
@anonjohnnyG 3 жыл бұрын
@@NoobTanker523 did you try adding the above code to the top of your main file. thats all i did and it fixed the error.
Master PyQt5 part 9: Style with Qt StyleSheets
14:59
Alan D Moore Codes
Рет қаралды 15 М.
Master PyQt5 part 11:  Application Infrastructure and Communication
33:51
Alan D Moore Codes
Рет қаралды 4,5 М.
DEFINITELY NOT HAPPENING ON MY WATCH! 😒
00:12
Laro Benz
Рет қаралды 31 МЛН
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
PyQt Images and qrc files
13:27
MadPonyInteractive
Рет қаралды 12 М.
QtDesigner and PyQt5:  The right and wrong way to use them together
37:16
Alan D Moore Codes
Рет қаралды 107 М.
Introduction to GUIs in Python with PyQt5
26:10
Clear Code
Рет қаралды 83 М.
Master PyQt5 part 10: Make responsive GUIs with Threads
33:35
Alan D Moore Codes
Рет қаралды 19 М.
Using Qt Resources for icons in PySide6 or PyQt6
12:11
Jason Codes Qt
Рет қаралды 3,4 М.
Giant numbers
7:27
stuff | An abridged guide to interesting things
Рет қаралды 10 М.
Creating PyQt Layouts for GUI Python Applications
13:56
Real Python
Рет қаралды 29 М.
Intel's CPUs Are Failing, ft. Wendell of Level1 Techs
23:59
Gamers Nexus
Рет қаралды 288 М.
Python Classes pt1:  5 Myths about Python Classes
18:39
Alan D Moore Codes
Рет қаралды 3 М.
Самый дорогой кабель Apple
0:37
Romancev768
Рет қаралды 337 М.
Klavye İle Trafik Işığını Yönetmek #shorts
0:18
Osman Kabadayı
Рет қаралды 1,2 МЛН
Я УКРАЛ ТЕЛЕФОН В МИЛАНЕ
9:18
Игорь Линк
Рет қаралды 55 М.
Отдых для геймера? 😮‍💨 Hiper Engine B50
1:00