Chapter 9. The embedded python

Reference

GabyWindow object

This object is used to hold a window as shown in Gaby. It has methods for common window actions (move, resize, destroy) as well as for actions specific to Gaby (bind, unbind, ...). It also has attributes to describe it closer (type, name, subtable, ...).

Methods

move

move (i, i)

This method moves the window to (i, i) (respectively x and y) OBSOLETE!: use gtk methods on window.gtkwindow

resize

resize (i, i)

This method resizes the window to (i, i) (respectively width and height) OBSOLETE!: use gtk methods on window.gtkwindow

destroy

destroy ()

This method destroy the window

add_bound_window

add_bound_window (w)

This method binds the window given as arg to the window

remove_bound_window

remove_bound_window (w)

This method unbinds the window given as arg from the window

set_records_list

set_records_list ( (i,i,i,...) )

This method reduces the amount of viewable records to the records with ids (normal or fast) from the list. This is especially useful for things like advanced filters. Note that using fast id will really be faster.

get_widget

get_widget (s)

This method returns the GUI widget (actually a GtkObject) matching the given string. The strings you can give depends upon the used view.

Items

type

this item holds the type of the view

i18n_type

this item holds the type of the view translated in the user's favortie language

subtable

this item holds the subtable used by the window

id

this item holds the id of the record currently shown. Unlike other attributes this one is not read-only.

name

this item holds the name of the window, as shown in its title bar

can_restrict_list

this item holds a boolean value that is set if the window has the 'what' attribute available.

gtkwindow

this item holds a GtkWindow reprensenting the physical window itself

restricted_list

This item is the place to set a 'restricted list' of records to show in a window (this is a duplicated set_records_list)

GabySubTable object

This object is used to hold a window as shown in Gaby. It has methods to access (both get and set) particular records, to move within the records, ... It also has attributes to describe it closer (name, fields, ...).

Methods

get_record_no

get_record_no (i [, b] )

This methods returns the record (list of strings) whose id (or 'fast id') is i from the subtable. If b is set to TRUE the list is filled using Python types matching in the best possible way the record type.

add_record

add_record (r)

This method adds the given record @r to the subtable. It returns the new record's id.

delete_record

delete_record (id)

This method removes the record whose id is @id from the subtable.

set_record_no

set_record_no (i, r)

This method sets the record whose id (or 'fast id') is i from the subtable to the record (list of strings) r. If id is 0 then the record is added to the table. This method returns the _real_ id. Comment: it doesn't touch to 'Record' and 'Records' fields

get_next_record

get_next_record (i)

This methods returns the id of the record directly following the record whose id (_not_ fast id) is i in the subtable

get_previous_record

get_previous_record (i)

This methods returns the id of the record directly preceding the record whose id (_not_ fast id) is i in the subtable

get_first_record

get_first_record ()

This methods returns the id of the first record in the subtable.

get_last_record

get_last_record ()

This methods returns the id of the last record in the subtable.

records_list

records_list ()

This methods returns the list (PyList) of the id of the records in the subtable.

fast_records_list

fast_records_list ()

This methods returns the list (PyList) of the 'fast id' of the records in the subtable. Comments on 'fast id': they are slightly faster than 'normal' ids but there are drawbacks : you can't record_{add,delete} a record and then reuse a list you got previously. (example: on a table with around 2600 records it was twice faster (simply listing))

create_new_window

create_new_window (s)

This methods creates (then shows) a new window of the type given by s ('form', 'xlist', ...) and fill it with the data from the subtable.

save

save ()

This methods saves the subtable on disk.

Items

name

this item holds the name of the subtable

i18n_name

this item holds the name of the subtable translated in the user's favorite language

fields

this item holds a tuple (_not_ list !) with the names of the subtable's fields.

dict_fields

this item holds a dict with the fields numbers referenced by the fields names.

i18n_fields

this item holds a tuple (_not_ list !) with the names translated in the user's favorite language of the subtable's fields.

dict_i18n_fields

this item holds a dict with the fields numbers referenced by the fields names translated in the user's favorite language.

table

this item holds the name of the table hidden behind the subtable

Standalone functions

hello_world

hello_world ()

Prints 'Hello, World !'

load_database

load_database (s)

This function loads the database 's' (ie both descfile and datas). It will fail if a database is already loaded.

get_subtable_by_name

get_subtable_by_name (s)

This functions returns the subtable with the given name

get_main_window

get_main_window ()

This function returns the main window (== the first created window)

get_current_window

get_current_window ()

This functions returns the focused window (if none has the focus, it is equivalent to get_main_window)

exit_gaby

exit_gaby ()

This function exits Gaby cleanly (asking confirmation if there were unsaved record(s))

get_subtables_list

get_subtables_list ()

This functions returns a list filled with the name of the subtables

get_windows_list

get_windows_list ()

This functions returns a list of GabyWindow objects

message_dialog

message_dialog (i, s)

This functions pops up a message box with the given message, the first arg is an integer representing the message type while the second is a string whose purpose is determined by the value of the integer

select_subtable

select_subtable ()

This function lets the user select a subtable in a clean manner. It returns the subtable or 'None' if the user selected canceled the operation.

gettext

gettext (s)

This functions returns a translation of the given string