Glade, PyGTK, gnome-python Textorial

Building the main App

We begin building the main Application window by firing up glade. In order to do anything in glade, we must start a new project. In the main glade window, create a new gnome project by clicking on the "new" button and choosing "gnome". You should be left with a fresh open work space much like the one below (without the confirmation dialogs of course).

Glade Windows

While it is possible to build our application completely from scratch, you will see later while this will only create a large ammount of repetition. There is more than enough here to get reasonably comfortable (even self assured might I add) without building the interface from scratch. Since we are going to use the default gnome application window, in the palette window select the large button "Gnome", and select the top left icon (the tooltip for the icon is gnome application window). Glade has now created a simple gnome app with a built in menu, some buttons, a status bar, and room for 1 Widget. It's also done the dirty work of connecting all of the menu signals automatically so that they actually work like menus. At this point, you should be looking at something like the image below.

Gnome App Window

Since we are making a simple text editor, we only need a box where the user can add and edit text. The GTK text view widget will work just perfectly, so choose the "GTK+ Basic" button on the palette window and then "paint" a text view widget into our open container (the hashed space) by clicking on the far right icon on the 2nd row from the top, and then (once the cursor is a small plus) clicking on the hashed area inside the gnome application window. What we are left with at this point is something that looks quite a bit like a text editor! Unfortunately, we are far from done; as is the easy part of this tutorial.

Text View Painting

Project Options and Saving

Before we get to the real meat of our program (the python code of course!), we will need to save the glade project somewhere so that it can be used in our code. It should of course be fairly obvious that to save we click the "save" button in the project window. While the default values (~user/project1) are usually sufficient, it should be noted that some gnome widgets (specifically the about dialog which is not used during this tutorial) will use some of the values set in the project properties. Regardless of where you save your files, you will need access to the *.glade file as well as whatever directories that you will be creating for Icons and Pixmaps. For the rest of the tutorial, I will refer to the place where your glade project is stored as "~glade/".

back to the specs | forward to Glade Env...
up to the index