5 Python GUI Frameworks to Create Desktop, Web, and Even Mobile Apps. | Towards Data Science

No solution is complete without a great UI.
Python has been successful in a wide variety of use cases. But few understand and appreciate its abilities in creating graphical user interfaces (GUI.) Indeed we have a handful of extraordinary python GUI frameworks that helps developers quickly put up an interface to interact with their project.
This post will discuss 3 cross-platform GUI frameworks and 2 web interfacing tools. We'll also cover some basic examples and their strengths so that you can be well acquainted with picking the right one for your next project.
Here are the five tools you need to know for building helpful UI.
Streamlit is a fantastic tool for developing web apps using Python. It has a declarative coding style which I found very helpful.
You don't have to know any HTML, CSS, or JavaScript or follow any web development online courses. If you know Python, you are already armed with everything you need.
You can install Streamlit with the following command.
pip install streamlit
Here's a simple application that displays a pandas data frame on a web page.
Create a file named quickstart.py with the above content. To start the streamlit web server, run the following command.
streamlilt run quickstart.py
This command will start a development server, and on your web browser, you can see the following.
You can learn more about Streamlit in my previous post on the topic. There is also a live version of this app you can check out.
towardsdatascience.com
towardsdatascience.com
Plotly has been around for several years. Dash is a framework that extensively leverages Plotly charts to build GUIs with less code.
Plotly Dash is a flexible solution that fits a variety of applications. Their website says it's designed to reach places where Tableau and PowerBI can not.
In my opinion, it does.
Install Plotly Dash with the following single command from the PyPI repository.
pip install dash
To start, you can create a file named app.py with the following content and run it like any other python script.
Run the below code to activate the webserver. It'll initiate a Flask development server and open it up on your default web browser.
python app.py
You can read more about Plotly Dash in my previous blog post on this topic.
towardsdatascience.com
Plotly Dash and Streamlit are more mature technologies in this list. While they are very helpful in developing a web application, we have tools that help us build cross-platform apps in Python. The next one is a great example.
Kivy is a cross-platform Python software development framework. With it, you can create Desktop applications for Windows, OS X, and Linux, build mobile apps for iOS and Android, and use it on embedded devices on top of Raspberry Pi.
You've read it correctly.
Python is no longer limited to web and desktop development. You can do a lot more stuff you can't do with other languages. Perhaps, that's why Python is the most popular technology in the Stackoverflow developer survey, 2021.
Kivy's documentation includes detailed guides from installation to publishing in Android Marketplace. They are significantly different from platform to platform.
Since I'm on Ubuntu (Linux), I'm using the Kivy official PPA way to install it. Following are the instructions to do it.
$ sudo add-apt-repository ppa:kivy-team/kivy$ sudo apt-get install python3-kivy
Once installed, you can create a file app.py with the following content and run it to see Kivy in action.
As you can see in the above example, Kivy's Grid layout is handy for arranging UI elements on the screen. You only have to specify the number of columns and start adding elements. Kivy is smart enough to display them in the best possible way.
Of course, Kivy is more than this. From their official docs, you can learn more about GPU optimization, mobile builds, touch support, etc. Here's an excellent Freecodecamp tutorial to watch on Youtube.
Kivy is a great tool to prototype your mobile applications. If your team doesn't have the skillset to develop mobile apps, this may be the best choice.
PyQt5 is a framework built around QT. QT (and PYQT5) supports cross-functional development. It supports Windows, Mac, Linux, and mobile platforms such as iOS and Android.
Besides its impressive UI components, PyQT5 integrates well with native OS APIs. A great benefit of PYQT5 is the QT Designer, a tool that lets you visually compose UI with QT widgets.
You can install the framework using PyPI as follows:
pip install PyQt5
A hello world style app would only have a few lines of code that puts up a nice-looking UI.
QT and PyQT5 are matured frameworks. Because its ecosystem is vast, it might take some time to master it. Yet, it won't be any difficult to find free learning resources.
PyQT5, however, is not free for commercial use. The next one is.
www.pythonguis.com
Tkinter is a standard Python GUI library. Like Kivy and PyQT5, Tkinter too works on Windows, Linux, and Mac OS. Since Tkinter uses OS native elements, they look and feel like everything else on the platform it's running on.
Tkinter is relatively easy to learn and implement. But its limitation is its lack of advanced widgets. Nevertheless, it's a great tool to prototype your ideas in a very short time.
Official python installation comes with Tkinter along with it. Yet if you are on Ubuntu, you'd have to install it with the following instructions.
$ sudo add-apt-repository ppa:deadsnakes/ppa$ sudo apt-get update$ sudo apt-get install python3.9 python3-tk
Once you have installed the package, you can execute the following python script to spin up a hello world app.
The above code will open up a native-looking GUI like the one below.
As you can see, this one is very straightforward compared to our previous tools.
realpython.com
Over the past couple of decades, Python has expanded into multiple territories. Today we use this elegant programming language for data science, workflow integration, software development, etc.
Python is fully capable of GUI development as well. That's precisely what we've covered in this post.
The five tools we discussed here are helpful for almost all the GUI development needs. From prototyping to mobile app releases to Google and iOS stores to Web applications. The only skill set you should have for all these tools is Python.
Choosing the right tool for the right project is art. From this list, my suggestion is as follows:
Looking for quick prototyping? Go with Tkinter
Need more widgets? Go with PyQT5
Developing cross-platform and mobile apps? Kivy works well
Want to build a web app and give users concurrent access? Streamlit is fantastic
Need more flexibility? Plotly Dash is the answer.
I hope this guide is informative to choosing the Python GUI tool for your next project.
Thanks for reading, friend! Say Hi to me on LinkedIn, Twitter, and Medium.
Not a Medium member yet? Please use this link to become a member because, at no extra cost for you, I earn a small commission for referring you.