This small code will load the Glade file and displays the window.
Note : The Glade Project file format should be GtkBuilder.
Now, let’s get down to the code. Create a Python file named window.py in the folder containing the glade file and put in the following contents :
self.gladefile = "window.glade"
self.glade = gtk.Builder()
self.win=self.glade.get_object("window1") # Window Name in GLADE
if __name__ == "__main__":
a = SubinsWindow()
The first yellow backgrounded text has the name of the GLADE file.
The second yellow backgrounded text has the name of the GLADE Window. Normally It would be window1.
Execute the Python program by opening a terminal with the folder and execute the following command:
Here is a sample window created using GLADE and executed in Python :
So, Now you know how to import a GLADE file in Python and display the window.
If you have any problems/suggestions/feedback just say it out in the comment box below.