dyndlg.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # dyndlg.py
  2. # contributed by Curt Hagenlocher <chi@earthlink.net>
  3. # Dialog Template params:
  4. # Parameter 0 - Window caption
  5. # Parameter 1 - Bounds (rect tuple)
  6. # Parameter 2 - Window style
  7. # Parameter 3 - Extended style
  8. # Parameter 4 - Font tuple
  9. # Parameter 5 - Menu name
  10. # Parameter 6 - Window class
  11. # Dialog item params:
  12. # Parameter 0 - Window class
  13. # Parameter 1 - Text
  14. # Parameter 2 - ID
  15. # Parameter 3 - Bounds
  16. # Parameter 4 - Style
  17. # Parameter 5 - Extended style
  18. # Parameter 6 - Extra data
  19. import win32ui
  20. import win32con
  21. from pywin.mfc import dialog, window
  22. def MakeDlgTemplate():
  23. style = win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU | win32con.DS_SETFONT
  24. cs = win32con.WS_CHILD | win32con.WS_VISIBLE
  25. dlg = [ ["Select Warehouse", (0, 0, 177, 93), style, None, (8, "MS Sans Serif")], ]
  26. dlg.append([130, "Current Warehouse:", -1, (7, 7, 69, 9), cs | win32con.SS_LEFT])
  27. dlg.append([130, "ASTORIA", 128, (16, 17, 99, 7), cs | win32con.SS_LEFT])
  28. dlg.append([130, "New &Warehouse:", -1, (7, 29, 69, 9), cs | win32con.SS_LEFT])
  29. s = win32con.WS_TABSTOP | cs
  30. # dlg.append([131, None, 130, (5, 40, 110, 48),
  31. # s | win32con.LBS_NOTIFY | win32con.LBS_SORT | win32con.LBS_NOINTEGRALHEIGHT | win32con.WS_VSCROLL | win32con.WS_BORDER])
  32. dlg.append(["{8E27C92B-1264-101C-8A2F-040224009C02}", None, 131, (5, 40, 110, 48),win32con.WS_TABSTOP])
  33. dlg.append([128, "OK", win32con.IDOK, (124, 5, 50, 14), s | win32con.BS_DEFPUSHBUTTON])
  34. s = win32con.BS_PUSHBUTTON | s
  35. dlg.append([128, "Cancel", win32con.IDCANCEL, (124, 22, 50, 14), s])
  36. dlg.append([128, "&Help", 100, (124, 74, 50, 14), s])
  37. return dlg
  38. def test1():
  39. win32ui.CreateDialogIndirect( MakeDlgTemplate() ).DoModal()
  40. def test2():
  41. dialog.Dialog( MakeDlgTemplate() ).DoModal()
  42. def test3():
  43. dlg = win32ui.LoadDialogResource(win32ui.IDD_SET_TABSTOPS)
  44. dlg[0][0] = 'New Dialog Title'
  45. dlg[0][1] = (80, 20, 161, 60)
  46. dlg[1][1] = '&Confusion:'
  47. cs = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.BS_PUSHBUTTON
  48. dlg.append([128, "&Help", 100, (111, 41, 40, 14), cs])
  49. dialog.Dialog( dlg ).DoModal()
  50. def test4():
  51. page1=dialog.PropertyPage(win32ui.LoadDialogResource(win32ui.IDD_PROPDEMO1))
  52. page2=dialog.PropertyPage(win32ui.LoadDialogResource(win32ui.IDD_PROPDEMO2))
  53. ps=dialog.PropertySheet('Property Sheet/Page Demo', None, [page1, page2])
  54. ps.DoModal()
  55. def testall():
  56. test1()
  57. test2()
  58. test3()
  59. test4()
  60. if __name__=='__main__':
  61. testall()