Drop downs and styles - PyQt with Python GUI Programming tutorial 10
Skills:
AI Pair Programming80%
Key Takeaways
Builds a PyQt GUI application with drop-down buttons and style changes using QT GUI toolkit
Full Transcript
what is going on everybody Welcome to the 10th python with pqt video series tutorial in this video what we're going to be talking about is adding a drop- down menu but also or a drop- down button rather and also changing the style of our window so that's actually what our drop down will be it'll be about the style of the window and users will be able to choose different styles for their window so let's go ahead and just Jump Right In so we're going to add this style this button we'll do it to home we could put it in the in it this one it would make a little sense maybe to put in the in it but since this is a button like if you were going to have something that changed the style you'd probably have it in the main menu but I want to show you a drop down menu or a drop down button I keep calling it menu if I was showing you drop down menu we put it in the main menu I want to show you drop down button so I'm going to put it in home because that makes the most sense but really if you were going to change style you'd put it in the main menu and you'd have it up here but it's a tutorial I'm trying to teach a drop down but button shoot killing two birds one stone so coming down here we're just going to add some more stuff and we're going to say self. style Choice uh style Choice equals QT gooey. Q label now we haven't actually even shown labels yet but here you go and uh first we'll start with just windows and actually I believe mine will be Windows I'm on Windows 7 but I think the default is actually Windows Vista uh you can put whatever you want in here it does not really matter you I'll show you actually how you can find out what you're using uh so we'll pass self so to find out exactly what the default style is what you can do is you can just we'll just print it out print um self. style empty parms doob name camel case that object name and that'll tell you the style you're currently using I'm almost positive mine actually uses Windows Vista even though you're on I'm on Windows 7 now now that we've done that we're going to create what's called uh the Q combo box but the combo Box means a drop down button so anyway combo box equals QT gooey. Q combo box self um then we're going to say combo box. add item and now we're going to add all of the various items now there's uh there should be about six maybe some more some less depending on what operating system you're on but add these if they don't exist it won't like crash or it shouldn't at least it didn't for me it just won't change your style so you have some choices there's Motif and then there is uh regular windows then there will be uh CDE and then there is plastic and then you've got clean looks actually it's not C case clean looks like that and then Windows Vista I'm kind of a fan of the clean looks but whatever so now that you've got that added what we want to go ahead and do is let's move our combo box so we're going to say uh combo box. move we're going to move it to 5250 that should be good self. um and then we're going to say uh where did sty choice right itself. style choice uh. move we'll move it to 5150 and then we're going to say combo box. activated so this will be like the default um and it also it'll display what's uh activated so we'll say string.c connect and then we'll connect to self. um this I'll throw me for a loop uh we'll be fine actually style underscore Choice like that so once we've done that we're going to come down here and we need to Define our method of style choice so this is all the gooey aspect stuff so the combo box placing it and showing the current value other than that what we need to do now is create the method which is actually going to do something with the choice so Define a style Choice whoops and we need to pass self then what do we want to do well we're going to say uh self. style Choice dot uh set text uh to text so St let me go back up here right so this will set our text so self. style choice is just the label that is saying what it is and then the button should also say it as well but we're just going to show labels really quick too uh see self dots where am I style Choice that's self. style Choice set text text and then we're going to say qtgui doq application. set style and we're going to set this Style to qtgui doqs Style Factory factory. create text okay so what this does is it just sets the style of your guey to whatever there's certain types of Q style factories and those these are the types here the major types but again you might have something like you might have like Macintosh right if you're running a Macintosh you have that style and it's probably your default uh but otherwise you generally everyone will have at least uh not Windows Vista but everyone should have these for sure anyway uh that should be it unless I messed up and because we call in a lot of things sty choice here so it's totally possible I screw something up let's run and find out so here is our our choice Windows Vista right now Motif is the one that's selected we need to we should probably move that up but anyway let's click on Motif H there we go uh text so okay so obviously um let's go text let's close this self style Choice obviously needs the text parameter try one more time there we go okay so you can see here when I clicked windows that changed we can do the download and you can see that's a little different you can check the boxes here you can see that's a little different and even like moving this thing around you can see that things are just it's just acting quite a bit different got Windows CDE is like an old school kind of look uh very basic and then you've got things like plastique plastic is pretty cool I like that plastic might be the one I was thinking of actually that I prefer um and then clean looks yeah I like clean looks too they're kind of close I suppose and anyway and you can like move these around so you can kind of decide which you like better uh as far as all these variations so you personally can kind of come through and uh you can change the default style so these these Styles should go with you like like plastic Motif CDE uh and clean looks these are all possible to uh move cross platforms so if you wanted it to look like this all the time then you would use plastique you would just need to reset that so it doesn't use the person's default style otherwise everything else pretty much Remains the Same all the code Remains the Same and stuff like that but there's like a lot of little minor changes I think things look a little better with plastic you know I just can't tend to like it but plastic or clean looks are probably the best um but I like this one a lot especially because it has it adds a scroll bar when things are a little too small as opposed to like clean looks which didn't it just like stuffed them all in there that's funny uh anyway uh that's that if you guys have any questions or comments up to this point please feel free to leave them below otherwise as always thanks for watching thanks for all the support and subscriptions and until next time
Original Description
In this PyQT4 GUI application development tutorial, we cover drop down buttons as well as quick style changes based on various themes.
sample code: http://pythonprogramming.net
http://hkinsley.com
https://twitter.com/sentdex
http://sentdex.com
http://seaofbtc.com
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
More on: AI Pair Programming
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
This ChatGPT Prompt Replaced 3 Hours of PowerPoint Work
Medium · AI
This ChatGPT Prompt Replaced 3 Hours of PowerPoint Work
Medium · ChatGPT
How AI Assist Turns a Rough Draft into a Polished Document in Minutes
Dev.to · paperquire
13 ways to make money with AI in 2026, ranked by how fast you will see your first dollar.
Medium · AI
🎓
Tutor Explanation
DeepCamp AI