Updated June 9, 2023
Introduction to Gnome Development
Gnome Builder is a solid ecosystem you may want to try before getting on to anything else. The Gnome development builder helps solve problems and create GUIs in real-time. It gives developers more power and flexibility. Previously, the development of gnome apps was limited by SUGAR due to the unavailability of Python bindings and lack of maintenance and packaging.
Let us study much more about Gnome development in detail:
Hi Guys. So, today we will be talking about the infamous Gnome development. So, if you are new to Python and Linux, this is not the perfect place for you. You need to go back and get some basics cleared. But, if you are a basic Python programmer and know at least how to work on Fedora or Ubuntu, this tutorial is exactly for you.
For people who have a background in other programming languages, this blog may help them, but having at least the basics right will give them a clear understanding of exactly how this works. So, do we start?
Gnome development
The first thing that we would be needed is a stable Python environment. The one which I am using and I would suggest using is Python 2.7. Though people nowadays use Python 3.3 or 3.4, I recommend using 2.7 because it is still the world’s most useful version of Python and extremely stable and compatible. Though Python 3.4 is consistent, some things still break Python 3.4, which we obviously don’t want.
The second thing would be a proper Python GTK. The latest and most stable release as of now is Python GTK+. Although before proceeding further, one must read the GNOME HIG, Human Interface Guidelines, on how to design an effective Gnome App with the help of Python. But again, if it were so easy, you wouldn’t be here in the first place.
Gnome HIG is not as easy to understand. Thus, I will try to give the best understanding possible in this blog and make it as simple as possible. But once you have understood everything from this blog when I say everything, I mean it. So, after completing this blog, I would surely suggest you read GNOME Human Interface Guidelines.
To start with, GTK+ provides n number of possibilities and common design patterns to create an effective user interface. So, assuming you know how to make and run Python files, I will proceed. Getting started with gnome apps in Windows is extremely easy. So, since I had a good understanding of creating Python GUI Apps using pyqt and Tkinter, I thought it would be easy to develop gnome GUI apps, but it was the opposite.
The hardest part was to get started. All the tutorials I saw when learning was just a direct entry to the GUI way, but with no easy way for beginners. I was increasingly irritated by how hopeless the codes I had written were when I started to understand Gnome GUI. Hence, after a long search, I finally settled for PyGTK/GTK+ and Glade.
Both are cross-platform, so working, installing, and compiling them exactly isn’t a big deal. But since this is a blog for beginners, I won’t be getting into much detail about Glade and stuff. I would suggest going with a Visual Grep tool which is very simple. I didn’t know about V-Grep when I was learning to develop gnome apps. But now, I have simplified this for you. You can also use grep from a command line. But sometimes, you just need something simple rather than it being extremely awesome and complicated.
I can’t make it simpler than using Albert Einstein’s Quote:
“If you can’t explain it to a six-year-old, you don’t understand it yourself.”
The quote is a broad concept, but we aren’t here to talk about the selection, are we?
The next thing you need to understand is the IDE concept. You would need a proper IDE. So, as a beginner, I would suggest using PyCharm Community Edition. Pycharm is an Integrated Development Environment that is extremely robust, with full support for tab and code completion, refactoring, and debugging.
While other IDEs like Adjuta and Eclipse can be useful for the GTK+ Gnome development stack, none is as robustly focused on development as PyCharm.
GTK3 uses introspective bindings, which can be problematic for some IDEs. But Pycharm handles it with charm by generating a skeleton known as its modules. Still, if that’s not our choice, you can always use a package called Faker which does the same thing.
But if you try to run an App within PyCharm using Faker, it will fail because Faker files supplant the real GTK application. But still, it’s a fair trade. You cannot get everything that you want without losing something.
An alternate way would be to use the Gnome development builder IDE. It is an IDE that makes Gnome base building extremely simple.
Following is what the Gnome development builder looks like A Screenshot from my PC:
One look at the Gnome development builder and you will know that this works extremely closely with GNOME3 HIG with a minimal interface. Even with a minimalistic interface, it includes many features that will make the gnome applications look like Loki in front of Hulk. Get the point. Yeah! That’s exactly how it is.
And Speaking of PyGTK, which is also awesome, but not exactly a beginner type, it contains the PyGObject project, which is extremely interesting. PyGTk also supports the ability to move between Python and C, which means you can quickly create Python prototypes and then simply compile them into C for performance enhancements.
The modules that run on top of the main PyGObject code don’t have to worry about supporting C Python APIs. They only need to understand the base GObject Introspection concepts, such as annotation and modeling API, so they are wrappable. This base understanding makes GObject developers write clearer public APIs by restricting the use of or confining to private APIs, some of C’s more esoteric code patterns.
Understanding the power that Introspection brings to application and module developers is important. Now, if you want to provide a new Python module, you don’t have to understand the C Python API; you can simply use your GObject knowledge to create an API accessible from Python or any other language with Introspection support, like JavaScript. Vala even supports Introspection, so you can write objects in Vala and access them through Python.
We don’t have a single runtime, so, unfortunately, you can’t mix scripting languages, but most projects that use introspection will either be exclusive in one scripting language or use a compiled language for their base and a scripting language for rapid prototyping, as a glue language or for plugins. The biggest challenge has been coordinating with the different libraries and applications which support or are supported by PyGObject.
Introspection is very new, and with that comes growing pains. Before, the binding developers could work in a bubble, catching up to whatever the API developers added or changed however they saw best. However, everything is so highly integrated that the binding developers must work closely with the API developers.
This can cause frustration and extra work for all involved, but closer collaboration will reveal itself in a better end-user experience in the long run.
If I have learned anything in GNOME over the years, it is the end-user that matters, and using Introspection helps move towards that goal.
Speaking of the End User, we have come to the end of this blog. To be precise, the more I say, the more confusing it is to think of which one to use when learning. Gnome development builder is simple and has lots of features. But Python has extreme support, and I would suggest going with that though It can get a bit messy sometimes.
Recommended Articles
This has been a guide to Gnome development. Here we have discussed the basic concept, how what the Gnome development builder looks like. You may also have a look at the following courses to learn more –