2 # Example 2 - Using fl in python with callbacks.
4 # The form is named 'main_form' and resides on file 'test_cb.fd'.
5 # It has three objects named button1, button2 and exitbutton.
6 # All buttons have callbacks with the same names as their corresponding
7 # buttons but with CB appended.
9 import fl
# The forms library
10 import FL
# Symbolic constants for the above
11 import flp
# The module to parse .fd files
14 # The following struct is created to hold the instance variables
15 # main_form, button1, button2 and exitbutton.
19 # The constructor parses and creates the form, but doesn't
21 def __init__(self
, number
):
23 # First we parse the form
24 parsetree
= flp
.parse_form('test_cb', 'main_form')
28 flp
.create_full_form(self
, parsetree
)
34 # The show function displays the form. It doesn't do any interaction,
37 self
.main_form
.show_form(FL
.PLACE_SIZE
, 1, '')
39 # The callback functions
40 def button1CB(self
, obj
, arg
):
41 print 'Button 1 pressed on form', self
.number
43 def button2CB(self
, obj
, arg
):
44 print 'Button 2 pressed on form', self
.number
46 def exitbuttonCB(self
, obj
, arg
):
51 # The main program. Instantiate two variables of the forms class
52 # and interact with them.
61 print 'do_forms() returned. This should not happen. obj=', obj