dojobapp.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # dojobapp - do a job, show the result in a dialog, and exit.
  2. #
  3. # Very simple - faily minimal dialog based app.
  4. #
  5. # This should be run using the command line:
  6. # pythonwin /app demos\dojobapp.py
  7. import win32ui
  8. import win32api
  9. import win32con
  10. import sys
  11. from pywin.framework import app, dlgappcore
  12. import string
  13. class DoJobAppDialog(dlgappcore.AppDialog):
  14. softspace=1
  15. def __init__(self, appName = ""):
  16. self.appName = appName
  17. dlgappcore.AppDialog.__init__(self, win32ui.IDD_GENERAL_STATUS)
  18. def PreDoModal(self):
  19. pass
  20. def ProcessArgs(self, args):
  21. pass
  22. def OnInitDialog(self):
  23. self.SetWindowText(self.appName)
  24. butCancel = self.GetDlgItem(win32con.IDCANCEL)
  25. butCancel.ShowWindow(win32con.SW_HIDE)
  26. p1 = self.GetDlgItem(win32ui.IDC_PROMPT1)
  27. p2 = self.GetDlgItem(win32ui.IDC_PROMPT2)
  28. # Do something here!
  29. p1.SetWindowText("Hello there")
  30. p2.SetWindowText("from the demo")
  31. def OnDestroy(self,msg):
  32. pass
  33. # def OnOK(self):
  34. # pass
  35. # def OnCancel(self): default behaviour - cancel == close.
  36. # return
  37. class DoJobDialogApp(dlgappcore.DialogApp):
  38. def CreateDialog(self):
  39. return DoJobAppDialog("Do Something")
  40. class CopyToDialogApp(DoJobDialogApp):
  41. def __init__(self):
  42. DoJobDialogApp.__init__(self)
  43. app.AppBuilder = DoJobDialogApp
  44. def t():
  45. t = DoJobAppDialog("Copy To")
  46. t.DoModal()
  47. return t
  48. if __name__=='__main__':
  49. import demoutils
  50. demoutils.NeedApp()