RadioGroups.py :  » Mobile » Python-for-PalmOS » Python-1.5.2+reduced-1.0 » Demo » stdwin » 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 » Mobile » Python for PalmOS 
Python for PalmOS » Python 1.5.2 reduced 1.0 » Demo » stdwin » RadioGroups.py
#! /usr/bin/env python

# radiogroups.py
#
# Demonstrate multiple groups of radio buttons

import stdwin
from Buttons import *
from WindowParent import WindowParent,MainLoop
from HVSplit import HSplit,VSplit

def main():
  #
  # Create the widget hierarchy, top-down
  #
  # 1. Create the window
  #
  window = WindowParent().create('Radio Groups', (0, 0))
  #
  # 2. Create a horizontal split to contain the groups
  #
  topsplit = HSplit().create(window)
  #
  # 3. Create vertical splits, one for each group
  #
  group1 = VSplit().create(topsplit)
  group2 = VSplit().create(topsplit)
  group3 = VSplit().create(topsplit)
  #
  # 4. Create individual radio buttons, each in their own split
  #
  b11 = RadioButton().definetext(group1, 'Group 1 button 1')
  b12 = RadioButton().definetext(group1, 'Group 1 button 2')
  b13 = RadioButton().definetext(group1, 'Group 1 button 3')
  #
  b21 = RadioButton().definetext(group2, 'Group 2 button 1')
  b22 = RadioButton().definetext(group2, 'Group 2 button 2')
  b23 = RadioButton().definetext(group2, 'Group 2 button 3')
  #
  b31 = RadioButton().definetext(group3, 'Group 3 button 1')
  b32 = RadioButton().definetext(group3, 'Group 3 button 2')
  b33 = RadioButton().definetext(group3, 'Group 3 button 3')
  #
  # 5. Define the grouping for the radio buttons.
  #    Note: this doesn't have to be the same as the
  #    grouping is splits (although it usually is).
  #    Also set the 'hook' procedure for each button
  #
  list1 = [b11, b12, b13]
  list2 = [b21, b22, b23]
  list3 = [b31, b32, b33]
  #
  for b in list1:
    b.group = list1
    b.on_hook = myhook
  for b in list2:
    b.group = list2
    b.on_hook = myhook
  for b in list3:
    b.group = list3
    b.on_hook = myhook
  #
  # 6. Select a default button in each group
  #
  b11.select(1)
  b22.select(1)
  b33.select(1)
  #
  # 6. Realize the window
  #
  window.realize()
  #
  # 7. Dispatch events until the window is closed
  #
  MainLoop()
  #
  # 8. Report final selections
  #
  print 'You selected the following choices:'
  if b11.selected: print '1.1'
  if b12.selected: print '1.2'
  if b13.selected: print '1.3'
  if b21.selected: print '2.1'
  if b22.selected: print '2.2'
  if b23.selected: print '2.3'
  if b31.selected: print '3.1'
  if b32.selected: print '3.2'
  if b33.selected: print '3.3'


# My 'hook' procedure
# This is placed as 'hook' attribute on each button.
# The example just prints the title of the selected button.
#
def myhook(self):
  print 'Selected:', self.text

main()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.