Create GUI App with PyQt5 - PART 1
Vložit
- čas přidán 25. 07. 2024
- In this video we'll use PyQt5 to create the graphic interface of "Who Wants to be a Programmer???";
a computer science trivia game, which determines who is truly worthy of the title!
We'll design the first two frames of this game and learn how to switch from one to the other effortlessly.
We'll also discuss in detail all the important widgets (text, image, button) , we'll go over styling and layout commands, as well as adding interactivity to clickable elements (this is probably my favourite part of PyQt5 - it allows you to create hover events and utilize your pro CSS skills to their full extent!).
This is PART 1 of the complete project, where we focus on creating the GUI.
In the upcoming PART 2, we will load a database of trivia questions and connect all its functionality to our interface.
😍 WATCH PYQT5 TRIVIA APP - PART 2 😍
• Open Trivia Database f...
********************************************
DOWNLOAD STARTER FILES:
github.com/MariyaSha/TriviaGa...
PyQt5 Documentation:
www.riverbankcomputing.com/st...
COMPLETE PROJECT:
github.com/MariyaSha/TriviaGame
MY NEW BLOG:
www.mariyasha.com/
(also pythonsimplified.ca)
CONNECT ON LINKEDIN:
/ mariyasha888
FOLLOW ON INSTAGRAM:
/ mariyasha888
************************************
⭐⭐⭐ TIMESTAMPS ⭐⭐⭐
************************************
00:00 - Intro
00:59 - Starter files walkthrough
************************************
1. CREATE WINDOW OBJECT
************************************
01:15 - initialize GUI app
01:31 - create QWidget window
01:46 - set window title
02:09 - set window width
02:22 - set window background color
02:58 - open window
03:05 - terminate app
************************************
2. RUN APP WITH TERMINAL
************************************
03:25 - open Anaconda or other terminal
03:29 - activate working environment
03:35 - change directory
03:57 - run app
04:12 - initialize grid layout
04:23 - apply grid layout
************************************
3. CREATE LOGO WIDGET
************************************
04:36 - load png image
05:00 - create label widget
05:10 - place image inside label
05:23 - place logo on grid
05:48 - set window position (fix)
06:36 - align label to center
06:56 - set label margin
************************************
4. CREATE BUTTON WIDGET
************************************
07:33 - create button widget
07:53 - set button cursor
08:32 - set button CSS style
10:05 - place button on grid
11:09 - set button padding and margin
12:02 - mouse hover event
************************************
5. CREATE FRAME FUNCTION
************************************
13:10 - create frame function
13:39 - call frame function
13:52 - create global dictionary of empty lists
14:40 - append local widgets to global dictionary
15:12 - place global variables on the grid
************************************
6. DESIGN FRAME 2
************************************
15:55 - define frame 2 function
16:09 - create text widget
16:53 - create wrapping text widget
17:36 - set word wrap
18:45 - place label on grid
19:26 - set column span
19:58 - fix typos and parameters
************************************
7. CREATE IDENTICAL BUTTONS
************************************
20:28 - create a button widget
21:05 - store button widget in a function
21:51 - return button from function
22:09 - add buttons to global dictionary
22:18 - call button function many times
23:17 - customize parameters for each button
24:20 - update function call with new parameters
************************************
8. SWITCH FRAMES
************************************
26:02 - define callback function
26:13 - hide all widgets
26:43 - reset global dictionary
27:49 - button callback
28:23 - switch frames continuously
************************************
29:54 - THANKS FOR WATCHING!
************************************
#python #pythonprogramming #learnpython #creategui #gui #graphicuserinterface #pythontutorial #programming #createapp #createpythonapp #interface #designinterface - Věda a technologie
I've watched many tutorials on PyQt5 and python in general, and you are the only one to actually explain what the code you write means and does! Keep up the good work and you earned a subscriber!
Why does almost no one do this? It is so important to tell viewers what the code actually does so we can understand it. So annoying lol.
@@lmnts556 IFKR, I hate most other tutorial videos because they skip over so many crucial details. Later on I learn them on my own, go back and watch the videos thinking, WHY DIDN'T THEY JUST SAY THIS
I want to praise you for taking note of corrections. This is a superior trait and I admire you more for your ability to learn and progress.
The example you set, will influence your students and followers to do the same by following your good example. Kudos.
HEY , mam , these are genuenly the most helpful tutorial videos i have encountered !! i have been following ur content since last month now , and am especially amazed on this GUI APP. it is really quite classy and useful and , i observed that this code is really very clean and PYTHONIC as one can expect , nowhere, on the INTERNET or other sources did i found this program explained so well !!
I found your vídeo randomly before take a sleep, I'm Lucky for dont fall asleep now hahaha. You made a Superb TimeStamp on description and looks like PyQt5 Will be more useful than TKinter for a Project! Thanks!
Thank you very much, your idea to save the history in a global dictionary of lists of widgets is amazing :). I also like this way of using PyQt5 more than using in an object orientated way
Took me an hour to do it, thank you for your efforts. Шикарный английский!
Using this way makes it look much better than Tkinter module.
Fantastic video and great run through of the functions and how to change them to achieve our own tailored display quiz windows. Thank you 💙
Hi there,
I have listened and watched few of your lessons about Python and I would like to appreciate you about how you politely describe the lessons and sometimes I used to smile on your reactions and expressions, want to have more lectures, Appreciation from Pakistan.!!!
I done all work of Part 1 PyQt5 to create the graphic user interface. You an excellent work design greatness job. That first Part 1.
Loving the content, thanks for making some great videos! I'm following along and I noticed that the hover styling includes when the cursor is over the margin of the button. Is there a way to have the margin but only have the hover over the button it self?
I'm waiting! Cheers from Japan.
Thank you Domino Sniper, I'll see you in the live chat once the premiere begins! 😁
Cheers from beautiful British Columbia!
Excellent tutorial and I appreciated your explanations on what the code is doing. Thank you, you have a subscriber. Look forward to part 2
The possibility to add Style Sheet is simply awesome (it is Qt Style Sheet, not Cascading Style Sheet, but it is very similar)
I hope that you'll get more attention because your tutorials have good quality.
What i mean when talking about quality:
- No waste of time ( You do everything very precise and fast)
- Good audio quality
- Very clear informations about why you are doing what you're doing
I'm not here because i am a simp, your content just speaks for itself. Hopefully you keep your channel active for some years with financial profit and teaching ppl your way how to be better programmers!
Wow, thank you so much for the incredible feedback Raphi!!!
I sometimes wonder if all this hard work is worth it - and then seeing comment such as yours gives me a huge motivation boost!! You've made my day, thank you!!! ❤️❤️❤️
@@PythonSimplified I am happy to hear that!
I maybe have an idea for your channel.
I saw many ppl typing in your comments that they started to program their own stuff because of you. If you want to you could do a video format and start a playlist about you looking over your comunity's programs and tell them what they need to improove! Ofc you only need to show programs where you think the creators or viewers will learn a lot from but at the end you need to decide what you think is best haha
I would love this kind of format if it doesnt take too much time and afford from you! 😊
It maybe makes your Comunity even stronger followers and consumer bc yk.. nowadays a lot og programmers only do their thing and comunitys are not asked many times.
But don't let it overwhelm you! I don't want you beeing in need for breaks from making yt because one of my ideas makes you unhappy. 😅😳😂
Ps: I would probably be the first person sending you something because i am unsure about the logic of my programmed stuff.
(Its kinda hard for me to read stuff from the internet and put the things into my programs that it works. Thats why i need exampls like your video 😩😂)
Hope your day went as good as the motivation you got! 😌
“I’m not here because i am a simp…” LOL 😂
@@dataengineer4424 simp memes have been such a nice thing back in the times i wrote the comment. ^^
Also..not indian.
Expectacular, te seguire viendo! Buen trabajo
Interesting, this is my first time looking at PyQt. Having done some simple CSS and javascript on websites before, this all makes sense.
been trying to find this since a long time thank you so much
Thank you for this amazing and informative video, it helped me a lot in making my first GUI application.
I've been meaning to check out Qt for a while, great topic!
Definitely check it out! I have a feeling you're gonna love it! 😃
I can't even think about Tkinter since I've discovered it! I find PyQt5 to be so much nicer in terms of styling, element placement and interactivity - it's an incomparable experiance!
Today I discovered your channel randomly iam loving it,
greetings from Iran
Thank you Milad, I'm glad you like my tutorials! 😁
Greetings from Canada! (and Nowruz Mubarak!)
I'm loving your classes! You and beautiful! From Brazil!
Thank you so much CanaL Legal! Greetings from Canada! 😃
Прикольная))) продолжай в том же духе! Как ux designer смотрю на это все😅 Какие оказывается возможности есть для стайлинга. Я в Германии по немецки так не шпарю как ты по английски 😂👍
Hahaha spasibo bolshoie Pablues!! Ja zivu v Kanade uze po4ti 8 let, ho4esh neho4esh - Angliskii viu4ish o4en horosho za eto vremja 🤣🤣🤣 i nemezkii na mnogo trudneie 4em Angliskii, ja pomnu pitalas sama evo u4it (4tob lutshe ponimat pesni Rammstein) no ne kak ne smogla! tak 4to - it's not really apples to apples 😁
I have learned something new here. Thanks for making this video :)
omggg I wish I found this video sooner its amazing
Thank you so much Sela! 😀
I'm glad you ended up finding it, even if slightly late!😉
Thankyou! I'm waiting for part 2
I have been studying from these videos and OMG these are amazing !!!!!!!!!!!! Why don't universities teach python???? Its such a great language!! Hope you become a famous youtuber!! Keep it up!
Great video! Thanks for putting this together.
привет, веселая чувиха с отличными видео - уроками) Как давно я Тебя не смотрел. Рад видеть Тебя и рад, что у Тебя все хорошо и Ты как всегда на позитиве!
(Another) Excellent Video! Very well organized and super informative. Looking forward to Part 2 already!!
Thank you so much Jim! 😃
I've already uploaded the complete code to Github if you want to have a peek. I'll go over it in lots of detail in the upcoming tutorial, but I thought it would be nice to include it in case people are curious 😉
@@PythonSimplified Nope! That's no fun :) I am gonna wait for the video - much better to learn that way :) Thanks though!
@@jimbauer9508 it's actually my favourite kind of answer!! thank you! 😃
@@PythonSimplified i love you
I'm sold. Thanks.
clean code and clear explanation. Great tutorial video!
Thank you so much, glad you liked it! :D
Awesome! I had just done this in tkinter but less efficient. I'm gonna try to use the same logic for my tkinter project!
You absolutely gonna love PyQt5, Brandon!! it will allow you much more customisation and interactivity, especially if you're a fan of CSS! 😁
I'd love to see what you come up with, let me know how your project turns out! 😃
Thank you for this content, u definitely deserve more subscribers
u explained this so well T_____T THANK YOU SO MUCH!
You are the best 😍
I love your Tutorials
Thank you Mohamed, I'm glad you like my videos! 😃
In the stylesheet method, you should use f-strings with multi-line string (triple quotes)
Should, or perhaps could.
@@tj9382 Yeah, could were more appropriated
Good English speaking! 👍(hello from South Ural😉)
Excellent vidéo. Thank you very much.
This inspired me to create my own app, thank you very much.
Yeeeeey!!! Thank you Paulo, I'm super glad I've lighted an entrepreneur spark in you 😉
Let me know how your app turns out! 🙂
Hi. I love your videos. You are a very good programmer. Thnaks a lot from Colombia.
Very nice tutorial.
Love the content!
Thank you so much Oliver! 😊
Tnanks very great way to explain and great tutorial.
great presentation! Thumbs up 👍🏻😃
the best programmer of world :D i learn fast with you
You are helping alots people around the world. God bless you young lady
Beautiful teacher ( teaching coding ) very nice 😁😁😁 full attendance in class ❤️😀
Thank you - you are doing awwwwesome stuff! (And without music it’s so so much better - just a tip. For mus background ppl speech with music doubles the brain work)
Эх, красиво печатает😍
nice work, love the enthusiasm
Great video, nice teaching style.
This is so cool, thank you so much :)
Thank you B Gill, enjoy! 😀
Thank you , love your videos
Thank you so much Basel, enjoy! 😊
Great video!! Very helpful 🔥🔥
Thank you so much Blind Eagle! Glad you liked it! 😄
im very excied for your new vidwo. i AM big fan. #1. you are the best
Thank you so much D Elliot! 😊 I'm glad you're enjoying my videos!
thanks for all this work...Best regards.
You are simply amazing 🙌🏻
Mariya , Just in case no one has told you today , YOU ARE A GREAT TEACHER ! ... keep on being awesome.
Thank you so much!!! 😃😃😃
Wonderful thank you, 💕 it!
great video, thank you!
This sounds fun. I like to start my own channel. Could you share the tips/steps .. and specifically what tools (cam, software) are needed? Thanks
Excellent explanation, very useful
Thanks! I love your videos =)
большое спасибо Егор!!! 😁😁😁
@@PythonSimplified 😱😍
This video is made so great. 👌
Thanks for the amazing tutorial
You're welcome Sam! I'm glad you liked it! 😊
Hi! you have really good content. I´m using Qt Designer with PyQt5, so I dont have to build the GUI from 0 on. Is there any chance that you have a video using both together? I´m new in this world.
Thank you!
Nice work, amazing timestamps index
I simply turned fan! Subscripted immediately!!! lol
My english is not really very good, but you explain with clarity, calm and one form that is very easy to understand you!
Particularly, I would like to learn PyQt in a complete project. If it's possible you to make it, I'll be very thankful.
Best regards from Brazil
Muito Obrigado Luis! Thank you so much! 😀
I'm so happy you find my English easy to understand! I'm always trying to speak as clearly as possible to make sure nobody gets confused because of my accent hahah 😊
Did you have a chance to see the second part of this project? this will connect a Trivia questions database to the interface and complete the app:
czcams.com/video/r2ZN0mTDnPc/video.html
And then once you finished building it and would like to learn how to convert it to an .exe file, you can checkout another video of mine (much shorter this time 😅 hahaha):
czcams.com/video/Y0HN9tdLuJo/video.html
Good luck and welcome aboard! 😁
@@PythonSimplified ahahahah, you risked to write in Portuguese...Very Nice!
Yes, I'll see all videos and try to learn about PyQt becouse it's in my opinion the best and beautiful GUI for Python program.
Thanks a lot for your attention and care!
Please make more projects using pyqt5 designer you are a good teacher
A beautiful teacher that has beautiful contents
Thank you, I fell in love with Python
You're welcome Andrei! 😀
Python is the best programming language in the world!!! (but maybe I'm a bit biased... hahaha 😂)
@@PythonSimplified for data science maybe
@@silviudinca6501 how about automation? Artificial Intelligence? Python web apps? There's actually a vast world of functionality beyond data science where Python stands out as well! 😃
@@PythonSimplified 🤣🤣🤣🤣 Yes you are biased. Thank you for this wonderful video, though.
@@PythonSimplified yes. In Qgis script, Google earth engine script, beagle bone black board, so on..
These videos are excellent, really easy to follow along to, well thought out and interesting for green as grass beginners like myself. If i had one negative thing to say it would be to please take the mic off of the desk - im a headphone user and every keystroke sounds like a dubstep wub wub.
Thank you for the lovely feedback Dean! The sound recording for this video in particular is unfortunatley very bad! 😭 you could hear my computer in the background so I had to correct it with a bunch of filters - the result unfortunatley included horrific keypress sounds...
But the audio on other videos is a thousand times better!! this one is a one time oopsie! 😀
@@PythonSimplified I’m looking forward to part 2 of this one while I work through part 2 of the PDF extractor app you made. It’s actually turned out to be quite useful for work!
Nice to see greatings from every corner in the world. Little kisses out of Germany!
I agree, it's absolutely amazing how international we are on this channel! 😃
Hugs from Canada! (sorry, I'm not single enough to send online kisses to strangers 🤣🤣🤣)
@@PythonSimplified : That was just little kidding, didn't want to get u to personal. Its nearly 2pm in Germany and i'm melting my brain with this silly rats of permissions in Linux...
No worries,@@Team_BSE, I was also joking! :) I'm actually writing you this comment from my old laptop that was magically fixed with Linux and foam tape! :D I'm only beginning to discover how AMAZING this OS is (even though I'm struggling myself with all the "sudo" stuff and drivers 😅).
I really wish they had Adobe products available on it though, I can't fully give up on Windows until they do so... good luck with the permissions! :)
Thanks for the valuable lessons
Awesome!
Very well done. Nice video and excellent presentation.
Thank you so much Erik, I'm glad you liked my tutorial! 😀
Really interesting, Hello from Belgium !
I wish a PyQt6 tutorial now, wonder what kind of new stuff it can do Xd.
Muito obrigado Maria!
Awesome ....!!
Dare I say you are the better version of TheCodingTrain for me. They are a bit too advanced for someone just hopping on to their train. I love your format. You make programming less scary by using the simplest forms of the instructions and breaking them into separate lines.
QUESTION: you are hard coding the margins, padding and window size. Do you have any video on how to automatically scale the parameters based on the resolution of the end user's device? Or maybe if the end user tries to resize the window which then causes the various button to scale and squish together or expand depending on the window size, kind of like how CZcams video player does when you resize the browser window. Is that even possible to do easily?
Great video, great code. I just have one problem, after calling the start_game method in the button widget, when I try running the program, it only shows frame2
You are amazing!!!!!!!
Im doing something similiar to this but using a class, but i have a problem, my problem is when i have my grid layout setup my buttons dont have rounded corners like they should do, i do have some edit line widgets and they have rounded corners (they are like a text input) im using this to make a login form and id appreciate any help getting the style to work with my buttons,
Nice, I am learning a lot
All my years in python. I have never taken the time to learn PyQt till a client said he needs a desktop app. I love python.
Hahahaha I hear ya! PyQt is nothing short of magical! 😊
Trust me, you would have had a different opinion about Python GUI if you went the Tkinter way instead 😁
Doesn't it cost 550$?
Однозначно like!
Sposibo bolshoie Zahar! 😃
oh yeah i am SOO ready
With regards to the styling, you can also create a separate python file specifically for it right and just import them especially if your dealing with multiple styles for buttons or whatever widget?
you could use QStackedWidget to implement the "frames". Also a tripple quoted f-string could be used for the stylesheet :-)
Wait, triple quote strings can be f strings?
Nicely explained.
You are amazing!
Thank you!
Congratulations for +20k subscribe
Thanks. How deploy this app? Is it possible to have an executable file?
Very Cool!
Thank you Beppe! 😁
You look like Mary-Kate and Ashley Olsen ('Olsen twins') from the 90's tv show - 'Full House'. Anyhow, great tutorial, kiddo. 👍👍
hey~ I love your videos from philippines
Thank you Carlo! Greetings from Vancouver! 😃
Well explained!!!
Thank you so much! 😊
Thanks...needed an alternative for Tkinter. How about some threading in the future?
Hi Bob, good to see ya! 😃
I'm so glad you brought that up! Originally I was about to add some threading to this project (and I actually have a fully functional version of this app that involves a timer, where you only have 30 seconds to answer each question!) 😁 I didn't cover it because I didn't understand exactly what I've done to get there, left alone trying to explain it to others hahahaha 😂
But I can tell you for sure that this article will help you (at least in terms of Qt):
programming.vip/docs/pyqt5-multithreading.html
His code worked great for me (more specifically, the last example of the digital timer under QThread)
I'll definitely cover multi-threading in the future though! just need to learn it better before I do so 😉
THANK YOU