【Sharing】An Easy method to develop GUI Desktop Software for ALL OS!

As a software engineer, I often have to deal with customers who use different OS platforms. Often the customer’s needs can be completed with a few simple command on the terminal. However, the customer is not an engineer and feels big about any interface that requires the use of “black frames”. To solve this problem, it is necessary to develop the desktop GUI (Graphical User Interface) software, which makes simple things very complicated, but is there a way to easily develop desktop GUI software?

YES ! Next, I will demo a method I learned recently.


Software tool list

-Python3
-pyinstaller


1. Use Python’s Tkinter to develop GUI software

Python comes with Tkinter modules to easily develop GUI desktop software. With Python’s simple and easy-to-read features and rich online tutorials, it may only take one or two hundred lines of code to develop a useful GUI desktop software. Compared to Qt, which has to install many tools at every turn, using Python’s Tkinter is really convenient.

To learn more about how to use Tkinter, please check here

Here we take this serial monitors as an example to see what code size is required for a self-made GUI serial monitor written in Python, here are the source code,


The two Python files add up to only 270 line code, which is quite small. If you are interested , you can clone the source code from this github and execute it with Python (you need to install the pyserial module with pip), and here is what you get,

image


Now it comes the problem. Although you can run this program on your laptop, it is because you have installed the Python development environment and the necessary Python modules, but it is very likely that, on the customer’s computer, there is no Python, let alone these necessary modules, what should we do? Don’t worry, I will introduce you to a super easy-to-use tool pyinstaller


2. Use pyinstaller to publish desktop software on all platforms

The all platform here refers to Windows, Linux and MacOS, but in fact pyinstaller also supports AIX, Solaris, FreeBSD and OpenBSD!

Normally, if you need to publish all-platform desktop software, you must use many tools. Now only one pyinstaller is enough.

The method of installing pyinstaller is also very simple. Just use pip like this,

pip install pyinstaller

(The following uses Windows 10 as an example)

After the installation is complete, you can find the place where you store the code of your Python GUI program, then enter the following command + enter in your file explorer address bar:

cmd

Then you will see the command prompt jump out from the current path,

image

Next, you only need to enter a line of instructions,

pyinstaller -w --onefile [name of your Python file]

Done!
:confetti_ball:


In this way, you can find the application for your OS in the dist folder under the current folder, and this program can run on any other Windows computer without having to install anything! (This method is also applicable to all other OSs)


Conclusion

Someone will definitely ask: “Why don’t you use Qt to develop GUI programs? Isn’t C + Qt good enough for you?”

My answer is:

Life is short, I use Python

:laughing:

3 Likes