How to Install PyGTK in Python on MacOS? - GeeksforGeeks

22 Nov, 2021
PyGTK is a Python package or module that enables developers to work with GTK+ GUI Toolkit. This is how WikiBooks describes GTK+:
“GTK+ is a highly usable, feature rich toolkit for creating graphical user interfaces which boasts cross platform compatibility and an easy to use API.”
And this is how gtk.org the official website of GTK markets it:
Offering a complete set of UI elements, GTK is suitable for projects ranging from small one-off tools to complete application suites.
Although Python comes with a built-in module called Tkinter which is used to make simple GUI applications. But many developers are unsatisfied by the appearance of the application made by it and it is not even feature-rich so as to help in making elaborate software. Therefore GTK+ in association with Python is considered to be a great alternative to Tkinter. Although the GTK library supports many programming languages such as C, JavaScript, Perl, Rust, and Vala. But it is most widely used in association with Python which employs a language wrapper to fully utilize the capabilities of the official GNOME binding to produce the most stable applications.
GTK library comes jam-packed with features that enable developers to do whatever they want.  Here are some of the main selling points of GTK.
Portability
Stability
Language Binging
Interfaces
OpenSource
API
Accommodation
Foundations
Listing some of the famous applications which are made by this GTK are as follows:
GIMP
Transmission
Evolution
Polati
Games of all sorts
Etc.
Below we will go through all the steps to install PyGTK in the macOS operating system in detail.
Step 1: Install Python
Although Python comes pre-installed in most macOS, however, it should be upgraded for the best performance or better saying to avoid unwanted errors. 
To check if Python is already installed in the system or not open the Terminal app and run the command below:
python --version
If the above command does not return any version number then, it means that Python is not pre-installed and if it returned any number such as 3. N.N then you may check if an upgrade is available or not. To see the full guide for the Python installation on macOS visit here.
Step 2: Install HomeBrew
Homebrew is open-source software that facilitated the management of packages in Mac and Linux-based operating systems. It basically gives developers the power to install, remove,  upgrade, downgrade, etc a package from the terminal itself.
To install Homebrew in our system we only need to run a simple command in the terminal that is given below:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once the above command gets executed you can check if it has been installed correctly by running the below command: 
brew help
If it returns any output then our work is done properly, if not then re-installed homebrew using the above command.
Step 3: Install GTK+
Now the last thing to do is to install GTK+ collection libraries in our system to later include this in Python projects. Since we have installed Homebrew in the previous step this step is going to be a breeze. All that is needed is the execution of the below command:
brew install gtk+
Once this process is done all you need is a quick reboot of the system and you should be ready to roll a new Python project with PyGTK in it. Although there is no quick way to find out GTK+ has been installed properly or not but you will surely find out while working with it. But one thing that we can do to be sure of that to run the same installation command again. What it will do is first it will check if the program is already installed or not. If it is not installed already then it will start the installation but now that we have installed it should return a warning.
As we can see in the above image we get a warning that gtk+ is already installed, so that is our confirmation of the same. One other thing that one might do is, issue a command to check the version of gtk package. The command is given below. 
gtk-launch --version
So with everything set now, you are ready to roll a project!
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?