Styling GUIs and windows in Python 3 - Tkinter tutorial Python 3.4 p. 5

preview_player
Показать описание

This tkinter tutorial with Python 3 covers how to customize the look of your GUI, using ttk. Ttk allows us to not only customize the windows and gui, but also comes default with a more familiar look and feel as is typical with your operating system.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

Thank you for making these, I'm an A level student struggling with my Computer Science project. I've watched hours of tutorials but yours have been the most comprehensive and useful. Had no idea what ttk was before this video.

NeilLTayler
Автор

This guy is probably the #1 Python trainer on the web IMO. His depth of knowledge and teaching style are top-notch, yet he's humble enough to admit that he picks up tricks from other programmers. Thanks Harrison, your work is top-notch and I am sure that we are ALL grateful for your efforts.

pb
Автор

For those of you who may be trying to follow on other operating systems,
to make this work cross platform add "from sys import platform", then add:

if platform == "darwin":
icon = "clienticon.icns"
elif platform == "win32":
icon = "clienticon.ico"

then change tk.Tk.iconbitmap(self, default="clienticon.ico") to read:
tk.Tk.iconbitmap(self, icon)

Note: tk.Tk.iconbitmap(self, default="clienticon.ico") will throw an error on OS X

Thank you sentdex for these really really great tutorials, and thank you so much for explaining things and adding the "why?" to the explanation!

garryhurst
Автор

Thank you for this. I'm new to both tkinter and python and I was struggling to make this happen using classes. Great tutorial.

frangomezvet
Автор

for those using python 36, delete the default = and just have self, "favicon.ico" in your parentheses. to change your icon, go to ms paint, resize, and then when saving just add a .ico to the end of the name of your icon. I am on windows 7.

smahns
Автор

i know this is like 4 years late but buddy thank you

Alan
Автор

First of I want to thank Harrison for putting this material on-line for us to learn!

For me changing the icon didn't work until I assigned the default parameter without specifying the word default. As long as I put in default it will go to the default icon no matter what I assign to default. So, the code that worked for me is: tk.Tk.iconbitmap(self, "icon.ico")

wouterdroog
Автор

Thanks for making these videos, they've been really helpful!

capsandnumbers
Автор

For Windows users, there's a plugin for Photoshop that lets you save as ICO (and CUR for custom cursors, bonus :) ). It works for both 32 bit and 64 bit and goes from Win98 all the way to the latest version. I'm surprised that it's still being developed, since it's such a simple script, but apparently they've kept it updated for 2 decades now...

I'm not sure how to get the icon for Linux or Mac, if those even have icons...

morphman
Автор

If anybody wants to use other formats instead of .ico for your icons you can try using this code. You have to keep the png file in the same folder.
Use your image name for icon1

icon = PhotoImage(file='icon1.png')
self.tk.call('wm', 'iconphoto', self._w, icon)

AndyDamb
Автор

This helps me quite a bit. By the way, I am using python 3.4.1 for doing work like py GUI.

xanderlim
Автор

For those who are still watching this in 2015 -> you can easily convert images to icons using infarn view.

vk
Автор

hi, this is working with Win OS but if I try it in Mac OS, I get this error:
line 1714, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, '-default', default)
_tkinter.TclError: wrong # args: should be "wm iconbitmap window ?bitmap?"

Any idea? thanks

lucprog
Автор

hello sir,
i try (ttk) but it just changing color but not changing it into a button shape like you.
did you changed something in ttk.style?

ochanamirja
Автор

Im new to programming, I chose python bcause it is great programming language i've ever studied at glance, and I always following each of your tut video, its awesome. I wonder if I am able to study it from u directly sir.

biimsstudio
Автор

Is this only to display information and flip through frames? Using an MVC approach I think this tutorial would not work. This seems like methods can only be created using the set Frame. Which is the StartPage. What if you have a Login and Register page. How would you implement this using an MVC approach?

timtech
Автор

How to add a background color in this object-oriented approach. Most of the things I found online were not working for me.
for ex, i added

container = tk.Frame(self, bg="#2196F3")
this is not working.

MrBunny
Автор

To get this bitmap method to work on linux I needed .mbc files which looked nasty and B+W. After some searching I got this to work for gifs.

icon =
self.tk.call('wm', 'iconphoto', self._w, icon)

Jigatree
Автор

I've used tk.Tk.iconbitmap(self, "./filename.ico") and worked, if I use tk.Tk.iconbitmap(self, default="filename.ico") it doesn't. The icon file is in the same app's directory. Any tips why it does that?

AndreNL
Автор

I keep getting icon.ico is undefined but I have triple checked I have everything typed exactly as you do.

desirays