codekingpro/portable-devtools
114k
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.py7 8 9import win32api10import win32con11import win32ui12from pywin.framework import app, dlgappcore13 14 15class DoJobAppDialog(dlgappcore.AppDialog):16 softspace = 117 18 def __init__(self, appName=""):19 self.appName = appName20 dlgappcore.AppDialog.__init__(self, win32ui.IDD_GENERAL_STATUS)21 22 def PreDoModal(self):23 pass24 25 def ProcessArgs(self, args):26 pass27 28 def OnInitDialog(self):29 self.SetWindowText(self.appName)30 butCancel = self.GetDlgItem(win32con.IDCANCEL)31 butCancel.ShowWindow(win32con.SW_HIDE)32 p1 = self.GetDlgItem(win32ui.IDC_PROMPT1)33 p2 = self.GetDlgItem(win32ui.IDC_PROMPT2)34 35 # Do something here!36 37 p1.SetWindowText("Hello there")38 p2.SetWindowText("from the demo")39 40 def OnDestroy(self, msg):41 pass42 43 44# def OnOK(self):45# pass46# def OnCancel(self): default behaviour - cancel == close.47# return48 49 50class DoJobDialogApp(dlgappcore.DialogApp):51 def CreateDialog(self):52 return DoJobAppDialog("Do Something")53 54 55class CopyToDialogApp(DoJobDialogApp):56 def __init__(self):57 DoJobDialogApp.__init__(self)58 59 60app.AppBuilder = DoJobDialogApp61 62 63def t():64 t = DoJobAppDialog("Copy To")65 t.DoModal()66 return t67 68 69if __name__ == "__main__":70 import demoutils71 72 demoutils.NeedApp()73 