;ς (8QFc@sdZdkZdkZdkZdkZdkZdkiZd„Zdfd„ƒYZ dei ei fd„ƒYZ e e d„ZdS(saSupport for loading glade files from your application directory. The simplest interface will be templates.load() which will return a set of widgets loaded from $APP_DIR/Templates.glade, e.g. widgets=templates.load('main') class MyWindow: def __init__(self): self.window=widgets.getWindow('main') self.entry=widgets['text_entry'] widgets.autoConnect(self) self.window.show_all() To use a template as part of a class, derive a class from ProxyWindow class MyWindow(templates.ProxyWindow): def __init__(self, window, widgets): templates.ProxyWindow.__init__(self, window, widgets) self.cancel_button=widgets['cancel'] # ... widgets=templates.load('main') window=widgets.getWindow('main', MyWindow) NcCsJ| o d}ntii|ƒ otiiti|ƒ}n|SdS(NsTemplates.glade(sfnamesosspathsisabssjoinsroxsapp_dir(sfname((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys_get_templates_file_name$s  s ProxyWindowcBs tZdZd„Zd„ZRS(sThis acts as a proxy for a GtkWindow or GtkDialog, except that it calls the toplevel_(un)ref functions for you automatically. It is designed to wrap a window loaded from a Glade template. You can sub-class this to create your own classes.cCs:||_tiƒ|iidtiƒ|i|ƒdS(sΆAct as a proxy for window. Call toplevel_ref() and arrange for toplevel_unref to be called on destruction. The signal handlers are connected to this object.sdestroyN( swindowsselfs_windowsroxs toplevel_refsconnectstoplevel_unrefswidgetsssignal_autoconnect(sselfswindowswidgets((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys__init__1s   cCsRy|id}Wntd‚nXt||ƒot||ƒSnt|‚dS(sLGet unrecognized attributes from the window we are proxying for.s_windowN(sselfs__dict__swinsAttributeErrorshasattrsnamesgetattr(sselfsnameswin((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys __getattr__>s (s__name__s __module__s__doc__s__init__s __getattr__(((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys ProxyWindow+s  s TemplatescBs_tZdZeed„Zed„Zd„Zd„Zd„Z d„Z d„Z d„Z RS( s4A set of widget instances created from a glade file.cCsJ| ottƒ}ntii|||ƒ|o|i |ƒndS(s&A set of widget instances created from the glade file. root - top level widget to create (and all its contained widgets), fname - file name to load the glade file from dict_or_instance - either a dictionary where the signal handlers are indexed by the name of the handler in the glade file, or an instance of a class where the methods have the same names as given in the glade file. NOTE: if fname is None the glade file is loaded from Templates.glade in the app dir. N( sfnames_get_templates_file_namesNonesgladesXMLs__init__sselfsrootsdict_or_instancessignal_autoconnect(sselfsrootsfnamesdict_or_instance((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys__init__Ms cOs ||i|ƒ|||ŽSdS(s‰Return the named widget, which should be a gtk.Window. The window is tracked by the window counting system, see rox.toplevel_ref(). name - name of the widget klass - Python class to wrap the widget in args - arguments to pass to the constructor for klass after the widget kwargs - keyword arguments to pass to the constructor for klassN(sklasssselfs get_widgetsnamesargsskwargs(sselfsnamesklasssargsskwargs((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys get_windowbs cCs2|it|ƒƒ}| o t|‚n|SdS(sReturn the named widget.N(sselfs get_widgetsstrskeyswidgetsKeyError(sselfskeyswidget((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys __getitem__ps  cCstd|‚dS(s#Set a widget. Raises an exception.sread-only, cannot set N(s TypeErrorskey(sselfskeysvalue((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys __setitem__xscCstd|‚dS(s&Delete a widget. Raises an exception.sread-only, cannot delete N(s TypeErrorskey(sselfskey((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys __delitem__|scCsA|idƒ}g}x!|D]}|i|iƒƒqW|SdS(s!Return list of all named widgets.sN(sselfsget_widget_prefixswsskswsappendsget_name(sselfswssksw((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pyskeys€scCs|idƒSdS(Ns(sselfsget_widget_prefix(sself((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pysvalues‰sccs(|idƒ}x|D] }|VqWdS(Ns(sselfsget_widget_prefixswssw(sselfswssw((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys itervaluesŒs( s__name__s __module__s__doc__sNones__init__s ProxyWindows get_windows __getitem__s __setitem__s __delitem__skeyssvaluess itervalues(((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys TemplatesJs      cCst|||ƒSdS(skLoad the templates file and return the set of widgets. root - name of top level widget (and all child widgets) to create fname - path to templates file: If it is an absolute path name then load it, if a relative path name load that from the appdir or if None the load $APP_DIR/Templates.glade. dict_or_instance - what to use to connect the signals. It is either a dictionary where the signal handlers are indexed by the name of the handler in the glade file, or an instance of a class where the methods have the same names as given in the glade file. N(s Templatessrootsfnamesdict_or_instance(srootsfnamesdict_or_instance((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pysload‘s (s__doc__sosssysserrnosUserDictsroxs gtk.gladesglades_get_templates_file_names ProxyWindowsXMLs DictMixins TemplatessNonesload( s Templatessroxserrnos_get_templates_file_namesloadsglades ProxyWindowssyssUserDictsos((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/templates.pys?s     G