Drop downs and styles - PyQt with Python GUI Programming tutorial 10

sentdex · Beginner ·🛠️ AI Tools & Apps ·11y ago

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 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
47 3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

Related AI Lessons

Up next
Salesforce Flow New Features (Summer '26) | Open Record, URL & Show Toast Messages
AITECHONE
Watch →