How to handle a project in a clearing with many windows

I am working on a PyGTK / glade application that currently has 16 windows / dialogs and is around 130 KB, and will ultimately have about 25 windows / dialogs and will be around 200 KB. Currently, I store all windows in a single file of a monolithic glade. When I launch the window, I call it ...

self.wTree = gtk.glade.XML("interface.glade", "WindowXYZ") 

I wonder if it would be better to split each window into its own clearing file. Instead of one glade file with 25 windows / dialogs, I would have 25 glade files with one window / dialog each and call it like this:

 self.wTree = gtk.glade.XML("windowxyz.glade") 

What do you guys think is the best way to do this? Is one method more resource intensive than another? One thing that would be nice to go to individual glade files is that naming widgets will be easier. For example, I call all my OK buttons "windowxyz_ok", but I could change it to just "ok." Makes things easier. The disadvantage is that it may be a little less convenient to make changes to different windows.

I am open to all arguments. Thanks!

+7
python gtk pygtk glade
source share
4 answers

In my projects, I always have one window per file glade. I would recommend the same for your project.

Two main reasons are listed below:

  • This will be faster and less memory, as each call to gtk.glade.XML () parses all this. Of course, you can pass the root argument to avoid creating a widget tree for all windows, but you still have to parse all the XML, even if you are not interested.
  • Conceptually, it is easier to understand if you have one level for the window. You easily know what file name this dialog / window is, just looking at the file name.
+9
source share

Have you done any timings to find out if this matters?

The problem is that, as I understand it, Glade always creates all widgets when parsing an XML file, so if you open an XML file and read only one widget, you spend a lot of resources.

Another problem is that you need to re-read the file if you want to have another instance of this widget.

The way I did this before was to put all the widgets that were created only once (for example, about the window, the main window, etc.) into one glade file, as well as separate cut-out files for widgets, which needed to be created several times.

+2
source share

I use different field files for different windows. But I keep the dialog associated with the window in the same file. As you said, the naming problem is annoying.

0
source share

I have one glade file with 2 windows. This is about 450KB in size, and I have not seen slowdown using libglademm with GTKmm.

0
source share

All Articles