📄 flp.doc
字号:
.SHModule flp.LPThe flp module loads fl-forms from fd files, as generatedby fdesign. The module is designed to be flexible enough to allowalmost anything to be done with the loaded form..LPLoadform defines two types of functions: functions to parse fd files and functions tocreate the forms from the templates returned by the parse functions.There are fairly low-level create functions that create single objects,and convenience routines that create complete forms, including callbacks,etc..LPThe exception flp.error is raised whenever an error occurs while parsing a formsdefinition file or creating a form..SH 2Parsing functions.LPThere are two parsing functions, parse_form() and parse_forms(). Theytake the following form:.LP.ft Cftuple = parse_form(filename, formname).brftdict = parse_forms(filename).IPParse_form parses a single form, and returns a tuple (ftmp, otmplist).Ftmp is a template for a form, otmplist is a list of templates forobjects. See below for a description of these templates..IPParse_forms parses all forms in an fd file. It returns a dictionary of(ftmp, otmplist) tuples, indexed by formname..IPFilename is the name of the forms definition file to inspect. The functionsappends '.fd' if needed, and use 'sys.path' to locate the file..IPformname is the name of the form to load. This argument is mandatory,even if the file only contains one form..LPThe form template and object template are structures that contain allthe information read from the fd file, in 'natural' form. A formtemplate record contains the following fields:.IP.nf"Name", the name of the form;"Width", the width of the form;"Height", the height of the form; and"Numberofobjects", the number of objects in the form..LPAn object template contains the following fields:.IP.nf"Class", the class of object (eg. FL.BUTTON);"Type", the sub-class (eg. FL.NORMALBUTTON);"Box", a list with four members: [x, y, width, height];"Boxtype", the type of box (eg. FL.DOWNBOX);"Colors", a list with the two object colors;"Alignment", the label alignment (eg. FL.ALIGNLEFT); "Style", the label style (eg. FL.BOLDSTYLE);"Lcol", the label color;"Label", a string containing the label;"Name", a string containing the name of the object;"Callback", a string containing the callback routine name; and"Argument", a string containing the callback routine extra argument..SHLow-level create routines..LPThe three low-level creation routines are called as follows:.LP.ft Cform = create_form(form_template).IPCreate an fl form from a form template. Returns the form created..LP.ft Cobj = create_object(form, obj_template).IPCreate an object in an fl form. Return the new object.An error is raised if the object has a callback routine..SHHigh-level create routines..LPThe 'standard' way to handle forms in python is to define a classthat contains the form and all the objects (insofar as they are named),and that defines all the callback functions, and use an instance ofthis class to handle the form interaction.Flp contains three routines that simplify handling this paradigm:.LP.ft Ccreate_full_form(instance, ftuple).IPThis routine takes an instance of your form-handling class and anftuple (as returned by the parsing routines) as parameters. It insertsthe form into the instance, defines all object names and arranges thatthe callback methods are called. All the names inserted into theinstance are the same as the names used for the objects, etc. in thefd file..LP.ft Cmerge_full_form(instance, form, ftuple).IPThis function does the same as create_full_form, only it does not createthe form itself nor the 'background box' that fdesign automaticallyadds to each form. This is useful if your class inherits a superclassthat already defines a skeleton form (with 'OK' and 'Cancel' buttons,for instance), and you want to merge the new form into that existingform. The 'form' parameter is the form to which the new objects areadded..LPIf you use the paradigm sketched here but need slightly more controlover object creation there is a routine that creates a single objectand inserts its name (and arranges for the callback routine to becalled):.LP.ft Ccreate_object_instance(instance, form, obj_template)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -