Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sliderdemo.py 2.1KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # sliderdemo.py
  2. # Demo of the slider control courtesy of Mike Fletcher.
  3. import win32con
  4. import win32ui
  5. from pywin.mfc import dialog
  6. class MyDialog(dialog.Dialog):
  7. """
  8. Example using simple controls
  9. """
  10. _dialogstyle = (
  11. win32con.WS_MINIMIZEBOX
  12. | win32con.WS_DLGFRAME
  13. | win32con.DS_MODALFRAME
  14. | win32con.WS_POPUP
  15. | win32con.WS_VISIBLE
  16. | win32con.WS_CAPTION
  17. | win32con.WS_SYSMENU
  18. | win32con.DS_SETFONT
  19. )
  20. _buttonstyle = (
  21. win32con.BS_PUSHBUTTON
  22. | win32con.WS_TABSTOP
  23. | win32con.WS_CHILD
  24. | win32con.WS_VISIBLE
  25. )
  26. ### The static template, contains all "normal" dialog items
  27. DIALOGTEMPLATE = [
  28. # the dialog itself is the first element in the template
  29. ["Example slider", (0, 0, 50, 43), _dialogstyle, None, (8, "MS SansSerif")],
  30. # rest of elements are the controls within the dialog
  31. # standard "Close" button
  32. [128, "Close", win32con.IDCANCEL, (0, 30, 50, 13), _buttonstyle],
  33. ]
  34. ### ID of the control to be created during dialog initialisation
  35. IDC_SLIDER = 9500
  36. def __init__(self):
  37. dialog.Dialog.__init__(self, self.DIALOGTEMPLATE)
  38. def OnInitDialog(self):
  39. rc = dialog.Dialog.OnInitDialog(self)
  40. # now initialise your controls that you want to create
  41. # programmatically, including those which are OLE controls
  42. # those created directly by win32ui.Create*
  43. # and your "custom controls" which are subclasses/whatever
  44. win32ui.EnableControlContainer()
  45. self.slider = win32ui.CreateSliderCtrl()
  46. self.slider.CreateWindow(
  47. win32con.WS_TABSTOP | win32con.WS_VISIBLE,
  48. (0, 0, 100, 30),
  49. self._obj_,
  50. self.IDC_SLIDER,
  51. )
  52. self.HookMessage(self.OnSliderMove, win32con.WM_HSCROLL)
  53. return rc
  54. def OnSliderMove(self, params):
  55. print("Slider moved")
  56. def OnCancel(self):
  57. print("The slider control is at position", self.slider.GetPos())
  58. self._obj_.OnCancel()
  59. ###
  60. def demo():
  61. dia = MyDialog()
  62. dia.DoModal()
  63. if __name__ == "__main__":
  64. demo()