How to Create a Desktop Application Using Python


Have you ever wanted to create your own desktop application to solve a problem, automate a process, or simply have fun? Python allows you to do that with ease. In this article, I will guide you through the process of creating a desktop application using the Tkinter library in Python.

First of all, let me answer the question that you have in your mind, that is, “how to create a desktop application in Python?”. To create a desktop application, you need to learn the basics of Python, some object-oriented programming concepts, and the fundamentals of the Tkinter library. Tkinter is a GUI (Graphical User Interface) library of Python, which can help you create desktop apps easily.

This article is an introduction to Desktop App development with Python. To help you master Desktop App development even further, I recommend you the GUI Development with Python and Tkinter course on Udemy. This affordable, high-quality course covers Tkinter in-depth and teaches you how to build some cool projects like a Snake Game, Pomodoro Timer App, and Chat App. You can check the course contents by yourself by clicking this link.

Now, let’s discuss how to get started with desktop app development with Python and build a simple application.

Requirements

Let’s look at the requirements in detail, and I’ll point you to some helpful resources.

1. Basics of Python

Obviously, to create a desktop app using Python, you need to know the basics of Python. I hope you already know the basics of Python since you came here to take it to the next level. So, I won’t waste so much time discussing Python basics.

However, if you don’t know the basics of Python, you can check this tutorial I’ve written, and learn the basics. If you know the basics, let’s move on to the next requirement.

2. Object Oriented Programming

Desktop apps work mostly based on objects, and hence, you need to know the object-oriented concepts in Python to create apps. You should learn what classes, objects, methods, inheritance, polymorphism, encapsulation, etc., are and how do they work.

If you don’t know these things, don’t worry. I’ve written a complete guide on object-oriented concepts in Python. But before going to that, let’s make your first desktop app, even if you don’t know anything.

Let’s move on to learning Tkinter now. You’ll be able to create a simple application if you follow along with me.

3. Fundamentals of Tkinter

It’s time to learn the basics of the Tkinter library. It is a pretty simple library, and you can easily understand the working of it. The best thing is that you don’t need to install anything extra to use Tkinter. If you have the Python IDLE on your system, that is enough. Tkinter comes up built-in with the Python IDLE.

If you want to learn Tkinter in-depth, I’ll point you to one of my favorite articles, where you’ll learn the concepts and create three amazing apps. You’ll create a social media bookmark app, an age calculator app, and a rock paper scissors game. Click here to check that article.

A Simple Desktop Application Using Python

Now, let’s make a simple desktop application using Python and Tkinter.

To use any library, we need to import it first into the code. So, let’s import Tkinter as tk. Why do we import tkinter as tk? It is for ease of use. Now we can use tk instead of Tkinter whenever we need to use it.

import tkinter as tk

The next thing we need to do is to create a window. We can do that by initializing a new Tkinter object with the help of the Tk() method. It’s simple. This is how we do it:

window=tk.Tk()

Now, we have a window for our desktop application. Let’s try to give this window a title. We can do it by using the title() method. I gave the name “Pythonista Planet Desktop App”. I know it is a weird name. But you understood how to give a title to the app.

window.title(" Pythonista Planet Desktop App ")

Now, let’s define the geometry for the app window. That means the width and height. We can do it using the geometry() method. Let’s give the width as 600 and the height as 400.

window.geometry("600x400")

Now, the window is ready. Let’s print something on this window. Again, I’ll be shamelessly promoting my website. Let’s display ” Visit Pythonista Planet to improve your Python skills ” on the window. What about that?

We can add a text by using the Label() method of Tkinter. Pass the string that you want to display to the parameter called ‘text’. I’m assigning the whole thing to a variable called “newlabel”.

newlabel = tk.Label(text = " Visit Pythonista Planet to improve your Python skills ")

Now, let’s place this label on a grid. The whole Tkinter window is divided into multiple grids. Let’s place it on the top-left grid(0,0).

newlabel.grid(column=0,row=0)

We’ve done almost everything. No, one last thing. Before we run any Tkinter application, we need to call the mainloop() method. If you know the C language, it is like calling the main() program in C. This main program executes everything that we’ve written above it. Let’s call the mainloop().

window.mainloop()

Now, our tiny desktop application is ready. Let’s run the program in our IDLE.

Simple Desktop App using Python Tkinter

Hurray!!! We have successfully build a desktop application using Python. Here is the output:

I know it is a very simple application. But for complete beginners, it is a pretty good starting point. You have at least made a simple desktop application using Python. Let’s build on this. I suggest you learn more about Tkinter now, and advance your skills.

Don’t worry, I’ll point you to some resources. As I’ve mentioned above, I’ve written a complete guide on building desktop applications using python and Tkinter. Click here to go to that article. It will help you learn the basics of Tkinter, and you will be able to create three advanced projects.

After doing those three projects, you can do even more projects if you want. Check out this article that I wrote on the topic 8 Fun Tkinter Project Ideas. This article will help you find some more project ideas. It will also show you some helpful tutorials to implement them.

Some Other Python Frameworks To Create Desktop Apps

Tkinter is not the only option available to create desktop apps in Python. Python has other GUI frameworks as well. Some of the commonly used GUI frameworks are given below.

  • PyQT
  • WxPython
  • PyGUI
  • PySimpleGUI
  • Kivy

I haven’t used all these frameworks by myself. If you want to learn more about these frameworks, I suggest you read this article.

I prefer Tkinter since it is a simple and lightweight framework. You might have understood that from this tutorial. It is a pretty simple framework and most suited for beginners. However, you can explore more and learn other frameworks as well if you want.

Final Thoughts

Creating desktop applications is easy, especially when you’re coding in Python. You can also create advanced desktop apps using Tkinter that can be helpful in real-world situations.

I hope this article was helpful for you in creating a simple desktop application. If this article was useful, let me know in the comments section. Also, let me know if you have queries or doubts. I’ll be to help you if I can. If you want to learn Tkinter in depth with an online course, you can check out my course recommendations for Tkinter.

I would really appreciate it if you would be willing to share this article on social media. It will inspire me to create more valuable tutorials like this.

Happy coding!

Ashwin Joy

I'm the face behind Pythonista Planet. I learned my first programming language back in 2015. Ever since then, I've been learning programming and immersing myself in technology. On this site, I share everything that I've learned about computer programming.

16 thoughts on “How to Create a Desktop Application Using Python

  1. I’m a c# programmer looking to learn python. I haven’t found any good examples of desktop apps with menus and multiple screens. An app with one screen is pretty straightforward, but overly simplistic for what I’m looking to do. Any examples you can point me to?

    1. Check out this article and see if any of these projects match your need: https://pythonistaplanet.com/python-tkinter-project-ideas/

  2. Seriously, amazing, i was stuck, not found any way to build my final year project, even don’t know, what will be my final year project, will it be web base application, or mobile application,
    Now finally after reading this, i have clear my concepts
    Thanks to God

  3. i am a c# programmer, need to build a desktop application that has around 40 to 45 different user interfaces. My basic two queries. first will this be a huge application for python.. why i am asking is that i have not used python in real life project.
    second is can we make a setup to deploy python like we do in c# desktop applications or is it that we deploy files?

  4. I do programming in Visual Basic 6. I would like to migrate some of those apps to another language. Most of them has hundreds of screens , reports , database (mostly using Microsoft access and a couple using sqlserver). How difficult it would be convert such applications to python ? where could I get stuck ? any idea

    1. The way more simple for make this is using PyQt5 or PySide2, honestly is equals, but distributed per differently companies, now for using database acess the own lib has ways ORM. good luck in this project

  5. Great Article. Helped me to create my 1st application.
    I want to create a attendance management system for office and the app should be installed in each employee’s system to check in and check out their timings.
    What will I need to make that application work ?
    And how do I make that software as exe file ?

    1. Yeah, you can create the app using Python and give it a UI using Tkinter. For converting it into an EXE, you can check this article: https://pythonistaplanet.com/how-to-convert-python-to-exe/

  6. hi great job man explain very basic detail how to do with python, but i think this blog’s font are kinda stretched

  7. Would TKinter be able to handle many forms for data entry and hundreds of rows of data connected to SQL Server?

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts