Tkinter VS Kivy Tutorial Quickstart: Which one is right for you?¶
Why Use Tkinter or Kivy In the First Place?¶
Tkinter and Kivy are both cross platform GUIs that are commonly used by Python users. There are other frameworks out there but they are either: in another programming language, not available on all platforms, or a combination of both.
In this blog post, you will go through the hello world
steps of both GUI interfaces on as much platforms as possible to get a feel for which one is right for you.
The only real test is to try them out!¶
Before following this guide, you need these tools and libraries:
- Python
These are helpful, but not required for this tutorial:
- Git
- Pyenv
- Poetry
- VSCode or editor of your choice
If you do not see any of the below sections, please click to show.¶
main.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Kivy Win Step 1: Get the repo from github¶
You can do this in two ways: git clone https://github.com/kivy-school/kivyhw
or download the zip file and unzip it somewhere.
How do I git clone?
- Press the ⊞ Windows key and type
cmd
to open command prompt.
- If git is installed, then change directory with the
cd
command to the correct folder you want to work in. dir
in Windows shows you the contents of the current directory.cd
changes to the directory you want.cd ..
goes up 1 directory level.
Then type git clone https://github.com/kivy-school/kivyhw
Then cd kivyhw
to enter the project.
Kivy Win Step 2: Install libraries¶
If poetry is installed:
- Type:
poetry update
in thekivyhw
directory. Poetry will install everything for you and AUTOSOLVE VERSION CONFLICTS, plus provide you with a virtual environment so you don't break your Windows system Python. - Type
poetry shell
to enter the virtual environment and proceed to the next step.
If poetry is not installed:
-
If
poetry
is not installed, you can still install requirements usingpip
. Be warned! If you make any mistakes with any sort of pip install, you might end up breaking your Windows Python installation and have to reinstall it over again to fix your environment. Because this is just a Hello World tutorial, you do not need to worry about it now. If you have also followed other tutorials, you might get version conflicts for libraries. This is because pip normally installs every library to your system Python unless specified. That means that conflicting versions ofcertifi
will appear and you will have to manually resolve conflicts. If so, please try installing python-poetry and use virtual environments for each project (like the one Kivy School is providing in this tutorial with thepoetry shell
command). -
In the
kivyhw
folder (NOTkivyhw/kivyhw
folder!) type:pip install -r requirements.txt
- Proceed to the next step.
Kivy Win Step 3: Run hello world!¶
There are two options to run the kivy app:
From the top level kivy hw
folder, run this command: python kivyhw/main.py
It is also possible to cd kivyhw
and run python main.py
If poetry update
was used in installation, you also have access to: task run
in the top level kivyhw
folder courtesy of these lines in the pyproject.toml
and the taskipy
library:
[tool.taskipy.tasks]
run = 'python kivyhw/main.py'
main.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Tkinter Win Step 1: Get the repo from github¶
You can do this in two ways: git clone https://github.com/kivy-school/tkinterhw
or download the zip file and unzip it somewhere.
How do I git clone?
- Press the ⊞ Windows key and type
cmd
to open command prompt.
- If git is installed, then change directory with the
cd
command to the correct folder you want to work in. dir
in Windows shows you the contents of the current directory.cd
changes to the directory you want.cd ..
goes up 1 directory level.
Then type git clone https://github.com/kivy-school/tkinterhw
Then cd tkinterhw
to enter the project.
Tkinter Win Step 2: Install libraries¶
If poetry is installed:
- Type:
poetry update
in thetkinterhw
directory. Poetry will install everything for you and AUTOSOLVE VERSION CONFLICTS, plus provide you with a virtual environment so you don't break your Windows system Python. - Type
poetry shell
to enter the virtual environment and proceed to the next step.
If poetry is not installed:
-
If
poetry
is not installed, you can still install requirements usingpip
. Be warned! If you make any mistakes with any sort of pip install, you might end up breaking your Windows Python installation and have to reinstall it over again to fix your environment. Because this is just a Hello World tutorial, you do not need to worry about it now. If you have also followed other tutorials, you might get version conflicts for libraries. This is because pip normally installs every library to your system Python unless specified. That means that conflicting versions ofcertifi
will appear and you will have to manually resolve conflicts. If so, please try installing python-poetry and use virtual environments for each project (like the one Kivy School is providing in this tutorial with thepoetry shell
command). -
In the
tkinterhw
folder (NOTtkinterhw/tkinterhw
folder!) type:pip install -r requirements.txt
- Proceed to the next step.
Tkinter Win Step 3: Run hello world!¶
There are two options to run the kivy app:
From the top level tkinterhw
folder, run this command: python tkinterhw/main.py
It is also possible to cd tkinterhw
and run python main.py
If poetry update
was used in installation, you also have access to: task run
in the top level tkinterhw
folder courtesy of these lines in the pyproject.toml
and the taskipy
library:
[tool.taskipy.tasks]
run = 'python tkinterhw/main.py'
main.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Kivy Mac Step 1: Get the repo from github¶
You can do this in two ways: git clone https://github.com/kivy-school/kivyhw
or download the zip file and unzip it somewhere.
How do I git clone?
- Press
Command ⌘
+Spacebar
and typeterminal
to openterminal.app
- If git is installed, then change directory with the
cd
command to the correct folder you want to work in. ls -l
in Mac shows you the contents of the current directory.cd
changes to the directory you want.cd ..
goes up 1 directory level.
Then type git clone https://github.com/kivy-school/kivyhw
Then cd kivyhw
to enter the project.
Kivy Mac Step 2: Install libraries¶
If poetry is installed:
- Type:
poetry update
in thekivyhw
directory. Poetry will install everything for you and AUTOSOLVE VERSION CONFLICTS, plus provide you with a virtual environment so you don't break your Mac system Python. - Type
poetry shell
to enter the virtual environment and proceed to the next step.
If poetry is not installed:
-
If
poetry
is not installed, you can still install requirements usingpip
. Be warned! If you make any mistakes with any sort of pip install, you might end up breaking your Mac Python installation and have to reinstall it over again to fix your environment. Because this is just a Hello World tutorial, you do not need to worry about it now. If you have also followed other tutorials, you might get version conflicts for libraries. This is because pip normally installs every library to your system Python unless specified. That means that conflicting versions ofcertifi
will appear and you will have to manually resolve conflicts. If so, please try installing python-poetry and use virtual environments for each project (like the one Kivy School is providing in this tutorial with thepoetry shell
command). -
In the
kivyhw
folder (NOTkivyhw/kivyhw
folder!) type:pip install -r requirements.txt
- Proceed to the next step.
Warning
If you cannot see the .venv
folder in the kivyhw
, that is because your Mac Finder settings are set to hide hidden folders.
-
To toggle seeing hidden folders like
.git
and.venv
, use the command:Command ⌘
+Shift
+.
-
Without hidden folders:
- With hidden folders:
Kivy Mac Step 3: Run hello world!¶
There are two options to run the kivy app:
From the top level kivy hw
folder, run this command: python kivyhw/main.py
It is also possible to cd kivyhw
and run python main.py
If poetry update
was used in installation, you also have access to: task run
in the top level kivyhw
folder courtesy of these lines in the pyproject.toml
and the taskipy
library:
[tool.taskipy.tasks]
run = 'python kivyhw/main.py'
main.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
TKinter Mac Step 1: Get the repo from github¶
You can do this in two ways: git clone https://github.com/kivy-school/tkinterhw
or download the zip file and unzip it somewhere.
How do I git clone?
- Press
Command ⌘
+Spacebar
and typeterminal
to openterminal.app
- If git is installed, then change directory with the
cd
command to the correct folder you want to work in. dir
in Windows shows you the contents of the current directory.cd
changes to the directory you want.cd ..
goes up 1 directory level.
Then type git clone https://github.com/kivy-school/tkinterhw
Then cd tkinterhw
to enter the project.
TKinter Mac Step 2: Install libraries¶
If poetry is installed:
- Type:
poetry update
in thetkinterhw
directory. Poetry will install everything for you and AUTOSOLVE VERSION CONFLICTS, plus provide you with a virtual environment so you don't break your Mac system Python. - Type
poetry shell
to enter the virtual environment and proceed to the next step.
If poetry is not installed:
-
If
poetry
is not installed, you can still install requirements usingpip
. Be warned! If you make any mistakes with any sort of pip install, you might end up breaking your Mac Python installation and have to reinstall it over again to fix your environment. Because this is just a Hello World tutorial, you do not need to worry about it now. If you have also followed other tutorials, you might get version conflicts for libraries. This is because pip normally installs every library to your system Python unless specified. That means that conflicting versions ofcertifi
will appear and you will have to manually resolve conflicts. If so, please try installing python-poetry and use virtual environments for each project (like the one Kivy School is providing in this tutorial with thepoetry shell
command). -
In the
tkinterhw
folder (NOTtkinterhw/tkinterhw
folder!) type:pip install -r requirements.txt
- Proceed to the next step.
Warning
If you cannot see the .venv
folder in the kivyhw
, that is because your Mac Finder settings are set to hide hidden folders.
-
To toggle seeing hidden folders like
.git
and.venv
, use the command:Command ⌘
+Shift
+.
-
Without hidden folders:
- With hidden folders:
TKinter Mac Step 3: Run hello world!¶
There are two options to run the kivy app:
From the top level tkinterhw
folder, run this command: python tkinterhw/main.py
It is also possible to cd tkinterhw
and run python main.py
If poetry update
was used in installation, you also have access to: task run
in the top level tkinterhw
folder courtesy of these lines in the pyproject.toml
and the taskipy
library:
[tool.taskipy.tasks]
run = 'python tkinterhw/main.py'
Why this project folder setup?¶
Most tutorials just give you the Python code in 1 folder.
In a real project, there are a lot of project management files that are simply not part of the main Python code and should NEVER be shipped, like hidden secrets. In this example, there are many things that should not be given to an end user, like the .git
folder, .venv
virtual environment provided by Poetry, .gitignore
used by git, poetry.lock and pyproject.toml
used by poetry, a github README.md
file and requirements.txt
used by pip
.
Those files are for development only! That is why the management files are in the top level, and the actual Python project is inside an inner folder.
You can see for yourself by inspecting these popular Python libraries:
Kivy¶
NumPy¶
FastAPI¶
Article Error Reporting¶
Message @BadMetrics on the Kivy Discord.