Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

How to Install PyGTK in Python on MacOS?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 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"

 Install HomeBrew

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+

install PyGTK in Python on MacOS

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.

verify installation of  PyGTK in Python on MacOS

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!

My Personal Notes arrow_drop_up
Last Updated : 22 Nov, 2021
Like Article
Save Article
Similar Reads