Learn to Code via Tutorials on Repl.it!

← Back to all posts
A very short intro to GUIs in Python with Tkinter

Okay, so I need to make a tutorial.

Let's discuss Tkinter.

What is Tkinter?

Tkinter is a module in python for creating GUIs.

It is built in to python so you don't have to use pip3.


Just use repl for now and make a Python Tkinter repl.

At the top type:


So Tkinter is a widget-based GUI engine.

Meaning everything is a widget.

So you can have text, button, label, ect. widgets.

And this all exists inside you root widget.

Or your window widget.

Creating a window.

To create a window type this code:

So we define a variable as a Tk object called root.

This Tk object is the Tkinter object for root widgets.

If you run you will notice a window!

Adding text.

To add text type this code:

So, we import tkinter.

Then we define our root.

Then we define a variable equal to a Label object.

The arguments that we input are the root widget (this tells tkinter where it can go) and then we set the text equal to a string.

Then we use the pack method to just pack the text in there.

What does this mean?

Well instead of us defining where the label goes, the pack() method just puts it in whatever place is free.

Now if you run you will see some text.


Er. This was short but upvote because I need to work on the web dev course. This was just to show you some of what Tkinter could do.

Upvoting is caring :) - @Bookie0 2020


Very helpful! Thanks!



gui is good for many things, including videogames, and operating systems.



operating systems

oh really?


Windows is a GUI based OS, an it's the most popular in the world. You linux kids need to learn that not everything needs a terminal. I love linux, but sometimes having to bother with the terminal for everything is annoying. @CodeLongAndPros



Windows is a GUI based OS, an it's the most popular in the world.

Correlation does not imply causation, Wuru.

Sometimes, a Gooey can be nice.
But it's not required for usage.

That's the thing.

Ya'll Windows kids need to understand that things can be different.

If you had to recover your system from a Plymouth boot hang error due to malformed code, could you do it? I did it in 10 mins. Without a Gui.

For in the beginning, there was the command line


Whilst it is helpful to know how to use your OSs terminal. It is completely irrational to expect to people to use it all the time. By doing this you are returning back to a time years and years ago where the average family couldn't use a computer. For example, how is some grandma gonna learn how to use Sudo pacman and what a -rf does to a rm command? GUI-based operating systems allow many people to learn to use a computer. It is my opinion that it is completely outrageous to have some things be only accessible via the CLI. The simple fact that you were still able to recover from that Plymouth error in 10 minutes without a GUI bothers me. It means that people are investing way too much time into these CLIs where as they should be trying to improve the GUIs. A terminal solution should the last resort and not the only resort. @CodeLongAndPros



some grandma gonna learn how to use

No. They're not going to use arch.
But they can use Linux.

-rf does to a rm

What if I said

Noone is going to learn {x} skill because they have to learn {y}

For example:

Noone will learn to read because they have to memorize all the rules that go with letters.

Noone will learn to drive because they have to memorize what all the little buttons and pedals do

Noone will learn to code since they have to memorize what the functions do.

It is my opinion that it is completely outrageous to have some things be only accessible via the CLI.

So you want a GUI for wc, with a checkbox saying bytes, chars, lines, and a file select dialog?

The simple fact that you were still able to recover from that Plymouth error in 10 minutes without a GUI bothers me.

Doesn't bother me.

On my system, to update all packages, I hit about 20 keys with cmd line:
With gooey:
<super>software <Mouse moves> <Checks for updates> click accept and enter password.


A GUI is more intuitive. You don't need everything to be at a low level. And your example of Noone is going to learn {x} beacuse they have to learn {y} is completely obselete. I never said they wouldn't want to learn x because they have to learn y. What I did say is that it doesn't need to be this complex. To delete a directory and it's everything in it in a file explorer I just click a few times. The terminal should be available, yes, but priority? No. @CodeLongAndPros


So you want an app that will rebuild the initramfs? It’ll have a dropdown menu to select the mode a a big button “regen initramfs”. How is that faster than ‘generate-initramfs -u’?


Its more intuitive. @CodeLongAndPros


what if I want to compress all png files into xz archive, @Wuru, is that faster?

On the Gooey: Ctrl click on all the png files, install a dolphin plugin for xz, right click, select compress, and fill out a form


xz —best *.png -o pngs.xz


Sometimes, it isn't about speed. Sometimes, I just want to use a computer at 3AM and not think about it. @CodeLongAndPros


@Wuru @CodeLongAndPros also i doubt we would be on repl.it without gui


@nk1rwc, yes, but I don’t need a GUI for daytoday work.


@CodeLongAndPros right but otherwise there's no videogames (regular videogames not text adventures.)


@CodeLongAndPros imagine an xbox or nintendo switch without gui


You can also use [email protected]


also wxpython and kivy for mobile [email protected]


@nk1rwc But that is not a computer. I don't even own a Xbox or a Switch.


@CodeLongAndPros do u have a ps4


@nk1rwc Yes, but I almost never use it



Can you please ping me when you are done with that?


sure may be a while though for a preview go here @AbhayBhat


@Wuru, Thanks a lot