Desktop App Development - PyQt vs Tkinter vs Electron

Analyzing Python and Javascript and the libraries they offer for building cross-platform desktop applications

·

4 min read

I'm working as a software engineer for quite a while now. I started exclusively with the development of web-based applications. Part of my work these days involves contributing to the development of desktop-based applications. As a result, I had exposure to multiple tools available for this in the languages already known to me - Python and Javascript. At the time of writing this post, I've tried PyQt/PySide, Tkinter and Electron frameworks to create desktop-based applications. I'd be discussing my experiences of working with them, about their pros and cons in subsequent paragraphs.

I started with Tkinter, it comes installed with your Python version. Perhaps the easiest to start with, but becomes difficult to manage as the complexity of your applications increases. There are concepts like widgets, frames, canvas, layouts, animations and more which are common regardless of what framework you use. Tkinter could be a nice point for kick-starting things and familiarising yourself with desktop app development. It gets hard to adequately place your widgets (components like list-box, buttons and more) as your Tkinter app grows. Design-wise, it is primitive. It does however has some themes to choose from which would enhance the look and feel of your application. The list of various components available for you to use is very limited. For instance, tables are not available in Tkinter and to implement one in your Tkinter app, you need to adopt a hackish way of accomplishing it by using Frames, Buttons and Labels. My first full fledge computer science project was in Tkinter, but I rarely use it these days ever since I encountered PySide/PyQt library. It is still good for small apps, you don't need to install additional packages and has a soft learning curve.

I've been using PyQT/Pyside for nearly half a year. It is based on the original QT library written for C++ language. It inherits most of the functions from the C++ implementation, for the documentation, I usually refer to the C++ one since that is more descriptive. It has a wide range of components to offer from list-box, tables, spinners, sliders and more. It has a steep learning curve given the range of features it offers. It has support for QT designer which lets you create widgets through a drag-and-drop interface and then convert them to a supported Python file which you can then modify for event handling and other stuff. It makes layout management easier to handle multiple components. It has CSS-based style support for all the widgets which you can also configure in the designer view. On a personal note, I enjoy this QT designer support a lot. Makes it so much easier to get started with the design. For the negatives, there isn't much I can think of. But, the libraries do take up a lot of space compared to Tkinter. Even the final build is bulky in size compared to the one generated by Tkinter.

Electron is a library in Javascript which aims at creating native desktop-based applications using a web-development coding style. You can use React (Vue or any other Javascript library) to create your desktop application. It makes us very easy for someone like me who is coming from a web-based background in software development. Many of the popular tools are created using Electron - for example, VS Code, one of our favorite coding editors is built using Electron. The views are written and styled in CSS, event handling is done in Javascript. As a result, it provides more flexibility to you in terms of changing the UI since you can use any popular UI library lit like Material UI, Bootstrap, Chakra UI and Vuetify just to name a few to create your desktop application. I haven't been working with Electron lately but would like to continue experimenting with it in the future.

My final verdict in short would be PySide > Electron > Tkinter. I might prefer Electron future given the friendly support it has for web developers. But, for now I am leaning towards PySide. PySide and PyQt are essentially the same except that PySide is authorized to be used to create production-grade open-source projects. But, PyQT is restricted for commercial usage only after buying a subscription.