def Boot( bEditor = 0 ): CMIFDIR = win32api.GetFullPathName(os.path.join(os.path.split(sys.argv[0])[0], "." )) # TEMP TEST FOLDER if bEditor: specificPath = "editor" os.environ['GRiNSApp']='GRiNSed' else: specificPath = "grins" os.environ['GRiNSApp']='GRiNS' CMIFPATH = [ os.path.join(CMIFDIR, '%s\\win32' % specificPath), os.path.join(CMIFDIR, 'common\\win32'), os.path.join(CMIFDIR, 'lib\\win32'), os.path.join(CMIFDIR, '%s' % specificPath), os.path.join(CMIFDIR, 'common'), os.path.join(CMIFDIR, 'lib'), os.path.join(CMIFDIR, 'pylib'), os.path.join(CMIFDIR, 'pylib\\audio'), os.path.join(CMIFDIR, 'win32\\src\\Build'), ] CMIF_USE_WIN32="ON" #CHANNELDEBUG="ON" sys.path[0:0] = CMIFPATH os.environ["CMIF"] = CMIFDIR #os.environ["CHANNELDEBUG"] = "ON" os.environ["CMIF_USE_WIN32"] = "ON" # Locate the GRiNSRes.dll file. This is presumably in the same directory as # the extensionmodules, or if frozen, in the main directory # This call allows Pythonwin to automatically find resources in it. import win32ui dllPath = os.path.split(win32ui.__file__)[0] win32ui.GetWin32Sdk().SetCurrentDirectory(dllPath) try: global resdll resdll = win32ui.LoadLibrary(os.path.join(dllPath, "GRiNSRes.dll")) resdll.AttachToMFC() except win32ui.error: win32ui.MessageBox("The application resource DLL 'GRiNSRes.dll' can not be located\r\n\r\nPlease correct this problem, and restart the application") # For now just continue!?!?! # set app registry root to GRiNS from version import registrykey, registryname win32ui.SetAppName(registryname) win32ui.SetRegistryKey(registrykey) # run the given cmif file if bEditor: import cmifed else: import grins
def InitInstance(self): # Allow "/nodde" and "/new" to optimize this! if ("/nodde" not in sys.argv and "/new" not in sys.argv and "-nodde" not in sys.argv and "-new" not in sys.argv): if self.InitDDE(): return 1 # A remote DDE client is doing it for us! else: self.ddeServer = None win32ui.SetRegistryKey("Python %s" % ( sys.winver, )) # MFC automatically puts the main frame caption on! app.CApp.InitInstance(self) # Create the taskbar icon win32ui.CreateDebuggerThread() # Allow Pythonwin to host OCX controls. win32ui.EnableControlContainer() # Display the interactive window if the user wants it. from . import interact interact.CreateInteractiveWindowUserPreference() # Load the modules we use internally. self.LoadSystemModules() # Load additional module the user may want. self.LoadUserModules() # Load the ToolBar state near the end of the init process, as # there may be Toolbar IDs created by the user or other modules. # By now all these modules should be loaded, so all the toolbar IDs loaded. try: self.frame.LoadBarState("ToolbarDefault") except win32ui.error: # MFC sucks. It does essentially "GetDlgItem(x)->Something", so if the # toolbar with ID x does not exist, MFC crashes! Pythonwin has a trap for this # but I need to investigate more how to prevent it (AFAIK, ensuring all the # toolbars are created by now _should_ stop it!) pass # Finally process the command line arguments. try: self.ProcessArgs(sys.argv) except: # too early for printing anything. win32ui.DisplayTraceback(sys.exc_info(), " - error processing command line args")
def InitInstance(self): # Use a registry path of "Python\Pythonwin Debugger win32ui.SetAppName(win32ui.LoadString(win32ui.IDR_DEBUGGER)) win32ui.SetRegistryKey("Python %s" % (sys.winver,)) # We _need_ the Scintilla color editor. # (and we _always_ get it now :-) numMRU = win32ui.GetProfileVal("Settings","Recent File List Size", 10) win32ui.LoadStdProfileSettings(numMRU) self.LoadMainFrame() # Display the interactive window if the user wants it. from pywin.framework import interact interact.CreateInteractiveWindowUserPreference() # Load the modules we use internally. self.LoadSystemModules() # Load additional module the user may want. self.LoadUserModules() # win32ui.CreateDebuggerThread() win32ui.EnableControlContainer()
# Turn pathnames into their full NT version import longpath for i in range(1, len(sys.argv)): if os.path.exists(sys.argv[i]): sys.argv[i] = longpath.short2longpath(sys.argv[i]) import string import win32api from win32con import * import win32ui import traceback from version import registryname, registrykey win32ui.SetAppName(registryname) win32ui.SetRegistryKey(registrykey) def SafeCallbackCaller(fn, args): try: return apply(fn, args) except SystemExit, rc: # We trap a system exit, and translate it to the "official" way to bring down a GUI. try: rc = int(rc[0]) except (ValueError, TypeError): rc = 0 # use afx to unload com/ole lib #(win32ui.GetAfx()).PostQuitMessage(rc) win32ui.GetMainFrame().PostMessage(WM_CLOSE) except: