<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >The embedded python</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Gaby's documentation" HREF="index.html"><LINK REL="UP" TITLE="Introduction" HREF="c139.html"><LINK REL="PREVIOUS" TITLE="Script-fus" HREF="c227.html"><LINK REL="NEXT" TITLE="Gaby Developers' Guide" HREF="p489.html"></HEAD ><BODY CLASS="CHAPTER" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Gaby's documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="c227.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="p489.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="CHAPTER" ><H1 ><A NAME="PYTHON" ></A >Chapter 1. The embedded python</H1 ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="AEN276" >1.1. Reference</A ></H1 ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN278" >1.1.1. GabyWindow object</A ></H2 ><P >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, ...).</P ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN281" >1.1.1.1. Methods</A ></H3 ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN283" >1.1.1.1.1. move</A ></H4 ><P ><CODE CLASS="FUNCTION" >move</CODE > (i, i)</P ><P >This method moves the window to (i, i) (respectively x and y) OBSOLETE!: use gtk methods on window.gtkwindow</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN288" >1.1.1.1.2. resize</A ></H4 ><P ><CODE CLASS="FUNCTION" >resize</CODE > (i, i)</P ><P >This method resizes the window to (i, i) (respectively width and height) OBSOLETE!: use gtk methods on window.gtkwindow</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN293" >1.1.1.1.3. destroy</A ></H4 ><P ><CODE CLASS="FUNCTION" >destroy</CODE > ()</P ><P >This method destroy the window</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN298" >1.1.1.1.4. add_bound_window</A ></H4 ><P ><CODE CLASS="FUNCTION" >add_bound_window</CODE > (w)</P ><P >This method binds the window given as arg to the window</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN303" >1.1.1.1.5. remove_bound_window</A ></H4 ><P ><CODE CLASS="FUNCTION" >remove_bound_window</CODE > (w)</P ><P >This method unbinds the window given as arg from the window</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN308" >1.1.1.1.6. set_records_list</A ></H4 ><P ><CODE CLASS="FUNCTION" >set_records_list</CODE > ( (i,i,i,...) )</P ><P >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.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN313" >1.1.1.1.7. get_widget</A ></H4 ><P ><CODE CLASS="FUNCTION" >get_widget</CODE > (s)</P ><P >This method returns the GUI widget (actually a GtkObject) matching the given string. The strings you can give depends upon the used view.</P ></DIV ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN318" >1.1.1.2. Items</A ></H3 ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN320" >1.1.1.2.1. type</A ></H4 ><P >this item holds the type of the view</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN323" >1.1.1.2.2. i18n_type</A ></H4 ><P >this item holds the type of the view translated in the user's favortie language</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN326" >1.1.1.2.3. subtable</A ></H4 ><P >this item holds the subtable used by the window</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN329" >1.1.1.2.4. id</A ></H4 ><P >this item holds the id of the record currently shown. Unlike other attributes this one is not read-only.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN332" >1.1.1.2.5. name</A ></H4 ><P >this item holds the name of the window, as shown in its title bar</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN335" >1.1.1.2.6. can_restrict_list</A ></H4 ><P >this item holds a boolean value that is set if the window has the 'what' attribute available.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN338" >1.1.1.2.7. gtkwindow</A ></H4 ><P >this item holds a GtkWindow reprensenting the physical window itself</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN341" >1.1.1.2.8. restricted_list</A ></H4 ><P >This item is the place to set a 'restricted list' of records to show in a window (this is a duplicated set_records_list)</P ></DIV ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN344" >1.1.2. GabySubTable object</A ></H2 ><P >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, ...).</P ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN347" >1.1.2.1. Methods</A ></H3 ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN349" >1.1.2.1.1. get_record_no</A ></H4 ><P ><CODE CLASS="FUNCTION" >get_record_no</CODE > (i [, b] )</P ><P >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.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN354" >1.1.2.1.2. add_record</A ></H4 ><P ><CODE CLASS="FUNCTION" >add_record</CODE > (r)</P ><P >This method adds the given record @r to the subtable. It returns the new record's id.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN359" >1.1.2.1.3. delete_record</A ></H4 ><P ><CODE CLASS="FUNCTION" >delete_record</CODE > (id)</P ><P >This method removes the record whose id is @id from the subtable.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN364" >1.1.2.1.4. set_record_no</A ></H4 ><P ><CODE CLASS="FUNCTION" >set_record_no</CODE > (i, r)</P ><P >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</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN369" >1.1.2.1.5. get_next_record</A ></H4 ><P ><CODE CLASS="FUNCTION" >get_next_record</CODE > (i)</P ><P >This methods returns the id of the record directly following the record whose id (_not_ fast id) is i in the subtable</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN374" >1.1.2.1.6. get_previous_record</A ></H4 ><P ><CODE CLASS="FUNCTION" >get_previous_record</CODE > (i)</P ><P >This methods returns the id of the record directly preceding the record whose id (_not_ fast id) is i in the subtable</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN379" >1.1.2.1.7. get_first_record</A ></H4 ><P ><CODE CLASS="FUNCTION" >get_first_record</CODE > ()</P ><P >This methods returns the id of the first record in the subtable.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN384" >1.1.2.1.8. get_last_record</A ></H4 ><P ><CODE CLASS="FUNCTION" >get_last_record</CODE > ()</P ><P >This methods returns the id of the last record in the subtable.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN389" >1.1.2.1.9. records_list</A ></H4 ><P ><CODE CLASS="FUNCTION" >records_list</CODE > ()</P ><P >This methods returns the list (PyList) of the id of the records in the subtable.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN394" >1.1.2.1.10. fast_records_list</A ></H4 ><P ><CODE CLASS="FUNCTION" >fast_records_list</CODE > ()</P ><P >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))</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN399" >1.1.2.1.11. create_new_window</A ></H4 ><P ><CODE CLASS="FUNCTION" >create_new_window</CODE > (s)</P ><P >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.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN404" >1.1.2.1.12. save</A ></H4 ><P ><CODE CLASS="FUNCTION" >save</CODE > ()</P ><P >This methods saves the subtable on disk.</P ></DIV ></DIV ><DIV CLASS="SECT3" ><H3 CLASS="SECT3" ><A NAME="AEN409" >1.1.2.2. Items</A ></H3 ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN411" >1.1.2.2.1. name</A ></H4 ><P >this item holds the name of the subtable</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN414" >1.1.2.2.2. i18n_name</A ></H4 ><P >this item holds the name of the subtable translated in the user's favorite language</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN417" >1.1.2.2.3. fields</A ></H4 ><P >this item holds a tuple (_not_ list !) with the names of the subtable's fields.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN420" >1.1.2.2.4. dict_fields</A ></H4 ><P >this item holds a dict with the fields numbers referenced by the fields names.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN423" >1.1.2.2.5. i18n_fields</A ></H4 ><P >this item holds a tuple (_not_ list !) with the names translated in the user's favorite language of the subtable's fields.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN426" >1.1.2.2.6. dict_i18n_fields</A ></H4 ><P >this item holds a dict with the fields numbers referenced by the fields names translated in the user's favorite language.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H4 CLASS="SIMPLESECT" ><A NAME="AEN429" >1.1.2.2.7. table</A ></H4 ><P >this item holds the name of the table hidden behind the subtable</P ></DIV ></DIV ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="AEN432" >1.1.3. Standalone functions</A ></H2 ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN434" >1.1.3.1. hello_world</A ></H3 ><P ><CODE CLASS="FUNCTION" >hello_world</CODE > ()</P ><P >Prints 'Hello, World !'</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN439" >1.1.3.2. load_database</A ></H3 ><P ><CODE CLASS="FUNCTION" >load_database</CODE > (s)</P ><P >This function loads the database 's' (ie both descfile and datas). It will fail if a database is already loaded.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN444" >1.1.3.3. get_subtable_by_name</A ></H3 ><P ><CODE CLASS="FUNCTION" >get_subtable_by_name</CODE > (s)</P ><P >This functions returns the subtable with the given name</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN449" >1.1.3.4. get_main_window</A ></H3 ><P ><CODE CLASS="FUNCTION" >get_main_window</CODE > ()</P ><P >This function returns the main window (== the first created window)</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN454" >1.1.3.5. get_current_window</A ></H3 ><P ><CODE CLASS="FUNCTION" >get_current_window</CODE > ()</P ><P >This functions returns the focused window (if none has the focus, it is equivalent to get_main_window)</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN459" >1.1.3.6. exit_gaby</A ></H3 ><P ><CODE CLASS="FUNCTION" >exit_gaby</CODE > ()</P ><P >This function exits Gaby cleanly (asking confirmation if there were unsaved record(s))</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN464" >1.1.3.7. get_subtables_list</A ></H3 ><P ><CODE CLASS="FUNCTION" >get_subtables_list</CODE > ()</P ><P >This functions returns a list filled with the name of the subtables</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN469" >1.1.3.8. get_windows_list</A ></H3 ><P ><CODE CLASS="FUNCTION" >get_windows_list</CODE > ()</P ><P >This functions returns a list of GabyWindow objects</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN474" >1.1.3.9. message_dialog</A ></H3 ><P ><CODE CLASS="FUNCTION" >message_dialog</CODE > (i, s)</P ><P >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</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN479" >1.1.3.10. select_subtable</A ></H3 ><P ><CODE CLASS="FUNCTION" >select_subtable</CODE > ()</P ><P >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.</P ></DIV ><DIV CLASS="SIMPLESECT" ><H3 CLASS="SIMPLESECT" ><A NAME="AEN484" >1.1.3.11. gettext</A ></H3 ><P ><CODE CLASS="FUNCTION" >gettext</CODE > (s)</P ><P >This functions returns a translation of the given string</P ></DIV ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="c227.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="p489.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Script-fus</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="c139.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Gaby Developers' Guide</TD ></TR ></TABLE ></DIV ></BODY ></HTML >