Package src :: Module autoglade :: Class AutoGlade
[show private | hide private]
[frames | no frames]

Class AutoGlade


AutoGlade main class.

This is the main AutoGlade class.

Conventions

These are the conventions used to relate Glade files.
Method Summary
  __init__(self, glade, root, autorun, autoinit, autodump)
Constructor
  __call__(args)
  __getattr__(self, name)
__getattr__
  __getitem__(self, key)
__getitem__
  abbreviations(self)
  autoDumpShell(self, var, val)
  autoDumpText(self, var, val)
  autoDumpValues(self)
  autoErrorDialog(self, ex)
  autoInfoDialog(self, msg, message_format)
  autoInit(self, autoinit)
Default autoInit method, can be overriden by children.
  autoInvoke(self, widget, *args)
Auto invoke the method codified in widget name
  autoQuestionDialog(self, msg, buttons)
  autoRun(self)
auto run the graphical user interface
  autoWarningDialog(self, msg, message_format)
  getDom(self)
  getGladeInterface(self)
  getSignalHandlers(self)
  getTopLevelWidgets(self)
  help(self)
  isInputClass(self, widgetClass)
  on_autobutton_clicked(self, widget, *args)
on_autobutton_clicked
  on_autobuttoncollapseall_clicked(self, widget)
  on_autobuttonexpandall_clicked(self, widget)
  on_autodialog_response(self, widget, response, *args)
Default handler for gtk.Dialog response signal
  on_automenuitem_activate(self, widget, *args)
Default handler for menu items activate signal
  on_autosensitize(self, widget, targetWidget)
Toggle the 'sensitive' property on a target widget
  on_autoshow(self, widget, targetWidget)
Toggle the 'visible' property on a target widget
  on_autotoolbutton_clicked(self, widget)
on_autotoolbutton_clicked
  on_cancelbutton_clicked(self, widget)
Default handler for Cancel buttons clicked signal.
  quit(self, widget, *args)
  VOID__getAboutDialogElement(self)
This method uses a value set by self.__getAboutDialogWidget
  VOID_get_children(self, widget)
  VOID_printWidgetTree(self, widget)
  __autoConnect(self)
  __findStockItem(self, stock, gtkClass)
Find a stock item in the elements tree.
  __fixComboBoxNotShowingActiveItem(self)
Fix a problem found with Combo Box widgets.
  __getAboutDialog(self)
Get the about dialog from the internal list of top level widgets and set the AutoGladeObject accordingly.
  __getButtonAbout(self)
Set self.__buttonAbout value with the stock item gtk-about if found.
  __getMenuItemAbout(self)
Set self.__menuItemAbout value with the stock item gtk-about if found.
  __getMenuItemQuit(self)
Set self.__menuItemQuit value with the stock item gtk-quit if found.
  __getSignalHandlers(self)
  __getTopLevelWidgetNames(self)
Get the top level widget names.
  __getTopLevelWidgets(self)
Get the top level widgets parsing the glade XML file.
  __mapAutoInvokeWidgetNames(self)
Map the autoInvoke names (widget:auto:method) to its plain form (widget).

Instance Variable Summary
gtk.Widget __menuItemAbout: Stock menu item about
gtk.Widget __menuItemQuit: Stock menu item quit
str __reAutoInvoke: The regular expression to parse the Glade widget name

Class Variable Summary
bool DEBUG: Set debugging output
NoneType _AutoGlade__aboutDialog = None                                                                  
dict _AutoGlade__autoDumpMap = {}
NoneType _AutoGlade__buttonAbout = None                                                                  
NoneType _AutoGlade__gconf = None                                                                  
NoneType _AutoGlade__mainTopLevelWidget = None                                                                  
NoneType _AutoGlade__menuItemAbout = None                                                                  
NoneType _AutoGlade__menuItemQuit = None                                                                  
SRE_Pattern _AutoGlade__reAutoInvoke = (.*):auto:([^:]*)(:(.+))?
SRE_Pattern _AutoGlade__reSetTreeviewCell = setTreeview(.+)Cell(\d+)...
dict _AutoGlade__signalHandlers = {}
list _AutoGlade__topLevelWidgetNames = []
dict _AutoGlade__topLevelWidgets = {}

Method Details

__init__(self, glade=None, root=None, autorun=True, autoinit=None, autodump='text')
(Constructor)

Constructor

Constructs the AutoGlade object based on the arguments passed.
Parameters:
glade - The glade filename, defaults to the name of the class. Default None
           (type=str)
root - The root widget name. Default None.
           (type=str)
autorun - Will autoglade auto run the GUI ?
           (type=boolean)
autoinit - Autoinit initialization string
           (type=str)
autodump - Autodump type output format (i.e.: text, shell)
           (type=str)

__getattr__(self, name)
(Qualification operator)

__getattr__

Provides self.name.method() access
Parameters:
name - Item name
           (type=str)
Returns:
Returns __getitem__(name)

__getitem__(self, key)
(Indexing operator)

__getitem__

Provides self['name'].method() access. If the key starts with on_ then the corresponding method is executed instead of returning the attribute value.
Parameters:
key - The key to search
           (type=str)
Returns:
if key starts with 'on_' returns the value of the execution of self.key, if key matches AUTO_TREEVIEW_SET_CELL_RE (or whatever self.__reSetTreeviewCell has compiled in) then returns an instance of AutoTreeviewSetCell or returns the corresponding widget if exists, otherwise raise an AutoGladeAttributeError.
Raises:
AutoGladeAttributeError - If the key is not found

autoInit(self, autoinit=None)

Default autoInit method, can be overriden by children.
Parameters:
autoinit - The string containing autoinit commands
           (type=str)

autoInvoke(self, widget, *args)

Auto invoke the method codified in widget name

Auto invoke the method codified and described in the Glade widget name. The pattern string is described by the regular expression in self.__reAutoInvoke which typically is '(.*):auto:(.*)' or everything before ':auto:' is the standard widget name, and everything after is the method name or widget (in the case of gtk.Dialog) to be invoked.

The the methods namePre, name amd namePost are invoked in order (if exist) and if and only if the predecesor returns True.
Parameters:
widget - The widget receiving the signal
           (type=gtk.Widget)

autoRun(self)

auto run the graphical user interface

Runs the graphical user interface automatically. There ase some special cases contempled.

#. If there's no __mainTopLevelWidget then it does nothing

#. If the __mainTopLevelWidget is a gtk.Dialog then the dialog box is run. Loops forever until one of the values of a valid response is received, then return this value

# if the __mainTolLvelWidget is not a gtk.Dialog then the main GTK loop is entered

on_autobutton_clicked(self, widget, *args)

on_autobutton_clicked
Parameters:
widget - The widget receiving the signal
           (type=gtk.Widget)

on_autodialog_response(self, widget, response, *args)

Default handler for gtk.Dialog response signal

This is a handler method intended to be a simple dialog handler. response signal of widget must be connected to this method and the user data parameter must be left untouched (as of Glade 3.0 and libglade 2).

Note: Perhaps this method should set a Singleton object value to the response received

gtk response values

gtk.RESPONSE_NONE=-1 gtk.RESPONSE_REJECT=-2 gtk.RESPONSE_ACCEPT=-3 gtk.RESPONSE_DELETE_EVENT=-4 gtk.RESPONSE_OK=-5 gtk.RESPONSE_CANCEL=-6 gtk.RESPONSE_CLOSE=-7 gtk.RESPONSE_YES=-8 gtk.RESPONSE_NO=-9 gtk.RESPONSE_APPLY=-10 gtk.RESPONSE_HELP=-11
Parameters:
widget - The widget receiving the signal
           (type=gtk.Widget)
response - The dialog response (i.e.: button pressed)
           (type=int)

on_automenuitem_activate(self, widget, *args)

Default handler for menu items activate signal

This is a handler method intended to be a simple menu item handler. The idea is to simplify handling menu items usually connected to dialog boxes. activate signal on the menu item object must point to this function and user data parameter of this signal must point to the object to call. In the case of a dialog, user data parameter is the dialog object which this method will run.

This can also be used (and it's used by autoInvoke) in gtk.ToolButton objects.
Parameters:
widget - The widget receiving the signal
           (type=gtk.Widget)

on_autosensitize(self, widget, targetWidget)

Toggle the 'sensitive' property on a target widget

on_autoshow(self, widget, targetWidget)

Toggle the 'visible' property on a target widget

on_autotoolbutton_clicked(self, widget)

on_autotoolbutton_clicked
Parameters:
widget - The widget receiving the signal
           (type=gtk.Widget)

on_cancelbutton_clicked(self, widget)

Default handler for Cancel buttons clicked signal.
Parameters:
widget - The widget receiving the signal
           (type=gtk.Widget)

VOID__getAboutDialogElement(self)

This method uses a value set by self.__getAboutDialogWidget

__findStockItem(self, stock, gtkClass=<type 'gtk.Widget'>)

Find a stock item in the elements tree.
Parameters:
stock - The stock item to find
           (type=str)

__fixComboBoxNotShowingActiveItem(self)

Fix a problem found with Combo Box widgets.

Is this a libglade bug ?

__getAboutDialog(self)

Get the about dialog from the internal list of top level widgets and set the AutoGladeObject accordingly.

__getButtonAbout(self)

Set self.__buttonAbout value with the stock item gtk-about if found.

__getMenuItemAbout(self)

Set self.__menuItemAbout value with the stock item gtk-about if found.

__getMenuItemQuit(self)

Set self.__menuItemQuit value with the stock item gtk-quit if found.

__getTopLevelWidgetNames(self)

Get the top level widget names.

Glade XML files have not been parsed yet.

__getTopLevelWidgets(self)

Get the top level widgets parsing the glade XML file. The widget trees (one for every top level widget) are also created in this operation.

__mapAutoInvokeWidgetNames(self)

Map the autoInvoke names (widget:auto:method) to its plain form (widget). Invoke 'auto:init' method if present. Connect 'auto:sensitize' signals. Connect signal for menu items (and tool buttons ?) if not connected

Instance Variable Details

__menuItemAbout

Stock menu item about
Type:
gtk.Widget

__menuItemQuit

Stock menu item quit
Type:
gtk.Widget

__reAutoInvoke

The regular expression to parse the Glade widget name
Type:
str

Class Variable Details

DEBUG

Set debugging output
Type:
bool
Value:
True                                                                   

_AutoGlade__aboutDialog

Type:
NoneType
Value:
None                                                                  

_AutoGlade__autoDumpMap

Type:
dict
Value:
{}                                                                     

_AutoGlade__buttonAbout

Type:
NoneType
Value:
None                                                                  

_AutoGlade__gconf

Type:
NoneType
Value:
None                                                                  

_AutoGlade__mainTopLevelWidget

Type:
NoneType
Value:
None                                                                  

_AutoGlade__menuItemAbout

Type:
NoneType
Value:
None                                                                  

_AutoGlade__menuItemQuit

Type:
NoneType
Value:
None                                                                  

_AutoGlade__reAutoInvoke

Type:
SRE_Pattern
Value:
(.*):auto:([^:]*)(:(.+))?                                              

_AutoGlade__reSetTreeviewCell

Type:
SRE_Pattern
Value:
setTreeview(.+)Cell(\d+)                                               

_AutoGlade__signalHandlers

Type:
dict
Value:
{}                                                                     

_AutoGlade__topLevelWidgetNames

Type:
list
Value:
[]                                                                     

_AutoGlade__topLevelWidgets

Type:
dict
Value:
{}                                                                     

Generated by Epydoc 2.1 on Sun Sep 30 22:02:21 2007 http://epydoc.sf.net