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

Type App

object --+    
         |    
_AutoGenId --+
             |
object --+   |
         |   |
 _EGObject --+
             |
            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

Method Summary
  __init__(self, title, id, center, left, right, top, bottom, preferences, window_size, window_position, window_decorated, menu, toolbar, quit_callback, data_changed_callback, author, description, help, version, license, copyright, statusbar, visible)
App Constructor.
  __add_to_app_list__(self)
  __add_widget__(self, widget)
  __delete_event__(self, *args)
  __do_close__(self)
  __get_gtk_window__(self)
  __get_window__(self)
  __getitem__(self, name)
  __persistence_filename__(self)
  __setitem__(self, name, value)
  __setup_connections__(self)
  __setup_gui__(self)
  __setup_gui_bottom__(self)
  __setup_gui_center__(self)
  __setup_gui_left__(self)
  __setup_gui_menu__(self)
  __setup_gui_preferences__(self)
  __setup_gui_right__(self)
  __setup_gui_toolbar__(self)
  __setup_gui_top__(self)
  close(self)
Close application window.
  data_changed(self, widget, value)
Notify that widget changed it's value.
  file_chooser(self, action, filename, filter, multiple)
Show FileChooser and return selected file(s).
  get_title(self)
  get_visible(self)
  get_widget_by_id(self, widget_id)
Return referece to widget with provided id or None if not found.
  get_window_decorated(self)
  get_window_position(self)
  get_window_size(self)
  hide(self)
  idle_add(self, callback, *args, **kargs)
Register a function to be called when system is idle.
  io_watch(self, file, callback, on_in, on_out, on_urgent, on_error, on_hungup, *args, **kargs)
Register a function to be called after an Input/Output event.
  is_visible(self)
  load(self)
Load data to widgets from file.
  remove_event_source(self, event_id)
Remove an event generator like those created by timeout_add, idle_add or io_watch.
  remove_status_message(self, message_id)
Remove a previously displayed message.
  save(self)
Save data from widgets to file.
  set_title(self, title)
  set_visible(self, visible)
  set_window_decorated(self, value)
  set_window_position(self, *args, **kargs)
Set window position.
  set_window_size(self, *args, **kargs)
Set window size.
  show(self)
  show_about_dialog(self)
Show AboutDialog of this App.
  show_help_dialog(self)
Show HelpDialog of this App.
  show_preferences_dialog(self)
Show PreferencesDialog associated with this App.
  status_message(self, message)
Display a message in status bar and retrieve its identifier for later removal.
  timeout_add(self, interval, callback, *args, **kargs)
Register a function to be called after a given timeout/interval.
    Inherited from _EGObject
  __repr__(self)
  __str__(self)
    Inherited from _AutoGenId
  __get_id__(classobj)
(Class method)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Property Summary
  bottom
  center
  left
  menu
  preferences
  right
  statusbar
  title
  toolbar
  top
  window_decorated
  window_position
  window_size
  _widgets
    Inherited from _EGObject
  id

Class Variable Summary
int border_width = 10                                                                    
int spacing = 3                                                                     
    Inherited from _AutoGenId
int last_id_num = 0                                                                     

Instance Method Details

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

App Constructor.

        @param title: application name, to be displayed in the title bar.
        @param id: unique id to this application, or None to generate one
               automatically.
        @param center: list of widgets to be laid out vertically in the
               window's center.
        @param left: list of widgets to be laid out vertically in the
               window's left side.
        @param right: list of widgets to be laid out vertically in the
               window's right side.
        @param top: list of widgets to be laid out horizontally in the
               window's top.
        @param bottom: list of widgets to be laid out horizontally in the
               window's bottom.
        @param preferences: list of widgets to be laid out vertically in
               another window, this can be shown with L{PreferencesButton}.
        @param window_size: tuple of ( width, height ) or None to use the
               default size.
        @param window_position: tuple of ( x, y ) or None to position
               window.
        @param window_decorated: boolean used to add or remove border,
               title bar and other decorations from window.
        @param menu: a list of Menu.BaseItem subclasses.
        @param toolbar: a list of Toolbar.BaseItem subclasses.
        @param statusbar: if C{True}, an statusbar will be available and
               usable with L{status_message} method.
        @param author: the application author or list of author, used in
               L{AboutDialog}, this can be shown with L{AboutButton}.
        @param description: application description, used in L{AboutDialog}.
        @param help: help text, used in L{AboutDialog} and L{HelpDialog}, this
               can be shown with L{HelpButton}.
        @param version: application version, used in L{AboutDialog}.
        @param license: application license, used in L{AboutDialog}.
b        @param copyright: application copyright, used in L{AboutDialog}.
        @param 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.
        @param 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:
eagle._EGObject.__init__

close(self)

Close application window.

data_changed(self, widget, value)

Notify that widget changed it's value.

Probably you will not need to call this directly.

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

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

get_widget_by_id(self, widget_id)

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

idle_add(self, callback, *args, **kargs)

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, *args, **kargs)

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

load(self)

Load data to widgets from file.

Probably you will not need to call this directly.

remove_event_source(self, event_id)

Remove an event generator like those created by timeout_add, idle_add or io_watch.
Parameters:
event_id - value returned from timeout_add, idle_add or io_watch.
Returns:
True if it was removed.

remove_status_message(self, message_id)

Remove a previously displayed message.

Note: this only active if statusbar=True

See Also: status_message

save(self)

Save data from widgets to file.

Probably you will not need to call this directly.

set_window_position(self, *args, **kargs)

Set window position.

Parameters are very flexible:
  • one argument with a tuple with ( x, y )
  • two integer arguments, being x and y
  • keywords x and y, both with integers

set_window_size(self, *args, **kargs)

Set window size.

Parameters are very flexible:
  • one argument with a tuple with ( width, height )
  • two integer arguments, being width and height
  • keywords width and height, both with integers

show_about_dialog(self)

Show AboutDialog of this App.

show_help_dialog(self)

Show HelpDialog of this App.

show_preferences_dialog(self)

Show PreferencesDialog associated with this App.

status_message(self, message)

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

Note: this only active if statusbar=True

See Also: remove_status_message

timeout_add(self, interval, callback, *args, **kargs)

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

Property Details

bottom

Get Method:
get(...)
Set Method:
set(...)

center

Get Method:
get(...)
Set Method:
set(...)

left

Get Method:
get(...)
Set Method:
set(...)

menu

Get Method:
get(...)
Set Method:
set(...)

preferences

Get Method:
get(...)
Set Method:
set(...)

right

Get Method:
get(...)
Set Method:
set(...)

statusbar

Get Method:
get(...)
Set Method:
set(...)

title

Get Method:
get_title(self)
Set Method:
set_title(self, title)

toolbar

Get Method:
get(...)
Set Method:
set(...)

top

Get Method:
get(...)
Set Method:
set(...)

window_decorated

Get Method:
get_window_decorated(self)
Set Method:
set_window_decorated(self, value)

window_position

Get Method:
get_window_position(self)
Set Method:
set_window_position(self, *args, **kargs)

window_size

Get Method:
get_window_size(self)
Set Method:
set_window_size(self, *args, **kargs)

_widgets

Get Method:
get(...)
Set Method:
set(...)

Class Variable Details

border_width

Type:
int
Value:
10                                                                    

spacing

Type:
int
Value:
3                                                                     

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