test_cb.py :  » Language-Interface » ChinesePython » chinesepython2.1.3-0.4 » Demo » sgi » flp » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Language Interface » ChinesePython 
ChinesePython » chinesepython2.1.3 0.4 » Demo » sgi » flp » test_cb.py
#
# 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 constructor 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

  #
  # 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(1)
form2 = myform(2)

form1.show()
form2.show()

obj = fl.do_forms()
print 'do_forms() returned. This should not happen. obj=', obj
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.