home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Demo / sgi / flp / test_nocb.py < prev   
Text File  |  1993-12-17  |  1KB  |  46 lines

  1. #
  2. # Example 1 - Using fl in python without callbacks.
  3. #
  4. # The form is named 'main_form' and resides on file 'test_nocb.fd'.
  5. # It has three objects named button1, button2 and exitbutton.
  6. #
  7. import fl        # The forms library
  8. import FL        # Symbolic constants for the above
  9. import flp        # The module to parse .fd files
  10. import sys
  11.  
  12. # The following struct is created to hold the instance variables
  13. # main_form, button1, button2 and exitbutton.
  14.  
  15. class struct: pass
  16. container = struct()
  17.  
  18. #
  19. # We now first parse the forms file
  20.  
  21. parsetree = flp.parse_form('test_nocb', 'main_form')
  22.  
  23. #
  24. # Next we create it
  25.  
  26. flp.create_full_form(container, parsetree)
  27.  
  28. #
  29. # And display it
  30.  
  31. container.main_form.show_form(FL.PLACE_MOUSE, 1, '')
  32.  
  33. #
  34. # And interact until the exit button is pressed
  35. while 1:
  36.     selected_obj = fl.do_forms()
  37.     if selected_obj == container.button1:
  38.         print 'Button 1 selected'
  39.     elif selected_obj == container.button2:
  40.         print 'Button 2 selected'
  41.     elif selected_obj == container.exitbutton:
  42.         print 'Ok, bye bye'
  43.         sys.exit(0)
  44.     else:
  45.         print 'do_forms() returned unknown object ', selected_obj
  46.