home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1998 November / maximum-cd-1998-11.iso / Truespace 4 / Data / PROGRAM / Scripts / dlgtest.py < prev    next >
Encoding:
Python Source  |  1998-05-21  |  2.2 KB  |  89 lines

  1. # dialog test
  2. # ID's for the tabstop dialog - out test.
  3. from win32ui import IDD_SET_TABSTOPS
  4. from win32ui import IDC_EDIT_TABS
  5. from win32ui import IDC_PROMPT_TABS
  6. from win32con import IDOK
  7. from win32con import IDCANCEL
  8.  
  9. import win32ui
  10. import win32con
  11. import dialog
  12.  
  13. class TestDialog(dialog.Dialog):
  14.     def __init__(self):
  15.         dialog.Dialog.__init__(self, IDD_SET_TABSTOPS)
  16.         self.counter=0
  17.         self.DoModal()
  18.         self.edit=None
  19.  
  20.     def OnInitDialog(self):
  21.         self.SetWindowText("Used to be Tab Stops!")
  22.         self.edit=self.GetDlgItem(IDC_EDIT_TABS)    # the text box.
  23.         self.edit.SetWindowText("Test")
  24.         self.edit.HookMessage(self.KillFocus, win32con.WM_KILLFOCUS)
  25.         prompt=self.GetDlgItem(IDC_PROMPT_TABS)    # the prompt box.
  26.         prompt.SetWindowText("Prompt")
  27.         cancel=self.GetDlgItem(IDCANCEL)    # the cancel button
  28.         cancel.SetWindowText("&Kill me")
  29.  
  30.     # kill focus for the edit box.
  31.     def KillFocus(self,msg):
  32.         self.counter=self.counter+1
  33.         if self.edit != None:
  34.             self.edit.SetWindowText(str(self.counter))
  35.  
  36.     def    OnDestroy(self,msg):
  37.         del self.edit
  38.         del self.counter
  39.  
  40. # now show it.
  41. def demo():
  42.     TestDialog()
  43.     
  44.     # property sheet/page demo
  45.     ps=win32ui.CreatePropertySheet('Property Sheet/Page Demo')
  46.     page1=win32ui.CreatePropertyPage(win32ui.IDD_PROPDEMO1)
  47.     page2=win32ui.CreatePropertyPage(win32ui.IDD_PROPDEMO2)
  48.     ps.AddPage(page1)
  49.     ps.AddPage(page2)
  50.     ps.DoModal()
  51.  
  52. class TestSheet(dialog.PropertySheet):
  53.     def __init__(self, title):
  54.         dialog.PropertySheet.__init__(self, title)
  55.         self.HookMessage(self.OnActivate, win32con.WM_ACTIVATE)
  56.     def OnActivate(self, msg):
  57.         pass
  58.     
  59. def test(modal=1):
  60.  
  61. #    dlg=dialog.Dialog(1010)
  62. #    dlg.CreateWindow()
  63. #    dlg.EndDialog(0)
  64. #    del dlg
  65. #    return
  66.     # property sheet/page demo
  67.     ps=TestSheet('Property Sheet/Page Demo')
  68.     page1=win32ui.CreatePropertyPage(win32ui.IDD_PROPDEMO1)
  69.     page2=win32ui.CreatePropertyPage(win32ui.IDD_PROPDEMO2)
  70.     ps.AddPage(page1)
  71.     ps.AddPage(page2)
  72.     del page1
  73.     del page2
  74.     if modal:
  75.         ps.DoModal()
  76.     else:
  77.         ps.CreateWindow()
  78.     return ps
  79.  
  80. def d():
  81.     dlg = win32ui.CreateDialog(win32ui.IDD_DEBUGGER)
  82.     dlg.datalist.append((win32ui.IDC_DBG_RADIOSTACK, "radio"))
  83.     print "data list is ", dlg.datalist
  84.     dlg.data['radio']=1
  85.     dlg.DoModal()
  86.     print dlg.data['radio']
  87.  
  88. demo()
  89.