tlist_dialog.py :  » Language-Interface » ChinesePython » chinesepython2.1.3-0.4 » Mac » Lib » test » 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 » Mac » Lib » test » tlist_dialog.py
from Dlg import *
from Events import *
from Evt import *
from List import *
from Qd import *
import Res
import string
import MacOS

ID = 513

def dodialog(items):
  print 'This is to create a window'
  #
  # Create the dialog
  #
  d = GetNewDialog(ID, -1)
  #
  # Create the list and fill it
  #
  tp, h, rect = d.GetDialogItem(2)
  rect = rect[0], rect[1], rect[2]-15, rect[3]-15  # Space for scrollbars
  length = (len(items)+1) / 2
  list = LNew(rect, (0, 0, 2, length), (0, 0), 0, d, 0, 1, 1, 1)
  for i in range(len(items)):
    list.LSetCell(items[i], (i%2, i/2))
  #
  # Draw it.
  #
  list.LSetDrawingMode(1)
  list.LUpdate(self.wid.GetWindowPort().visRgn)
  #
  # Do the (modeless) dialog
  #
  while 1:
    ok, ev = WaitNextEvent(0xffff, 10)
    if not ok:
      # No event.
      continue
    (what, message, when, where, modifiers) = ev
    if what == updateEvt:
      # XXXX We just always update our list (sigh...)
      SetPort(window)
      list.LUpdate(self.wid.GetWindowPort().visRgn)
    if IsDialogEvent(ev):
      # It is a dialog event. See if it's ours.
      ok, window, item = DialogSelect(ev)
      if ok:
        if window == d:
          # Yes, it is ours.
          if item == 1:  # OK button
            break
          elif item == 2:  # List
            (what, message, when, where, modifiers) = ev
            SetPort(window)
            if what == mouseDown:
              local = GlobalToLocal(where)
              list.LClick(local, modifiers)
          else:
            print 'Unexpected item hit'
        else:
          print 'Unexpected dialog hit'
    else:
      MacOS.HandleEvent(ev)
  sel = []
  for i in range(len(items)):
    ok, dummycell = list.LGetSelect(0, (i%2, i/2))
    if ok:
      sel.append(list.LGetCell(256, (i%2, i/2)))
  print 'Your selection:', sel

def test():
  import os, sys
  Res.FSpOpenResFile('tlist_dialog.rsrc', 1)
  dodialog(os.listdir(':'))
  sys.exit(1)

if __name__ == '__main__':
  test()
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.