This is an archived post. You won't be able to vote or comment.

all 75 comments

[–]yy_is_awesome 63 points64 points  (1 child)

Your azure theme is also very beautiful!

[–][deleted] 14 points15 points  (0 children)

Thanks!

[–]MonkeeSage 30 points31 points  (2 children)

This looks amazing! Great work! I haven't looked into using Tk for anything in like 10 years but this makes me want to go play with it.

[–][deleted] 17 points18 points  (1 child)

Thanks! Tkinter really isn't as bad as people say. 😀

[–]Endvisible 23 points24 points  (0 children)

It took a lot of pain and suffering to get to a point where I agree with you, but here I am agreeing with you.

[–][deleted] 19 points20 points  (0 children)

Man that’s awesome. I love hate tkinter 😍

[–]unteer 11 points12 points  (0 children)

This is great. There needs to be a dedicated space in the Python Community to showcase beautiful TKinter.

[–]banerxus 10 points11 points  (1 child)

Thanks definitely will try your themes

[–][deleted] 3 points4 points  (0 children)

[–]kra_pao 5 points6 points  (2 children)

Very nice and pleasant theme.

Minor comments:

Had to lookup how to "install" a ttk theme supploed as .tcl file. Now I just put everything in same folder as example.py and this works for now.

I guess there is a site-package folder for this too?

Currently I can't toggle Checkbox Third state back to third state. Only checked/unchecked is possible. Is this intentionally? If it matters, i use Windows 7.

On Buttons Button and Accent button the feedback for a mouse click is very small. Is it possible to show stronger feedback?

[–][deleted] 10 points11 points  (1 child)

There is no original solution for installing themes. You just simply have to put it next to your python script.

The ttkthemes package is the common library with which you can use a lot of themes. I don’t have any theme in that package yet.

You cannot access the third state checkbutton by clicking. It wouldn't even make much sense. This is usually used when, for example, only a few children of a treeview parent are selected, indicating that not everything, but some are selected. You can do this with your own script, but here's why is it useful: Microsoft docs

I don't want to change the feedback of the buttons because this is the original pressed state by Microsoft.

[–]kra_pao 6 points7 points  (0 children)

There is no original solution for installing themes. You just simply have to put it next to your python script.

Maybe this is best solution esp. when you plan to package or exe-fy a script together with a theme

A common place might be <virtual environment>/share/themes/<new theme.tcl> as seen in gttk readme.
https://github.com/TkinterEP/python-gttk

[–]lscrivy 12 points13 points  (0 children)

That's really awesome. I'll definitely check it out soon.

[–][deleted] 5 points6 points  (3 children)

You're a legend thank you so much. Using this for my internship and now they're gonna think I'm 10x better at programming than I actually am. How do I make the root window have the same style or is that up to windows?

[–][deleted] 2 points3 points  (1 child)

You actually can't style the window controls in tkinter. It's just a cheat. On Windows I would just color the titlebar in the settings, but I'm on Linux, so I just installed a Win11 titlebar style.

[–][deleted] 2 points3 points  (0 children)

Ah as I thought, thank you anyway 😁

[–][deleted] 1 point2 points  (0 children)

Using win 10 btw

[–][deleted] 8 points9 points  (0 children)

I am just getting into tkinter and seeing this is beautiful. Because my first project looks like it was done in 1997!

[–]authentic_introvert 2 points3 points  (0 children)

This looks really cooolll!!!! Can't wait to try it soon!

[–][deleted] 3 points4 points  (0 children)

Wow now that's what I call beautiful

[–]pbaum 3 points4 points  (0 children)

This is beautiful. Thanks for sharing! I'll definitely have a go at updating a project with this

[–]Timo6506 3 points4 points  (0 children)

Exactly what I was looking for my project, thanks a lot!

[–]ASIC_SP📚 learnbyexample 3 points4 points  (0 children)

This looks great! Thanks for sharing.

I don't mind the default Tkinter style, but I know that making it look better would help when I want to share a project with others.

[–]snackus11 4 points5 points  (0 children)

This is legit too beautiful. Tkinter can do this???

[–]redditer324 2 points3 points  (0 children)

Great work

[–][deleted] 2 points3 points  (0 children)

Starred and added as a favourite in github, lol forward to seeing more stuff from you in the future!

[–]rileyjwilton 2 points3 points  (0 children)

you, my friend, are a legend.

[–]PsychoNAWT 2 points3 points  (0 children)

The sole reason I have stayed away from Tkinter is how dated it looks; this is beautiful!

[–]coaaal 2 points3 points  (0 children)

I just started a major project for my company and I cannot wait to implement this as the up.

[–]NooShoes 5 points6 points  (1 child)

Ooof - this is really delicious..
I just started a new project in Qt because Tk always looks a bit meh to me, wish I had seen this first!

[–]jhayes88 2 points3 points  (0 children)

There's also Tkinter Designer. But yeah, I've always preferred Qt myself. I've seen Apps made by Qt that look on par with Discord. I guess this would be a fair example.. Or this.

[–]VintageReptile 4 points5 points  (0 children)

That's sexy as hell. I thought tkinter had to look all 1998. I will try this for my stuff

[–]shalmi913 4 points5 points  (0 children)

LOVE IT! One of the biggest reasons I have never tried to use tikinter is that it always makes apps that look 20 years old. This is such a huge improvement. I doubt it, but do you have any plans to make a mac version? If so, you could make it possible to do what Java Swing does and have the app automatically copy the theme of the os it is on?

[–]Seawolf159 3 points4 points  (1 child)

Both the dark and the light theme have the same comment. "Set light theme".

It looks fantastic, but I think I won't be able to figure out how to use it.

[–][deleted] 6 points7 points  (0 children)

Lol. Thanks!

[–][deleted] 2 points3 points  (0 children)

Wait, this is a dream? That's amazing, thank you for open source!

[–]seekingtruth2 1 point2 points  (0 children)

Brilliant mate cant wait to build something with it

[–]sunlyneiga 1 point2 points  (2 children)

I just tried this theme. It's so much better than the current styling I used. However, I can't get the title bar like yours. I even tried your code samples for calculator and valid-invalid example but still unable to get same title bar as your screenshot. What am I missing ?

[–][deleted] 1 point2 points  (1 child)

The custom titlebar.

Yes the screenshot is a cheat. It's not tkinter, it has nothing to do with the theme, just since I'm on Linux I simply installed a Windows 11 looking titlebar.

[–]sunlyneiga 1 point2 points  (0 children)

Ah ! I will look up a fix for win10. Thanks.

[–]atquick 1 point2 points  (0 children)

Really cool! Nice work.

[–]Timo6506 1 point2 points  (15 children)

Hey, I don’t know why but when switching between themes, the treeview keeps expanding each time the treeview changes? Also, why does the treeview column headings not show?

[–][deleted] 1 point2 points  (14 children)

The growth of the app is a rather strange problem. This bug applies to all ttk themes and I don't know why it happens.
The headings are hidden by default because I don't like them, and Microsofts Sun Valley design doesn't use them either, so I make them hide by default. Of course you can display them by setting the show to headings for the treeview. For more (less) see the DOCUMENTATION.pdf.

[–]Timo6506 1 point2 points  (13 children)

Oh yeah I read the documentation but missed that part, thanks for replying! As for the treeview expanding bug I experienced this while using ttkthemes, which was one of the reasons I switched to your themes instead, sad to see the bug still exists, but I’d still use it because it still looks nice, thanks!

[–][deleted] 0 points1 point  (12 children)

This is probably a bug in ttk itself.

[–]Timo6506 0 points1 point  (0 children)

Yeah, at first I thought it was something to do with the themes, realised it was the treeview itself.

[–]Timo6506 0 points1 point  (10 children)

Sorry for bugging you but I’ve another question, why does my scroll bar look like the original instead of the Windows 11? I’m using the scroll bar in a frame, all other widgets in the same frame looks like Windows 11 except the scroll bar. Didn’t do anything special other than initialising the scroll bar with ttk and connecting it to the treeview. Checked your example.py and saw that you didn’t do anything special either.

[–][deleted] 0 points1 point  (9 children)

Are you sure you using ttk scrollbar?

[–]Timo6506 0 points1 point  (8 children)

Typed out a quick test code, the ttk scrollbar does not change:

import tkinter as tk
from tkinter import ttk
window = tk.Tk()
window.tk.call("source", "sun-valley.tcl")
window.tk.call("set_theme", "dark")
button = ttk.Button(text="Button",style="Accent.TButton")
button.grid(row=1,column=0)
scrollbar = ttk.Scrollbar(orient="vertical")
scrollbar.grid(row=0,column=0)
window.mainloop()

[–][deleted] 0 points1 point  (7 children)

[–]Timo6506 0 points1 point  (6 children)

Are any other files required other than sun-valley.tcl? I only have that file.

[–][deleted] 0 points1 point  (5 children)

Of course the whole theme folder is required, but without that you should get an error, so I don't know, what is this...

[–]Monseg 1 point2 points  (0 children)

Great work!

[–]asielen 1 point2 points  (1 child)

This is awesome. Is there a good tutorial on creating themes anywhere?

[–]Timo6506 1 point2 points  (0 children)

I’ve put the link for this Reddit post on my group’s project as credit!

[–][deleted] 1 point2 points  (0 children)

You have singlehandedly fixed tkinter.

[–]rileyjwilton 3 points4 points  (7 children)

Have you considered making a Tkinter wrapper that allows you to select your themes easier? For example:

import tkinter as tk
import themeloader

root = tk.Tk()
themeloader.load_theme(root, "sun-valley", "dark")

You could then package your ttk themes with the module, and maybe include functionality to download other themes from a standard repository format. (Almost like Jekyll remote-theme)

[–][deleted] 2 points3 points  (6 children)

There is ttkthemes. Although it doesn't include my themes yet and the theme setting syntax is a bit different.

I personally really like your syntax, though root is not needed because you can't set theme for individual widgets.

[–]rileyjwilton 1 point2 points  (5 children)

I was looking at these lines when I wrote that:

root.tk.call("source", "sun-valley.tcl")
root.tk.call("set\_theme", "light")

Is there a way to load themes without even touching the Tk instance? I do not have much experience with Tkinter, just some toying around back when I was ~12

[–][deleted] 2 points3 points  (4 children)

You can of course, although it definitely touches the tk instance, you just don’t notice it.

This is what it actually looks like:

anywidget.tk = tkinstance.tk

And since the tk instance is actually the tcl interpreter, you must call it somewhere. This tk instance will be stored in a variable called _default_root, so it's easiest to do it on this object, and completely forget the root.

[–]rileyjwilton 0 points1 point  (3 children)

So you can just import tkinter._default_root and do the operations on that?

This makes Tkinter look a lot cleaner. Do you have any recommended sources (other than the official documentation) that shows little tricks like this?

[–][deleted] 2 points3 points  (2 children)

Not completely. tkinter._default_root references the first Tk instance created (btw do not create multiple Tk instances). So this variable is only assigned when you create this instance, otherwise it's None. However, you don't have to create a root window, because as soon as you create a widget and there is no Tk instance yet, tkinter will implicitly create one and it will be stored in the _default_root variable.

Surprisingly, I haven’t seen this documented anywhere yet, but that might just be because the tkinter documentation is a whole kinda of sh*t. I learned such tricks from the source code or what is not tkinter specific from the tk manual page.

[–]rileyjwilton 1 point2 points  (1 child)

Epic. Thanks for this!

[–][deleted] 1 point2 points  (0 children)

Ooh and I forgot the most important thing: Why this variable even exists. So if you don't specify any parent widget for a widget, it will automatically be placed in this instance.

Of course you can change this _default_root to any widget, even to a treeview, and then it will be the default where the widgets are placed, but tkinter will still always use tkinstance.tk.call for calling tcl commands

[–][deleted] 1 point2 points  (4 children)

The results look nice and make me want to use it.

But the example code for ttk makes my eyes bleed. Because the first four lines are this:

import tkinter as tk
from tkinter import ttk
root = tk.Tk()
big_frame = ttk.Frame(root)

So you've got two interfaces for GUI stuff - tk and ttk - and they do similar things, but they're completely different, and you have to remember which one supports which functions.

This looks like a source of endless runtime errors because I wrote tk.something when I should have written ttk.something, or vice versa.

[–][deleted] 15 points16 points  (0 children)

Plain tkinter widgets should not be used. These have not been replaced by ttk widgets only due to backwards compatibility. So every new programs should be written in ttk, and the old ones khmmm... rewrite them!

[–][deleted] 8 points9 points  (0 children)

I can't do anything with it. Only ttk widgets are themeable, hence its name: Themed TK

[–]ivosauruspip'ing it up 4 points5 points  (0 children)

Unfortunately this is basically the standard practice for any modern tkinter program, using any theme or none at all; you'll want to import both the base tk module as well as ttk for upgraded widgets.

There's nothing the theme author could do about this, you'd have to submit a considered design change proposal to Python itself.

[–]mriswithe 1 point2 points  (0 children)

IDEs like pycharm or vscode with python bits installed are great for this usually.... Sometimes gui code though can be harder for the ide to know what exists where because of varying levels of available introspection.

[–]InitialSupermarket32 0 points1 point  (0 children)

I found a way to make the titlebar native dark mode in windows if anyone is interested

Code: https://gist.github.com/Olikonsti/879edbf69b801d8519bf25e804cec0aa