gtk.glade.XMLAllows dynamic loading of user interfaces
from XML descriptions.Synopsisgtk.glade.XMLgobject.GObjectgtk.glade.XMLfnamerootNonedomain""typedict{}signal_connecthandler_namefuncsignal_autoconnectdictget_widgetnameget_widget_prefixnamerelative_filefilenameFunctionsgtk.glade.xml_new_from_bufferbuffersizeroot""domain""typedict{}gtk.glade.get_widget_namewidgetgtk.glade.get_widget_treewidgetgtk.glade.set_custom_handlerhandleruser_datagtk.glade.bindtextdomaindomainnamedirname""gtk.glade.textdomaindomainname""gtk.glade.set_custom_widget_callbacksdictAncestry+-- gobject.GObject
+-- gtk.glade.XML
gtk.glade.XML Signal Prototypesgobject.GObject Signal PrototypesDescriptionThis object represents an `instantiation' of an XML interface
description. When one of these objects is created, the XML file is read,
and the interface is created. The gtk.glade.XML object
then provides an interface for accessing the widgets in the interface by the
names assigned to them inside the XML description.The gtk.glade.XML object
can also be used to connect handlers to the named signals in the
description. Libglade also provides an interface by which it can look up
the signal handler names in the program's symbol table and automatically
connect as many handlers up as it can that way.Constructorgtk.glade.XMLfnamerootNonedomain""typedict{}fname :the XML file nameroot :the widget node in fname to
start building from (or None)domain :the translation domain for the XML file (or
"" for default)typedict :A dictionary used to lookup types (or
{} for default)Returns :a new gtk.glade.XML
objectCreates a new gtk.glade.XML object
(and the corresponding widgets) from the XML file specified by
fname. Optionally it will only build the interface
from the widget node specified by root (if it is not
None). This feature is useful if you only want to build
say a toolbar or menu from the XML file, but not the window it is embedded
in. Note also that the XML parse tree is cached to speed up creating another
gtk.glade.XML
object for the same file.Methodsgtk.glade.XML.signal_connectsignal_connecthandler_namefunchandler_name :the signal handler namefunc :the signal handler functionIn the glade interface descriptions, signal handlers are
specified for widgets by name. The signal_connect()
method allows you to connect a callback specified by
func to all signals in the gtk.glade.XML file
with the signal handler name specified by
handler_name.gtk.glade.XML.signal_autoconnectsignal_autoconnectdictdict :a mapping or an instanceThe signal_autoconnect() method is a
variation of the gtk.glade.XML.signal_connect
method. It uses Python's introspective features to look at the keys (if
dict is a mapping) or attributes (if
dict is an instance) and tries to match them with the
signal handler names given in the interface description. The callbacks
referenced by each matched key or attribute are connected to their matching
signals. The argument is called dict due to compatibility
reasons since originally only the mapping interface was supported. The
instance variant was introduced in PyGTK 2.0.gtk.glade.XML.get_widgetget_widgetnamename :the name of the widgetReturns :the widget matching the name or
NoneThe get_widget() method returns a
reference to the gtk.Widget specified
by name in the interface
description. None is returned, if
name doesn't specify a widget in the
interface.gtk.glade.XML.get_widget_prefixget_widget_prefixnamename :the prefix the widget names or
"" for all widgetsReturns :A list of widgets that match name
as the start of their name or NoneThe get_widget_prefix() method returns
a list of interface gtk.Widget objects
that have names prefixed by
name. None is returned if no
interface widget names match the prefix name.gtk.glade.XML.relative_filerelative_filefilenamefilename :a relative file pathnameReturns :the absolute file pathnameThe relative_file() method resolves the
relative pathname specified by filename, using the
directory of the XML file as a base. If filename
contains an absolute pathname, then the original file name is
returned.Functionsgtk.glade.xml_new_from_buffergtk.image_new_from_bufferbuffersizeroot""domain""typedict{}buffer :the string containing the XML buffersize :size of the stringroot :the widget node in fname to start building from
(or "")domain :the translation domain for the XML file (or
"" for default)typedict :A dictionary used to lookup types (or
{} for default)Returns :a new gtk.glade.XML
object.The gtk.glade.xml_new_from_buffer()
function creates a new gtk.glade.XML object
(and the corresponding widgets) from the string specified by
buffer. Optionally it will only build the interface
from the widget node specified by root (if it is not
""). This feature is useful if you only want to build
say a toolbar or menu from the XML document, but not the window it is
embedded in.gtk.glade.get_widget_namegtk.glade.get_widget_namewidgetwidget :a gtk.WidgetReturns :the name of the widgetThe gtk.glade.get_widget_name() function
returns the name of the gtk.Widget specified
by widget that was generated by a gtk.glade.XML
object.gtk.glade.get_widget_treegtk.glade.get_widget_treewidgetwidget :a gtk.WidgetReturns :the gtk.glade.XML
object that built widgetThis gtk.glade.get_widget_tree() function
is used to get the gtk.glade.XML object
that built the gtk.Widget specified
by widget.gtk.glade.set_custom_handlergtk.glade.set_custom_handlerhandleruser_datahandler :the custom widget handler.user_data :user data passed to the custom handler.This gtk.glade.set_custom_handler() function
allows you to override the default behaviour when a Custom widget is found in an interface.
gtk.glade.bindtextdomaingtk.glade.bindtextdomaindomainnamedirnamedomainname :the name of the application.dirname :the directory where to find locales.Returns :the value of dirnameThis gtk.glade.bindtextdomain() function allows you to use internationalisation with glade.
gtk.glade.textdomaingtk.glade.textdomaindomainnamedomainname :the name of the application.Returns :the value of domainnameThis gtk.glade.textdomain() function allows you to use internationalisation with glade.
gtk.glade.set_custom_widget_callbacksgtk.glade.set_custom_widget_callbacksdictdict :a dictionary of function names.This gtk.glade.set_custom_widget_callbacks() function
takes a dictionary of function names->functions, for an example see
PyGTK FAQ 22.7
for an example.