diff options
Diffstat (limited to 'Demo/sgi/flp')
-rwxr-xr-x | Demo/sgi/flp/test_cb.fd | 75 | ||||
-rwxr-xr-x | Demo/sgi/flp/test_cb.py | 62 | ||||
-rwxr-xr-x | Demo/sgi/flp/test_nocb.fd | 75 | ||||
-rwxr-xr-x | Demo/sgi/flp/test_nocb.py | 45 |
4 files changed, 257 insertions, 0 deletions
diff --git a/Demo/sgi/flp/test_cb.fd b/Demo/sgi/flp/test_cb.fd new file mode 100755 index 0000000..e83fd1f --- /dev/null +++ b/Demo/sgi/flp/test_cb.fd @@ -0,0 +1,75 @@ +Magic: 12321 + +Internal Form Definition File + (do not change) + +Number of forms: 1 + +=============== FORM =============== +Name: main_form +Width: 170.000000 +Height: 190.000000 +Number of Objects: 4 + +-------------------- +class: 1 +type: 1 +box: 0.000000 0.000000 170.000000 190.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: +name: +callback: +argument: + +-------------------- +class: 11 +type: 0 +box: 10.000000 140.000000 150.000000 40.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: Button 1 +name: button1 +callback: button1CB +argument: 0 + +-------------------- +class: 11 +type: 0 +box: 10.000000 100.000000 150.000000 40.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: Button 2 +name: button2 +callback: button2CB +argument: 0 + +-------------------- +class: 11 +type: 6 +box: 10.000000 10.000000 150.000000 40.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: EXIT +name: exitbutton +callback: exitbuttonCB +argument: 0 + +============================== +create_the_forms diff --git a/Demo/sgi/flp/test_cb.py b/Demo/sgi/flp/test_cb.py new file mode 100755 index 0000000..d622332 --- /dev/null +++ b/Demo/sgi/flp/test_cb.py @@ -0,0 +1,62 @@ +# +# Example 2 - Using fl in python with callbacks. +# +# The form is named 'main_form' and resides on file 'test_cb.fd'. +# It has three objects named button1, button2 and exitbutton. +# All buttons have callbacks with the same names as their corresponding +# buttons but with CB appended. +# +import fl # The forms library +import FL # Symbolic constants for the above +import flp # The module to parse .fd files +import sys + +# The following struct is created to hold the instance variables +# main_form, button1, button2 and exitbutton. + +class myform(): + # + # The init function parses and creates the form, but doesn't + # display it (yet). + def init(self, number): + # + # First we parse the form + parsetree = flp.parse_form('test_cb', 'main_form') + # + # Next we create it + + flp.create_full_form(self, parsetree) + + # And keep our number + self.number = number + return self + + # + # The show function displays the form. It doesn't do any interaction, + # though. + def show(self): + self.main_form.show_form(FL.PLACE_SIZE, 1, '') + + # The callback functions + def button1CB(self, obj, arg): + print 'Button 1 pressed on form', self.number + + def button2CB(self, obj, arg): + print 'Button 2 pressed on form', self.number + + def exitbuttonCB(self, obj, arg): + print 'Ok, bye bye' + sys.exit(0) + +# +# The main program. Instantiate two variables of the forms class +# and interact with them. + +form1 = myform().init(1) +form2 = myform().init(2) + +form1.show() +form2.show() + +obj = fl.do_forms() +print 'do_forms() returned. This should not happen. obj=', obj diff --git a/Demo/sgi/flp/test_nocb.fd b/Demo/sgi/flp/test_nocb.fd new file mode 100755 index 0000000..4d3f7ef --- /dev/null +++ b/Demo/sgi/flp/test_nocb.fd @@ -0,0 +1,75 @@ +Magic: 12321 + +Internal Form Definition File + (do not change) + +Number of forms: 1 + +=============== FORM =============== +Name: main_form +Width: 170.000000 +Height: 190.000000 +Number of Objects: 4 + +-------------------- +class: 1 +type: 1 +box: 0.000000 0.000000 170.000000 190.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: +name: +callback: +argument: + +-------------------- +class: 11 +type: 0 +box: 10.000000 140.000000 150.000000 40.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: Button 1 +name: button1 +callback: +argument: + +-------------------- +class: 11 +type: 0 +box: 10.000000 100.000000 150.000000 40.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: Button 2 +name: button2 +callback: +argument: + +-------------------- +class: 11 +type: 6 +box: 10.000000 10.000000 150.000000 40.000000 +boxtype: 1 +colors: 47 47 +alignment: 4 +style: 0 +size: 11.000000 +lcol: 0 +label: EXIT +name: exitbutton +callback: +argument: + +============================== +create_the_forms diff --git a/Demo/sgi/flp/test_nocb.py b/Demo/sgi/flp/test_nocb.py new file mode 100755 index 0000000..48cee9d --- /dev/null +++ b/Demo/sgi/flp/test_nocb.py @@ -0,0 +1,45 @@ +# +# Example 1 - Using fl in python without callbacks. +# +# The form is named 'main_form' and resides on file 'test_nocb.fd'. +# It has three objects named button1, button2 and exitbutton. +# +import fl # The forms library +import FL # Symbolic constants for the above +import flp # The module to parse .fd files +import sys + +# The following struct is created to hold the instance variables +# main_form, button1, button2 and exitbutton. + +class struct(): pass +container = struct() + +# +# We now first parse the forms file + +parsetree = flp.parse_form('test_nocb', 'main_form') + +# +# Next we create it + +flp.create_full_form(container, parsetree) + +# +# And display it + +container.main_form.show_form(FL.PLACE_MOUSE, 1, '') + +# +# And interact until the exit button is pressed +while 1: + selected_obj = fl.do_forms() + if selected_obj == container.button1: + print 'Button 1 selected' + elif selected_obj == container.button2: + print 'Button 2 selected' + elif selected_obj == container.exitbutton: + print 'Ok, bye bye' + sys.exit(0) + else: + print 'do_forms() returned unknown object ', selected_obj |