3 Module that provides an object oriented abstraction to pygtk and gtkbuilder
4 Copyright (C) 2009 Michael Vogt
5 based on ideas from SimpleGladeBuilder by Sandino Flores Moreno
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 # based on SimpleGladeApp
30 class SimpleGtkbuilderApp:
32 def __init__(self, path):
33 self.builder = gtk.Builder()
34 self.builder.add_from_file(path)
35 self.builder.connect_signals(self)
36 for o in self.builder.get_objects():
37 if issubclass(type(o), gtk.Buildable):
38 name = gtk.Buildable.get_name(o)
39 setattr(self, name, o)
41 print >>sys.stderr, "WARNING: can not get name for '%s'" % o
45 Starts the main loop of processing events checking for Control-C.
47 The default implementation checks wheter a Control-C is pressed,
48 then calls on_keyboard_interrupt().
50 Use this method for starting programs.
54 except KeyboardInterrupt:
55 self.on_keyboard_interrupt()
57 def on_keyboard_interrupt(self):
59 This method is called by the default implementation of run()
60 after a program is finished by pressing Control-C.