How to Install PyGTK in Python on MacOS?
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.
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.
- Language Binging
Listing some of the famous applications which are made by this GTK are as follows:
- Games of all sorts
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:
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:
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.
So with everything set now, you are ready to roll a project!
Please Login to comment...