wxPython Programming Tutorial 7: Adding Static Text and Colors
Key Takeaways
Demonstrates how to add static text and colors in wxPython programming
Full Transcript
hello and welcome to your seventh WX Python tutorial in this tutorial we're going to be working on some customization of this window most notably in the panel and as always we want to do this with a bit of interaction with the user since that's what it's all about these days is user interaction and customized ability based on the user so if you don't recall where we left off was here that's their name and s if they enjoy and then it asks them what their favorite color is they click that and up pops in this window so now what we want to do is like this text box is in what is known as the panel and like this kind of area right here is our panel and so this text box is just within the panel so let's exit this window and what we're gonna do first is change this panel a little bit first let's move the panel down because generally just like we did with the buttons you want all your button information kind of grouped all your customizable stuff that's happening back to back I think you want that group so you can kind of find this stuff over time when you're coming back to change up your program or whatever it just helps to have it groups so we're gonna put the panel stuff actually down here now the other thing we'd like to do let's go ahead and make room for some text that we're going to put on so we're gonna change the position of this panel instead we're gonna put it at 3 and a hundred and then we're gonna change the size so let's do like more like 150 and 50 so it'll be kind of long and short and so now what we're gonna do you'll see it will bring it up in the program just a second if you can't visualize that so now let's put something else in our panel so let's call this awesome awesome text but we'll just do our text for short equals W X dot static text and within the parameters you're gonna have basically four and the first one we're going to say panel and then we'll do negative one for the ID then you'll have awesome text is what will have that text say and then you finally you have the position of it and so you don't want it to conflict with this text panel that we have so that's why we move this text panel down it's down a hundred pixels so we got plenty of space but this text will put this text where at three three so it'll be three pixels over and through pixels down so if we run this now you'll see that we have awesome text here but let's be honest with ourselves that text really isn't that awesome so let's apply some colors to that text so we'll come down here and the way you do this is you do aught X obviously then you're gonna set the foreground for grant oh my goodness can't type foreground color set for grant let's make sure we did that right yep and then we'll set that color to yellow then we'll do the same thing we'll set a background Oh text got set background color and we'll set that background color to black okay so we'll save that we'll run it and up pops this window and now you can see you okay the text is looking a little more awesome now I'll you graphic designers out there I'm sure you were like okay okay but can we put hex color codes in there yes you can so not only can you like spell out the colors you can put the hex codes in there so let's do kind of like a light blue we'll save that and we'll run it and just you just put the hex color code within the parenthesis so it's a string itself and now you see okay now our awesome text it's this light blue on top of black so yes you can do hex color codes as well so you have you know any color you could possibly want and put in there so that's really cool but I bet you guys want to take it a step further and let's make this text like truly custom text based on user input and what better way to color our text than to color the text the same color that the user chose so let's do that real quick so we'll call this really attack so for really awesome text that's gonna be W X dot static text same thing as before it's gonna go in the panel it's ideal just be negative one and then we'll call this customized awesome miss then we're gonna say it's location will be same three pixels over but just so we have plenty of space we'll do it 30 pixels down now what we want to do is we'll say really awesome text equals W X dot static or I'm sorry it's really awesome text dot set foreground color and within these parentheses you can put the users see we save this as fav color and fav color is just corresponding to a string so we can just literally take fav color and copy and paste that variable right on in there and then the same thing before let me just copy and paste this and so we'll do really awesome text and then we paste set background color we'll still have that be black so now when we run this okay you said Harrison yeah I enjoy it now I can pick any color we want so let's say we want green so now we can see okay the customized awesomeness is green but what if we want a different color let's choose up red now it's red text so now that we've added a little bit of color I think that especially nowadays you know in the old days just having like the most basic GUI was like oh but this GUI nowadays is pretty disgusting so we're gonna continue building on making the GUI just maybe a little bit more appealing to somebody so I hope you're looking forward to that as always thank you for watching and thank you for my subscriptions it really helps to see like the people that support me so thanks for subscribing and until next time
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 · 10 of 60
1
2
3
4
5
6
7
8
9
▶
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
🎓
Tutor Explanation
DeepCamp AI