Example #1
0
    def OnInitDialog(self):

        edit = self.GetDlgItem(win32ui.IDC_EDIT1)
        format = eval(win32ui.GetProfileVal(interact.sectionProfile, interact.STYLE_INTERACTIVE_PROMPT,
                                            str(interact.formatInput)))
        edit.SetDefaultCharFormat(format)
        edit.SetWindowText("Input Text")

        edit = self.GetDlgItem(win32ui.IDC_EDIT2)
        format = eval(win32ui.GetProfileVal(interact.sectionProfile, interact.STYLE_INTERACTIVE_OUTPUT,
                                            str(interact.formatOutput)))
        edit.SetDefaultCharFormat(format)
        edit.SetWindowText("Output Text")

        edit = self.GetDlgItem(win32ui.IDC_EDIT3)
        format = eval(win32ui.GetProfileVal(interact.sectionProfile, interact.STYLE_INTERACTIVE_ERROR,
                                            str(interact.formatOutputError)))
        edit.SetDefaultCharFormat(format)
        edit.SetWindowText("Error Text")

        self['bShowAtStartup'] = interact.LoadPreference("Show at startup", 1)
        self['bDocking'] = interact.LoadPreference("Docking", 0)
        self['MRUSize'] = win32ui.GetProfileVal("Settings", "Recent File List Size", 10)

        # Hook the button clicks.
        self.HookCommand(self.HandleCharFormatChange, win32ui.IDC_BUTTON1)
        self.HookCommand(self.HandleCharFormatChange, win32ui.IDC_BUTTON2)
        self.HookCommand(self.HandleCharFormatChange, win32ui.IDC_BUTTON3)

        # Ensure the spin control remains in range.
        spinner = self.GetDlgItem(win32ui.IDC_SPIN1)
        spinner.SetRange(1, 16)

        return dialog.PropertyPage.OnInitDialog(self)
Example #2
0
def LoadWindowSize(section):
    """ Loads a section from an INI file, and returns a rect in a tuple (see SaveWindowSize)"""
    left = win32ui.GetProfileVal(section, "left", 0)
    top = win32ui.GetProfileVal(section, "top", 0)
    right = win32ui.GetProfileVal(section, "right", 0)
    bottom = win32ui.GetProfileVal(section, "bottom", 0)
    return (left, top, right, bottom)
Example #3
0
    def OnInitDialog(self):
        win32ui.SetProfileFileName('pytimer.ini')
        self.title = win32ui.GetProfileVal(self.timerAppName, "Title",
                                           "Remote System Timer")
        self.buildTimer = win32ui.GetProfileVal(self.timerAppName, "Timer",
                                                "EachMinuteIntervaler()")
        self.doWork = win32ui.GetProfileVal(self.timerAppName, "Work",
                                            "DoDemoWork()")
        # replace "\n" with real \n.
        self.doWork = self.doWork.replace('\\n', '\n')
        dlgappcore.AppDialog.OnInitDialog(self)

        self.SetWindowText(self.title)
        self.prompt1 = self.GetDlgItem(win32ui.IDC_PROMPT1)
        self.prompt2 = self.GetDlgItem(win32ui.IDC_PROMPT2)
        self.prompt3 = self.GetDlgItem(win32ui.IDC_PROMPT3)
        self.butOK = self.GetDlgItem(win32con.IDOK)
        self.butCancel = self.GetDlgItem(win32con.IDCANCEL)
        self.prompt1.SetWindowText("Python Timer App")
        self.prompt2.SetWindowText("")
        self.prompt3.SetWindowText("")
        self.butOK.SetWindowText("Do it now")
        self.butCancel.SetWindowText("Close")

        self.timerManager = TimerManager(self)
        self.ProcessArgs(sys.argv[self.argOff:])
        self.timerManager.go()
        return 1
Example #4
0
def LoadFontPreferences():
    global formatTitle, formatInput, formatOutput, formatOutputError
    try:
        fmt = win32ui.GetProfileVal(sectionProfile, valueFormatTitle, "")
        if len(fmt): formatTitle = eval(fmt)
        fmt = win32ui.GetProfileVal(sectionProfile, valueFormatInput, "")
        if len(fmt): formatInput = eval(fmt)
        fmt = win32ui.GetProfileVal(sectionProfile, valueFormatOutput, "")
        if len(fmt): formatOutput = eval(fmt)
        fmt = win32ui.GetProfileVal(sectionProfile, valueFormatOutputError, "")
        if len(fmt): formatOutputError = eval(fmt)
    except:
        win32ui.MessageBox("The Font Preferences could not be loaded")
Example #5
0
	def SetApplicationPaths(self):
		# Load the users/application paths
		new_path = []
		apppath=win32ui.GetProfileVal('Python','Application Path','').split(';')
		for path in apppath:
			if len(path)>0:
				new_path.append(win32ui.FullPath(path))
		for extra_num in range(1,11):
			apppath=win32ui.GetProfileVal('Python','Application Path %d'%extra_num,'').split(';')
			if len(apppath) == 0:
				break
			for path in apppath:
				if len(path)>0:
					new_path.append(win32ui.FullPath(path))
		sys.path = new_path + sys.path
Example #6
0
def LoadToolMenuItems():
    # Load from the registry.
    items = []
    lookNo = 1
    while 1:
        menu = win32ui.GetProfileVal("Tools Menu\\%s" % lookNo, "", "")
        if menu == "":
            break
        cmd = win32ui.GetProfileVal("Tools Menu\\%s" % lookNo, "Command", "")
        items.append((menu, cmd))
        lookNo = lookNo + 1

    if len(items) == 0:
        items = defaultToolMenuItems
    return items
Example #7
0
 def LoadUserModules(self, moduleNames=None):
     # Load the users modules.
     if moduleNames is None:
         default = "pywin.framework.sgrepmdi,pywin.framework.mdi_pychecker"
         moduleNames = win32ui.GetProfileVal('Python', 'Startup Modules',
                                             default)
     self.DoLoadModules(moduleNames)
Example #8
0
 def setInitParams(self, paramstr):
     if paramstr is None:
         paramstr = win32ui.GetProfileVal("Pychecker", "Params", '\t\t\t1\t0\t0')
     params = paramstr.split('\t')
     if len(params) < 3:
         params = params + ['']*(3-len(params))
     if len(params) < 6:
         params = params + [0]*(6-len(params))
     self.dirpattern = params[0]
     self.filpattern = params[1]
     self.greppattern = params[2] or '-#1000 --only'
     self.casesensitive = int(params[3])
     self.recurse = int(params[4])
     self.verbose = int(params[5])
     # setup some reasonable defaults.
     if not self.dirpattern:
         try: 
             editor=win32ui.GetMainFrame().MDIGetActive()[0].GetEditorView()
             self.dirpattern=os.path.abspath(os.path.dirname(editor.GetDocument().GetPathName()))
         except (AttributeError,win32ui.error):
             self.dirpattern = os.getcwd()
     if not self.filpattern:
         try: 
             editor=win32ui.GetMainFrame().MDIGetActive()[0].GetEditorView()
             self.filpattern=editor.GetDocument().GetPathName()
         except AttributeError:
             self.filpattern = "*.py"
Example #9
0
def GetEditorOption(option, defaultValue, min=None, max=None):
    rc = win32ui.GetProfileVal("Editor", option, defaultValue)
    if min is not None and rc < min:
        rc = defaultValue
    if max is not None and rc > max:
        rc = defaultValue
    return rc
Example #10
0
	def CreateWindow(self, parent):
		DebuggerListViewWindow.CreateWindow(self, parent)
		items = win32ui.GetProfileVal("Debugger Windows\\" + self.title, "Items", "").split("\t")
		index = -1
		for item in items:
			if item:
				index = self.InsertItem(index+1, item)
		self.InsertItem(index+1, "<New Item>")
Example #11
0
    def __init__(self, pInfo, dlgID, flags=win32ui.PD_USEDEVMODECOPIES):
        dialog.PrintDialog.__init__(self, pInfo, dlgID, flags=flags)
        mag = win32ui.GetProfileVal(self.sectionPos, 'Document Magnification',
                                    0)
        if mag <= 0:
            mag = 2
            win32ui.WriteProfileVal(self.sectionPos, 'Document Magnification',
                                    mag)

        self['mag'] = mag
Example #12
0
    def InitInstance(self):
        " Called to crank up the app "
        numMRU = win32ui.GetProfileVal("Settings", "Recent File List Size", 10)
        win32ui.LoadStdProfileSettings(numMRU)
        #		self._obj_.InitMDIInstance()
        if win32api.GetVersionEx()[0] < 4:
            win32ui.SetDialogBkColor()
            win32ui.Enable3dControls()

        # install a "callback caller" - a manager for the callbacks
#		self.oldCallbackCaller = win32ui.InstallCallbackCaller(self.CallbackManager)
        self.LoadMainFrame()
        self.SetApplicationPaths()
Example #13
0
 def ProcessArgs(self, args, dde=None):
     # If we are going to talk to a remote app via DDE, then
     # activate it!
     if dde is not None: dde.Exec("self.Activate()")
     if len(args) and args[0] in ['/nodde', '/new']: del args[0]  # already handled.
     if len(args) < 1 or not args[0]:  # argv[0]=='' when started without args, just like Python.exe!
         return
     try:
         if args[0] and args[0][0] != '/':
             argStart = 0
             argType = win32ui.GetProfileVal("Python", "Default Arg Type", "/edit").lower()
         else:
             argStart = 1
             argType = args[0]
         if argStart >= len(args):
             raise TypeError("The command line requires an additional arg.")
         if argType == "/edit":
             # Load up the default application.
             if dde:
                 fname = win32api.GetFullPathName(args[argStart])
                 dde.Exec("win32ui.GetApp().OpenDocumentFile(%s)" % (repr(fname)))
             else:
                 win32ui.GetApp().OpenDocumentFile(args[argStart])
         elif argType == "/rundlg":
             if dde:
                 dde.Exec("from pywin.framework import scriptutils;scriptutils.RunScript('%s', '%s', 1)" % (
                 args[argStart], ' '.join(args[argStart + 1:])))
             else:
                 from . import scriptutils
                 scriptutils.RunScript(args[argStart], ' '.join(args[argStart + 1:]))
         elif argType == "/run":
             if dde:
                 dde.Exec("from pywin.framework import scriptutils;scriptutils.RunScript('%s', '%s', 0)" % (
                 args[argStart], ' '.join(args[argStart + 1:])))
             else:
                 from . import scriptutils
                 scriptutils.RunScript(args[argStart], ' '.join(args[argStart + 1:]), 0)
         elif argType == "/app":
             raise RuntimeError("/app only supported for new instances of Pythonwin.exe")
         elif argType == '/dde':  # Send arbitary command
             if dde is not None:
                 dde.Exec(args[argStart])
             else:
                 win32ui.MessageBox("The /dde command can only be used\r\nwhen Pythonwin is already running")
         else:
             raise TypeError("Command line arguments not recognised")
     except:
         # too early for print anything.
         win32ui.DisplayTraceback(sys.exc_info(), " - error processing command line args")
Example #14
0
def LoadConfiguration():
	global configManager
	# Bit of a hack I dont kow what to do about?
	from config import ConfigManager
	configName = rc = win32ui.GetProfileVal("Editor", "Keyboard Config", "default")
	configManager = ConfigManager(configName)
	if configManager.last_error:
		bTryDefault = 0
		msg = "Error loading configuration '%s'\n\n%s" % (configName, configManager.last_error)
		if configName != "default":
			msg = msg + "\n\nThe default configuration will be loaded."
			bTryDefault = 1
		win32ui.MessageBox(msg)
		if bTryDefault:
			configManager = ConfigManager("default")
			if configManager.last_error:
				win32ui.MessageBox("Error loading configuration 'default'\n\n%s" % (configManager.last_error))
Example #15
0
	def GUICheckInit(self):
		if self.inited: return
		self.inited = 1
		frame = win32ui.GetMainFrame()

		# Ensure the debugger windows are attached to the debugger.
		for id, klass, float in DebuggerDialogInfos:
			w = frame.GetControlBar(id)
			w.dialog.Init(self)
			# Show toolbar if it was visible during last debug session
			# This would be better done using a CDockState, but that class is not wrapped yet
			if win32ui.GetProfileVal("Debugger Windows\\" + w.dialog.title, "Visible", 0):
				frame.ShowControlBar(w, 1, 1)

		# ALWAYS show debugging toolbar, regardless of saved state
		tb = frame.GetControlBar(win32ui.ID_VIEW_TOOLBAR_DBG)
		frame.ShowControlBar(tb, 1, 1)
		self.GUIRespondDebuggerData()
Example #16
0
	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()
Example #17
0
    def ProcessArgs(self, args, dde=None):
        # If we are going to talk to a remote app via DDE, then
        # activate it!
        if len(args) < 1 or not args[
                0]:  # argv[0]=='' when started without args, just like Python.exe!
            return

        i = 0
        while i < len(args):
            argType = args[i]
            i += 1
            if argType.startswith('-'):
                # Support dash options. Slash options are misinterpreted by python init
                # as path and not finding usually 'C:\\' ends up in sys.path[0]
                argType = '/' + argType[1:]
            if not argType.startswith('/'):
                argType = win32ui.GetProfileVal("Python", "Default Arg Type",
                                                "/edit").lower()
                i -= 1  #  arg is /edit's parameter
            par = i < len(args) and args[i] or 'MISSING'
            if argType in ['/nodde', '/new', '-nodde', '-new']:
                # Already handled
                pass
            elif argType.startswith('/goto:'):
                gotoline = int(argType[len('/goto:'):])
                if dde:
                    dde.Exec("from pywin.framework import scriptutils\n"
                             "ed = scriptutils.GetActiveEditControl()\n"
                             "if ed: ed.SetSel(ed.LineIndex(%s - 1))" %
                             gotoline)
                else:
                    from . import scriptutils
                    ed = scriptutils.GetActiveEditControl()
                    if ed: ed.SetSel(ed.LineIndex(gotoline - 1))
            elif argType == "/edit":
                # Load up the default application.
                i += 1
                fname = win32api.GetFullPathName(par)
                if not os.path.isfile(fname):
                    # if we don't catch this, OpenDocumentFile() (actually
                    # PyCDocument.SetPathName() in
                    # pywin.scintilla.document.CScintillaDocument.OnOpenDocument)
                    # segfaults Pythonwin on recent PY3 builds (b228)
                    win32ui.MessageBox(
                        "No such file: %s\n\nCommand Line: %s" %
                        (fname, win32api.GetCommandLine()),
                        "Open file for edit", win32con.MB_ICONERROR)
                    continue
                if dde:
                    dde.Exec("win32ui.GetApp().OpenDocumentFile(%s)" %
                             (repr(fname)))
                else:
                    win32ui.GetApp().OpenDocumentFile(par)
            elif argType == "/rundlg":
                if dde:
                    dde.Exec(
                        "from pywin.framework import scriptutils;scriptutils.RunScript(%r, %r, 1)"
                        % (par, ' '.join(args[i + 1:])))
                else:
                    from . import scriptutils
                    scriptutils.RunScript(par, ' '.join(args[i + 1:]))
                return
            elif argType == "/run":
                if dde:
                    dde.Exec(
                        "from pywin.framework import scriptutils;scriptutils.RunScript(%r, %r, 0)"
                        % (par, ' '.join(args[i + 1:])))
                else:
                    from . import scriptutils
                    scriptutils.RunScript(par, ' '.join(args[i + 1:]), 0)
                return
            elif argType == "/app":
                raise RuntimeError(
                    "/app only supported for new instances of Pythonwin.exe")
            elif argType == '/dde':  # Send arbitary command
                if dde is not None:
                    dde.Exec(par)
                else:
                    win32ui.MessageBox(
                        "The /dde command can only be used\r\nwhen Pythonwin is already running"
                    )
                i += 1
            else:
                raise ValueError("Command line argument not recognised: %s" %
                                 argType)
Example #18
0
def LoadPreference(preference, default=""):
    return win32ui.GetProfileVal(sectionProfile, preference, default)
Example #19
0
 def LoadPreference(self, name, default):
     rc = win32ui.GetProfileVal("Format", name, default)
     if rc == default:
         rc = win32ui.GetProfileVal(sectionProfile, name, default)
     return rc
Example #20
0
 def ProcessArgs(self, args, dde=None):
     # If we are going to talk to a remote app via DDE, then
     # activate it!
     if dde is not None: dde.Exec("self.Activate()")
     if len(args) and args[0] in ['/nodde', '/newinstance']:
         del args[0]  # already handled.
     if len(args) < 1 or not args[
             0]:  # argv[0]=='' when started without args, just like Python.exe!
         return
     try:
         if args[0] and args[0][0] != '/':
             argStart = 0
             argType = string.lower(
                 win32ui.GetProfileVal("Python", "Default Arg Type",
                                       "/edit"))
         else:
             argStart = 1
             argType = args[0]
         if argStart >= len(args):
             raise TypeError, "The command line requires an additional arg."
         if argType == "/edit":
             # Load up the default application.
             if dde:
                 fname = win32api.GetFullPathName(args[argStart])
                 dde.Exec("win32ui.GetApp().OpenDocumentFile(%s)" %
                          ( ` fname `))
             else:
                 win32ui.GetApp().OpenDocumentFile(args[argStart])
         elif argType == "/rundlg":
             if dde:
                 dde.Exec(
                     "import scriptutils;scriptutils.RunScript('%s', '%s', 1)"
                     % (args[argStart], string.join(args[argStart + 1:])))
             else:
                 import scriptutils
                 scriptutils.RunScript(args[argStart],
                                       string.join(args[argStart + 1:]))
         elif argType == "/run":
             if dde:
                 dde.Exec(
                     "import scriptutils;scriptutils.RunScript('%s', '%s', 0)"
                     % (args[argStart], string.join(args[argStart + 1:])))
             else:
                 import scriptutils
                 scriptutils.RunScript(args[argStart],
                                       string.join(args[argStart + 1:]), 0)
         elif argType == "/app":
             raise RuntimeError, "/app only supported for new instances of Pythonwin.exe"
         elif argType == '/new':  # Allow a new instance of Pythonwin
             return 1
         elif argType == '/dde':  # Send arbitary command
             if dde is not None:
                 dde.Exec(args[argStart])
             else:
                 win32ui.MessageBox(
                     "The /dde command can only be used\r\nwhen Pythonwin is already running"
                 )
         else:
             raise TypeError, "Command line arguments not recognised"
     except:
         typ, val, tb = sys.exc_info()
         print "There was an error processing the command line args"
         traceback.print_exception(typ, val, tb, None, sys.stdout)
         win32ui.OutputDebug(
             "There was a problem with the command line args - %s: %s" %
             ( ` typ `, ` val `))
         tb = None  # Prevent a cycle
 def LoadPreference(self, name, default):
     return win32ui.GetProfileVal("Format", name, default)
Example #22
0
 def IsFirstTime(self):
     return win32ui.GetProfileVal('GRiNSToolBars-Summary', 'Bars', -1) == -1
Example #23
0
def DoGetOption(optsDict, optName, default):
    optsDict[optName] = win32ui.GetProfileVal("Debugger Options", optName,
                                              default)