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

Class AutoGlade

source code

AutoGlade main class.

This is the main AutoGlade class.

Conventions

These are the conventions used to relate Glade files.

Instance Methods [hide private]
 
__init__(self, glade=None, root=None, autorun=True, autoinit=None, autoinitSplit=':', autodump='text')
Constructor
source code
 
__getitem__(self, key)
__getitem__
source code
 
__getattr__(self, name)
__getattr__
source code
 
__call__(args) source code
 
__getTopLevelWidgetNames(self)
Get the top level widget names.
source code
 
__getSignalHandlers(self) source code
 
__getSignalHandlerFromAGOKey(self, agokey)
Get signal handler from Auto Glade Object key
source code
 
__autoConnectAGO(self, agokey, handler='auto', signal='auto') source code
 
__autoConnect(self) source code
 
__getTopLevelWidgets(self)
Get the top level widgets parsing the glade XML file.
source code
 
__mapAutoInvokeWidgetNames(self)
Map the autoInvoke names (widget:auto:method) to its plain form (widget).
source code
 
__fixComboBoxNotShowingActiveItem(self)
Fix a problem found with Combo Box widgets.
source code
 
__getAboutDialog(self)
Get the about dialog from the internal list of top level widgets and set the AutoGladeObject accordingly.
source code
 
__getPreferencesDialog(self)
Get the preferences dialog from the internal list of top level widgets and set the AutoGladeObject accordingly.
source code
 
__getStockItem(self, agokey, stock, gtkClass=gtk.Widget) source code
 
__getStockItems(self)
Get stock items.
source code
 
__findStockItem(self, stock, gtkClass=gtk.Widget)
Find a stock item in the elements tree.
source code
 
getGladeInterface(self) source code
 
getDom(self) source code
 
getTopLevelWidgets(self) source code
 
getSignalHandlers(self) source code
 
getWidgetNames(self, widgetClassFilter=None, widgetCanonicalNames=False)
List the widget names possible filtered.
source code
 
autoInit(self, autoinit=None)
Default autoInit method, can be overriden by children.
source code
 
on_cancelbutton_clicked(self, widget)
Default handler for Cancel buttons clicked signal.
source code
 
on_autosensitize(self, widget, targetWidget)
Toggle the 'sensitive' property on a target widget
source code
 
on_autoshow(self, widget, targetWidget)
Toggle the 'visible' property on a target widget
source code
 
on_automenuitem_activate(self, widget, *args)
Default handler for menu items activate signal
source code
 
on_autobutton_clicked(self, widget, *args)
on_autobutton_clicked
source code
 
on_autotoolbutton_clicked(self, widget)
on_autotoolbutton_clicked
source code
 
autoInvoke(self, widget, *args)
Auto invoke the method codified in widget name
source code
 
on_autodialog_response(self, widget, response, *args)
Default handler for gtk.Dialog response signal
source code
 
on_autobuttonexpandall_clicked(self, widget) source code
 
on_autobuttoncollapseall_clicked(self, widget) source code
 
autoRun(self)
auto run the graphical user interface
source code
 
autoErrorDialog(self, ex) source code
 
autoWarningDialog(self, msg, message_format=None) source code
 
autoQuestionDialog(self, msg, buttons=gtk.BUTTONS_YES_NO) source code
 
autoInfoDialog(self, msg="No message", message_format=None) source code
 
autoAddTimeout(self, msecs=1000, method=None, *args) source code
 
autoProgressBar(self, args) source code
 
isInputClass(self, widgetClass) source code
 
autoDumpText(self, var, val) source code
 
autoDumpShell(self, var, val) source code
 
autoDumpValues(self) source code
 
autoDialog(self, widget, *args) source code
 
autoHelp(self) source code
 
autoQuit(self, widget, *args) source code
 
autoAbout(self, widget, *args) source code
 
autoNew(self, widget, *args) source code
 
autoOpen(self, widget, *args) source code
 
autoSaveas(self, widget, *args) source code
 
autoSave(self, widget, *args) source code
 
autoCopy(self, widget, *args) source code
 
autoCut(self, widget, *args) source code
 
autoPaste(self, widget, *args) source code
 
autoDelete(self, widget, *args) source code
 
autoPreferences(self, widget, *args) source code
 
printval(self, *args) source code
 
new(self, widget) source code
 
open(self, filename, widget) source code
 
save(self, filename, widget) source code
 
abbreviations(self) source code
Class Variables [hide private]
bool DEBUG = False
Set debugging output
  __reSetTreeviewCell = re.compile(AUTO_TREEVIEW_SET_CELL_RE)
  __topLevelWidgetNames = []
  __mainTopLevelWidget = None
  __autoGladeObjects = {}
  __topLevelWidgets = {}
  __signalHandlers = {}
  __autoDumpMap = {}
  __gconf = None
  __dump = {}
  __autoArgs = ''
  __autoProperties = {}
  __autoStockItems = {}
  cellText = gtk.CellRendererText()
  cellPixbuf = gtk.CellRendererPixbuf()
  cellToggle = gtk.CellRendererToggle()
Instance Variables [hide private]
str __reAutoInvoke = re.compile(AUTO_INVOKE_RE)
The regular expression to parse the Glade widget name
gtk.Widget __menuItemAbout
Stock menu item about
gtk.Widget __menuItemPreferences
Stock menu item preferences
gtk.Widget __menuItemQuit
Stock menu item quit
Method Details [hide private]

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

source code 

Constructor

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

__getitem__(self, key)
(Indexing operator)

source code 

__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 (str) - The key to search
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:

__getattr__(self, name)
(Qualification operator)

source code 

__getattr__

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

__getTopLevelWidgetNames(self)

source code 

Get the top level widget names.

Glade XML files have not been parsed yet.

__getSignalHandlerFromAGOKey(self, agokey)

source code 

Get signal handler from Auto Glade Object key

This method obtains the signal handler from the Auto Galde Object key in camel case, assuming the handler method named is formed by the last component of the camel case key, capitalized and with the prefix 'auto' prepended.

Examples:
       agokey = menuItemOpen}
       method = autoOpen}

       agokey = toolButtonSaveas # note the lowercase in as}
       method = autoSaveas
Parameters:
  • agokey (str) - The Auto Glade Object key
Returns:
The signal handler method instance or None if there's no match

__getTopLevelWidgets(self)

source code 
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)

source code 
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

__fixComboBoxNotShowingActiveItem(self)

source code 

Fix a problem found with Combo Box widgets.

Is this a libglade bug ?

__getPreferencesDialog(self)

source code 

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

To find it, widget name is matched against 'preferences' ignoring case.

__findStockItem(self, stock, gtkClass=gtk.Widget)

source code 

Find a stock item in the elements tree.

WARNING: Right now only find the first widget if more than one satisfies the conditions
Parameters:
  • stock (str) - The stock item to find

getWidgetNames(self, widgetClassFilter=None, widgetCanonicalNames=False)

source code 

List the widget names possible filtered.

This method was an idea suggested by Charles Edward Pax and Christopher Pax from Gladex project (http://www.openphysics.org/~gladex/)

autoInit(self, autoinit=None)

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

on_cancelbutton_clicked(self, widget)

source code 
Default handler for Cancel buttons clicked signal.
Parameters:
  • widget (gtk.Widget) - The widget receiving the signal

on_automenuitem_activate(self, widget, *args)

source code 

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 (gtk.Widget) - The widget receiving the signal

on_autobutton_clicked(self, widget, *args)

source code 
on_autobutton_clicked
Parameters:
  • widget (gtk.Widget) - The widget receiving the signal

on_autotoolbutton_clicked(self, widget)

source code 
on_autotoolbutton_clicked
Parameters:
  • widget (gtk.Widget) - The widget receiving the signal

autoInvoke(self, widget, *args)

source code 

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 methods namePre, name and namePost are invoked in order (if exist) and if and only if the predecesor returns True.
Parameters:
  • widget (gtk.Widget) - The widget receiving the signal

on_autodialog_response(self, widget, response, *args)

source code 

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

These are the 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 (gtk.Widget) - The widget receiving the signal
  • response (int) - The dialog response (i.e.: button pressed)

autoRun(self)

source code 

auto run the graphical user interface

Runs the graphical user interface automatically. There ase some special cases contempled.
  1. If there's no __mainTopLevelWidget then it does nothing
  2. 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
  3. if the __mainTopLevelWidget is not a gtk.Dialog then the main GTK loop is entered