Today we're going to use a usefull library in python to build awesome applications. We'll use :
In this first part, we'll know how to create the base of our application. In a second part, we'll see the different widgets, this module propose to us and how to display them. And finally, in a third part, the inputs and actions.
First Tkinter is a module that can create some GUI applications for all plateforms as Windows, Mac OS and Linux. If you have Python already installed on your computer, you have surely tkinter with it. If it's not you can run this command in the console :
pip install tkinter
So, let's start with the script. Create a file with the
.py extension (PS : you can use
.pyw extension if you want to hide the console when the script is running).
In this empty file, insert the import of Tkinter :
import tkinter # Basic import from tkinter import * # Import all propreties from tkinter module
We'll use the second import because it's a better way to do.
Now, we can create a variable that store the application :
app = Tk()
After that, we can asign some options to the app :
1) A title :
2) A size by default :
app.geometry("600x400") -> "widthxheight"
And now, we can finally finish the programm by this line :
Like that our app can run on the screen.
from tkinter import * app = Tk() app.title("Our Application") app.geometry("600x400") app.mainloop()
As you see, create a desktop application with tkinter is very simple. In the next post, we'll see the different widgets we can add to our app and how to display them on the screen.
If you have some questions on this first part, please write it in the comment section below.
I hope this help you. And see you soon. Bye bye 👋👨💻