Modern GUI using Tkinter

Fareed Khan
4 min readSep 4, 2022

--

There are two things to remember:

  1. If your idea is new that never existed before, a beautiful user interface (GUI) is not required. People will use your product without hesitation.
  2. If your idea is old, then a beautiful user interface (GUI) is what makes them stick to your product.

Tkinter is one of the most widely used libraries for creating Desktop Applications in Python, many developers find it easy to use, but the main problem is it requires a lot of time to create a beautiful GUI. I will show you how you can create a beautiful GUI in Tkinter without much code.

In case you want to know how you can create a desktop application using the Flask Web framework, here is the link to that blog:

I am going to demonstrate the features of a library created by Tom Schimansky, which gives you the ability to create a beautiful GUI in Tkinter, so you can focus on the backend coding rather than frontend.

Here is the link to that repository for future learning:

https://github.com/TomSchimansky/CustomTkinter

Here is the link to their official documentation:

https://github.com/TomSchimansky/CustomTkinter/wiki

A quick demo of what some basic components look like when you use this library to build the front end of your Tkinter App.

Dark Theme

Light Theme

First, you need to install this library name CustomTkinter, using the pip command

pip install customtkinter

as stated in their official documentation:

(Update the library as often as possible because it is under active development)

Here is a very basic Tkinter app:

Now we use the Custom Tkinter library, these changes occur in our previous code:

Instead of creating a root window using Tkinter, we create it using the Custom Tkinter library

Creating Button using Custom Tkinter

The only difference here is the root window that is defined by specifying the master parameter.

The rest of the code remains the same

This is the complete code of the app

This is the output

If we want to create this GUI using Tkinter, it will take time to create a style for both button and background, but with custom Tkinter, we didn’t change much code and were able to create this beautiful UI within a minute.

The default theme for custom Tkinter is system defined, which means the theme you are currently using on windows or mac, if you want to specify the default theme of your app you can do this by specifying the set_appearance_mode property right before creating the root window:

Set_appearance_mode takes three values

  1. System (whatever user operating system theme is)
  2. light
  3. dark

You can change the color theme for all the components of your app by specifying the set_default_color_theme property

We choose green for all our components i.e., buttons, scrollbar, etc.

Custom Tkinter offers a variety of possibilities for Tkinter widgets to play around with.

The following widgets are supported in Custom Tkinter:

You can go through the examples they have in their repository,

Here is the demonstration of a complex example.

Link: https://github.com/TomSchimansky/CustomTkinter/blob/master/examples/complex_example.py

If you have queries feel free to ask me!

--

--