wxPython Programming Tutorial 8: Custom Button Images
Key Takeaways
Adds custom button images using wxPython
Full Transcript
hello and welcome to your eth wxpython tutorial uh in this tutorial we're going to be talking about how to add a little bit more flavor um to your windows and in this tutorial we're going to be most specifically talking about how to give buttons uh a bitmap image um this way just looks more appealing maybe although I will just add that my buttons aren't exactly the most appealing buttons ever but regardless that's what we're going to do so before this video I made a quick sadface PNG image um which we're going to use for the exit so when the user goes to file and exit uh like right now we run this program and the window here you know we got awesome text this is cool but you know the user is like uh I got other stuff to do file and then exit it's just so easy they just hit exit and they're done so what we want to add is a little something something there to maybe um convince them why don't you just stay a little bit longer so uh let's hop into it the first thing I want to do is rearrange a few things again uh most notably let's bump this down because we're going to be changing this and also I would just like to change uh this as well to do if you're going to uh edit the button in any way it's usually easier to do it uh this way and so just follow with me edit item now we're going to change this to just be um WX do menu item so we're just giving it the uh WX Python's mode of being a menu item already and then what we're going to do is Define it a little bit and first you say where it's going to go and it's going to go under the file button then we give it its um ID and in this case it's just going to be the ID exit so it's going to have the exit parameters that WX python presets and then finally it's got the um you know whatever you want it to say so in this case it's going to say quit now um the next thing you want to do is you'll want to give it its image so in this case you'll do X item or whatever you've named yours uh set bitmat and then in parentheses here the only parameter is the location so we're going to say WX bitmap and then in parentheses uh you give the location of this if it's in the same directory then you just straight up put the file name if it's not in the same directory then you'll have to give you know the full PA secon slash blah blah blah blah blah blah blah slash okay um but in my case it's in the directory generally if you um ship out anything or you install something on someone's computer it's going to be in the same directory anyway but if not give the full path so next um now that we've done that the only thing we need to do uh is do file button and we're going to pend uh this exit button or exit item to the button so exit item or pend item exit item and that should be it hopefully we haven't typoed or screwed anything else up so let's save it and run it see what happens and so here is our window and we go to file and now they got a a sad face when they go to quit now um something you'll notice with a lot of Windows like if we look here at this python window new window is crln open is crl O and then obviously like exit is contrl q now when we come to our window um you can't see me but here I'll hit control Q nothing's happening if you can hear I'm getting like a the windows notification that whatever I'm trying to do isn't working so control Q doesn't really work for me here but what you can do to set uh control Q to work it's actually pretty nifty you literally just type it in like you do ctrl+ q and I did like a little tab before so this back slash uh t means Tab and then I said I just strictly just said controll Q nothing else we'll run it and I just suggest you run this alongside me so you can just instead or you can just take my word for it um and then now when you go here and you look at the button it says contrl Q there but even if you're not even using it and then you hit control Q it'll close and you might be thinking well that's probably just cuz it like recognizes everything and so if you just have any parameter there maybe it does it but you can change it like you can say contrl p which normally corresponds to print but in our case if we do this we'll run it and here's our window again and it says contrl P there I'm going to just again you can do this yourself or take my word for it contrl Q is not doing anything but if I do contrl p sure enough it closes finally you can also just not have a parameter in there at all for like how to close it and instead you could be like don't and then back slash to escape the uh uh the single quote there so don't and then don't do it like that right so we'll put that in there we'll save that we'll run it and here's our window and now when they go like this it says don't do it right by the quit but if so now if I do contrl Q still nothing contrl P still nothing so you can really put anything you want in there but if you do say contrl uh P or control Q or whatever it'll also act like short keys and like that's just kind of coded into WX python again one of those things that takes a lot of coding for them to just you know be like okay if they happen to put control in here so anyway really cool stuff okay so anyway that's it we'll quit uh the program there and so that's the basics to adding little icons by like menu items and now what we're going to be talking about briefly is a toolbar and in case you haven't guessed it you can also add little images for the toolbar so stay tuned for the next video and toolbars and as always thank you for watching and subscribing
Original Description
Full Playlist Link: http://www.youtube.com/playlist?list=PLQVvvaa0QuDc4SQhfpm6XHO0l-1Ybtur2
Code for this tutorial can be found on Sentdex.com
Sentdex.com
Facebook.com/sentdex
Twitter.com/sentdex
How to make graphical windows for user-friendliness within python, using wxPython!
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 11 of 60
1
2
3
4
5
6
7
8
9
10
▶
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
🎓
Tutor Explanation
DeepCamp AI