Education logo

Beginner's Guide To Python's GUI Library Called "Tkinter"

Basics every python programmer should know

By Alex SmithPublished 11 months ago 3 min read
Source: Yandex Photo

In this article, we will try to cover everything beginners need to know about Python's library for creating desktop apps called Tkinter.

What is Tkinter?

Tkinter is one of the common libraries which allows users to create desktop apps using Python. It provides resources to create buttons, text boxes, lists, and so on. Officially, these elements are called widgets, but I call them elements, you also can call them however you want.

Now, let's walk through them.

Button

As its name says, it's just a button. You can set its width, height, text, color, and of course, its function.

Function "execute_message" doesn't exist, therefore I got a warning

Label

Basically, it's just a field where you can set an information, both textual and visual(not videos). But, you can't set a command to it.

Entry

This widget allows users to type in a text. But it won't fit for novel sized texts, as it has only one line(you can't control height, only width), so it will go for email, or password fields.

You can also set a font style and font size

These were the most used and significant widgets in Tkinter, and I have a task for you: make an app where user types a text in entry, and when button is clicked, entry's value will be on label.

Text

Next widget is Text. As its name says, it's a text box where you can write your lovey-dovey novels). You can set its width, height, font, background and text color, and so on.

Theme's name is "Dark Satanus". Only for Visual Code

Radiobutton and Checkbutton

You could see these two when signing up or taking online quiz. These two are a bit tricky, as they require using Tkinter's special variables(IntVar, BooleanVar, etc), especially Radiobutton.

I told you it will be tricky!

Messagebox and Filedialog

These two are not widgets, but separate libraries which are inside of Tkinter library. Don't get confused, it's a common thing in Python.

  • Messagebox

This library simply creates a pop-up message with info, error, warning, and so on.

I mostly use this trio
  • Filefailog

This library is used to save/edit files on user's computer.

It's how you save a text in certain file.

Honestly, writing is a bit tricky for me

Listbox and Combobox

These are the widgets that create a list in your app. Between Listbox and Combobox, latter is easier to use and build(objectively).

Important fact, Combobox is in separate library called ttk, which is inside tkinter library.

  • Listbox
    • Combobox

    Pack, Grid and Place

    I suppose you noticed that pack() method in every code example. Well, with this method, you place the widget on the screen. Without it, your app will be empty. However, pack() is not the only method to place widgets in tkinter. There are two more, these are grid() and place().

    • Grid()

    For me, it's the second most popular method to place widgets, as it allows you to easily understand how widgets stand on screen.

    Key difference of grid() from pack() is that you need to give it a couple of arguments, mostly ones called row and column. Except this, you can also state how much place can take.

    • Place()

    This method can be used to set exact position for widgets. Its main arguments are x and y. To work with this method effectively, users better be able to imagine how widget will look like in chosen coordinates, so widgets won't overlap or look odd.

    Methods to control window

    In place() method's example, you could see core.geometry() method. To simplify, this method allows you to change window's size. Additionally, you can also set wether window can or can't be resized. It's done by main window's resizable() method.

    I personally use only these two methods.

    Conclusion

Well, I suppose the material I've gave you in this article is quite enough to keep learning and creating your own wonderful apps. Keep searching, working and practicing.

And for now, good bye!

listteacher

About the Creator

Alex Smith

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2026 Creatd, Inc. All Rights Reserved.