Module eagle :: Class App
[hide private]
[frames] | no frames]

Class App
source code

object --+    
         |    
 _EGObject --+
             |
object --+   |
         |   |
 AutoGenId --+
             |
            App

An application window.

This is the base of Eagle programs, since it will hold every graphical component.

An App window is split in 5 areas:

the first 3 have a vertical layout, the other have horizontal layout. Every area has its own scroll bars that are shown automatically when need.

Also provided is an extra area, that is shown in another window. This is the preferences area. It have a vertical layout and components that hold data are made persistent automatically. You should use PreferencesButton to show this area.

Extra information like author, description, help, version, license and copyright are used in specialized dialogs. You may show these dialogs with AboutButton and HelpButton.

Widgets can be reach with get_widget_by_id, example:
>>> app = App( "My App", left=Entry( id="entry" ) )
>>> app.get_widget_by_id( "entry" )
Entry( id='entry', label='entry', value='' )
You may also reach widgets using dict-like syntax, but with the special case for widgets that hold data, these will be provided using their set_data and get_data, it make things easier, but be careful to don't misuse it!. Example:
>>> app= App( "My App", left=Entry( id="entry" ),
...           right=Canvas( "canvas", 300, 300 ) )
>>> app[ "entry" ]
''

>>> app[ "entry" ] = "text"
>>> app[ "entry" ]
'text'

>>> app[ "canvas" ]
Canvas( id='canvas', width=300, height=300, label='' )

>>> app[ "canvas" ].draw_text( "hello" )
>>> app[ "entry" ].get_value() # will fail, since it's a data widget


Instance Methods [hide private]
  __init__(self, title, id=None, center=None, left=None, right=None, top=None, bottom=None, preferences=None, window_size=(800,600), quit_callback=None, data_changed_callback=None, author=None, description=None, help=None, version=None, license=None, copyright=None, statusbar=False)
App Constructor.
  __getitem__(self, name)
  __setitem__(self, name, value)
  get_widget_by_id(self, widget_id)
Return referece to widget with provided id or None if not found.
  show_about_dialog(self)
Show AboutDialog of this App.
  show_help_dialog(self)
Show HelpDialog of this App.
  file_chooser(self, action, filename=None, filter=None, multiple=False)
Show FileChooser and return selected file(s).
  show_preferences_dialog(self)
Show PreferencesDialog associated with this App.
  __get_window__(self)
  __add_to_app_list__(self)
  __add_widget__(self, widget)
  __setup_gui__(self)
  __setup_gui_left__(self)
  __setup_gui_right__(self)
  __setup_gui_center__(self)
  __setup_gui_top__(self)
  __setup_gui_bottom__(self)
  __setup_gui_preferences__(self)
  __setup_connections__(self)
  data_changed(self, widget, value)
Notify that widget changed it's value.
  __do_close__(self)
  __delete_event__(self, *args)
  __persistence_filename__(self)
  save(self)
Save data from widgets to file.
  load(self)
Load data to widgets from file.
  close(self)
Close application window.
  status_message(self, message)
Display a message in status bar and retrieve its identifier for later removal.
  remove_status_message(self, message_id)
Remove a previously displayed message.
  timeout_add(self, interval, callback)
Register a function to be called after a given timeout/interval.
  idle_add(self, callback)
Register a function to be called when system is idle.
  io_watch(self, file, callback, on_in=False, on_out=False, on_urgent=False, on_error=False, on_hungup=False)
Register a function to be called after an Input/Output event.
  remove_event_source(self, event_id)
Remove an event generator like those created by timeout_add, idle_add or io_watch.

Inherited from _EGObject: __repr__, __str__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__


Class Methods [hide private]

Inherited from AutoGenId: __get_id__


Class Variables [hide private]
border_width  
spacing  
title  
left  
right  
top  
bottom  
center  
preferences  
statusbar  
_widgets  

Inherited from _EGObject: id

Inherited from AutoGenId: last_id_num

Inherited from object: __class__


Method Details [hide private]

__init__(self, title, id=None, center=None, left=None, right=None, top=None, bottom=None, preferences=None, window_size=(800,600), quit_callback=None, data_changed_callback=None, author=None, description=None, help=None, version=None, license=None, copyright=None, statusbar=False)
(Constructor)

source code 
App Constructor.
Parameters:
  • title - application name, to be displayed in the title bar.
  • id - unique id to this application, or None to generate one automatically.
  • center - list of widgets to be laid out vertically in the window's center.
  • left - list of widgets to be laid out vertically in the window's left side.
  • right - list of widgets to be laid out vertically in the window's right side.
  • top - list of widgets to be laid out horizontally in the window's top.
  • bottom - list of widgets to be laid out horizontally in the window's bottom.
  • preferences - list of widgets to be laid out vertically in another window, this can be shown with PreferencesButton.
  • window_size - tuple of ( width, height ) or None to use the minimum size.
  • statusbar - if True, an statusbar will be available and usable with status_message method.
  • author - the application author or list of author, used in AboutDialog, this can be shown with AboutButton.
  • description - application description, used in AboutDialog.
  • help - help text, used in AboutDialog and HelpDialog, this can be shown with HelpButton.
  • version - application version, used in AboutDialog.
  • license - application license, used in AboutDialog.
  • copyright - application copyright, used in AboutDialog.
  • quit_callback - function (or list of functions) that will be called when application is closed. Function will receive as parameter the reference to App. If return value is False, it will abort closing the window.
  • data_changed_callback - function (or list of functions) that will be called when some widget that holds data have its data changed. Function will receive as parameters:
    • App reference
    • Widget reference
    • new value
Overrides: _EGObject.__init__

__getitem__(self, name)
(Indexing operator)

source code 

__setitem__(self, name, value)
(Index assignment operator)

source code 

get_widget_by_id(self, widget_id)

source code 
Return referece to widget with provided id or None if not found.

show_about_dialog(self)

source code 
Show AboutDialog of this App.

show_help_dialog(self)

source code 
Show HelpDialog of this App.

file_chooser(self, action, filename=None, filter=None, multiple=False)

source code 
Show FileChooser and return selected file(s).
Parameters:
  • action - must be one of ACTION_* as defined in FileChooser.
  • filter - a pattern (ie: '*.png'), mime type or a list.

See Also: FileChooser

show_preferences_dialog(self)

source code 
Show PreferencesDialog associated with this App.

__get_window__(self)

source code 

__add_to_app_list__(self)

source code 

__add_widget__(self, widget)

source code 

__setup_gui__(self)

source code 

__setup_gui_left__(self)

source code 

__setup_gui_right__(self)

source code 

__setup_gui_center__(self)

source code 

__setup_gui_top__(self)

source code 

__setup_gui_bottom__(self)

source code 

__setup_gui_preferences__(self)

source code 

__setup_connections__(self)

source code 

data_changed(self, widget, value)

source code 

Notify that widget changed it's value.

Probably you will not need to call this directly.

__do_close__(self)

source code 

__delete_event__(self, *args)

source code 

__persistence_filename__(self)

source code 

save(self)

source code 

Save data from widgets to file.

Probably you will not need to call this directly.

load(self)

source code 

Load data to widgets from file.

Probably you will not need to call this directly.

close(self)

source code 
Close application window.

status_message(self, message)

source code 
Display a message in status bar and retrieve its identifier for later removal.

See Also: remove_status_message

Note: this only active if statusbar=True

remove_status_message(self, message_id)

source code 
Remove a previously displayed message.

See Also: status_message

Note: this only active if statusbar=True

timeout_add(self, interval, callback)

source code 
Register a function to be called after a given timeout/interval.
Parameters:
  • interval - milliseconds between calls.
  • callback - function to call back. This function gets as argument the app reference and must return True to keep running, if False is returned, it will not be called anymore.
Returns:
id number to be used in remove_event_source

idle_add(self, callback)

source code 

Register a function to be called when system is idle.

System is idle if there is no other event pending.
Parameters:
  • callback - function to call back. This function gets as argument the app reference and must return True to keep running, if False is returned, it will not be called anymore.
Returns:
id number to be used in remove_event_source

io_watch(self, file, callback, on_in=False, on_out=False, on_urgent=False, on_error=False, on_hungup=False)

source code 
Register a function to be called after an Input/Output event.
Parameters:
  • file - any file object or file descriptor (integer).
  • callback - function to be called back, parameters will be the application that generated the event, the file that triggered it and on_in, on_out, on_urgent, on_error or on_hungup, being True those that triggered the event. The function must return True to be called back again, otherwise it is automatically removed.
  • on_in - there is data to read.
  • on_out - data can be written without blocking.
  • on_urgent - there is urgent data to read.
  • on_error - error condition.
  • on_hungup - hung up (the connection has been broken, usually for pipes and sockets).
Returns:
id number to be used in remove_event_source

remove_event_source(self, event_id)

source code 
Remove an event generator like those created by timeout_add, idle_add or io_watch.
Parameters:
Returns:
True if it was removed.

Class Variable Details [hide private]

border_width

Value:
10                                                                     
      

spacing

Value:
3                                                                      
      

title

Value:
_gen_ro_property("title")                                              
      

left

Value:
_gen_ro_property("left")                                               
      

right

Value:
_gen_ro_property("right")                                              
      

top

Value:
_gen_ro_property("top")                                                
      

bottom

Value:
_gen_ro_property("bottom")                                             
      

center

Value:
_gen_ro_property("center")                                             
      

preferences

Value:
_gen_ro_property("preferences")                                        
      

statusbar

Value:
_gen_ro_property("statusbar")                                          
      

_widgets

Value:
_gen_ro_property("_widgets")