DEV Community 👩‍💻👨‍💻


Posted on

Use Tkinter to make a Python GUI?

There are many GUI modules for Python. One of them is Tkinter. So what about Tkinter?

Maybe. If your program doesn't need complex GUI widgets or a native GUI.

If you need many widgets and native operating system look, it may be better to go with the PyQt5 module.

Tkinter has been around for a long long time. It contains the basic widgets

  • Button, Checkbutton, Menubutton, Radiobutton
  • Canvas
  • Entry
  • Frame
  • Label, LabelFrame
  • Listbox
  • Menu ... and so on.

So you can build basic GUI interfaces. But it doesn't have an enormous list of widgets.

On the other hand, it has an easy learning curve. The hello world program looks like this:

import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master=None):
        self.master = master

    def create_widgets(self):
        self.hi_there = tk.Button(self)
        self.hi_there["text"] = "Hello World\n(click me)"
        self.hi_there["command"] = self.say_hi

        self.quit = tk.Button(self, text="QUIT", fg="red",

    def say_hi(self):
        print("hi there, everyone!")

root = tk.Tk()
app = Application(master=root)

Related links:

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Just kidding, it's a personal preference. But you can change your theme, font, etc. in your settings.

The more you know. 🌈