Python win32ui.MessageBox() Examples
The following are 30
code examples of win32ui.MessageBox().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32ui
, or try the search function
.
Example #1
Source File: app.py From ironpython2 with Apache License 2.0 | 6 votes |
def OnHelp(self,id, code): try: if id==win32ui.ID_HELP_GUI_REF: helpFile = regutil.GetRegisteredHelpFile("Pythonwin Reference") helpCmd = win32con.HELP_CONTENTS else: helpFile = regutil.GetRegisteredHelpFile("Main Python Documentation") helpCmd = win32con.HELP_FINDER if helpFile is None: win32ui.MessageBox("The help file is not registered!") else: import help help.OpenHelpFile(helpFile, helpCmd) except: t, v, tb = sys.exc_info() win32ui.MessageBox("Internal error in help file processing\r\n%s: %s" % (t,v)) tb = None # Prevent a cycle
Example #2
Source File: intpyapp.py From ironpython2 with Apache License 2.0 | 6 votes |
def OnViewBrowse( self, id, code ): " Called when ViewBrowse message is received " from pywin.mfc import dialog from pywin.tools import browser obName = dialog.GetSimpleInput('Object', '__builtins__', 'Browse Python Object') if obName is None: return try: browser.Browse(eval(obName, __main__.__dict__, __main__.__dict__)) except NameError: win32ui.MessageBox('This is no object with this name') except AttributeError: win32ui.MessageBox('The object has no attribute of that name') except: traceback.print_exc() win32ui.MessageBox('This object can not be browsed')
Example #3
Source File: intpyapp.py From ironpython2 with Apache License 2.0 | 6 votes |
def OnFileLocate( self, id, code ): from pywin.mfc import dialog import scriptutils import os global lastLocateFileName # save the new version away for next time... name = dialog.GetSimpleInput('File name', lastLocateFileName, 'Locate Python File') if name is None: # Cancelled. return lastLocateFileName = name # if ".py" supplied, rip it off! # should also check for .pys and .pyw if lastLocateFileName[-3:].lower()=='.py': lastLocateFileName = lastLocateFileName[:-3] lastLocateFileName = lastLocateFileName.replace(".","\\") newName = scriptutils.LocatePythonFile(lastLocateFileName) if newName is None: win32ui.MessageBox("The file '%s' can not be located" % lastLocateFileName) else: win32ui.GetApp().OpenDocumentFile(newName) # Display all the "options" proprety pages we can find
Example #4
Source File: document.py From ironpython2 with Apache License 2.0 | 6 votes |
def OnOpenDocument(self, filename): # init data members #print "Opening", filename self.SetPathName(filename) # Must set this early! try: # load the text as binary we can get smart # about detecting any existing EOL conventions. f = open(filename, 'rb') try: self._LoadTextFromFile(f) finally: f.close() except IOError: win32ui.MessageBox("Could not load the file from %s" % filename) return 0 return 1
Example #5
Source File: view.py From ironpython2 with Apache License 2.0 | 6 votes |
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 #6
Source File: __init__.py From ironpython2 with Apache License 2.0 | 5 votes |
def LoadDefaultEditor(): pass ## prefModule = GetDefaultEditorModuleName() ## restorePrefModule = None ## mod = None ## if prefModule: ## try: ## mod = __import__(prefModule) ## except 'xx': ## msg = "Importing your preferred editor ('%s') failed.\n\nError %s: %s\n\nAn attempt will be made to load the default editor.\n\nWould you like this editor disabled in the future?" % (prefModule, sys.exc_info()[0], sys.exc_info()[1]) ## rc = win32ui.MessageBox(msg, "Error importing editor", win32con.MB_YESNO) ## if rc == win32con.IDNO: ## restorePrefModule = prefModule ## WriteDefaultEditorModule("") ## del rc ## ## try: ## # Try and load the default one - dont catch errors here. ## if mod is None: ## prefModule = "pywin.framework.editor.color.coloreditor" ## mod = __import__(prefModule) ## ## # Get at the real module. ## mod = sys.modules[prefModule] ## ## # Do a "from mod import *" ## globals().update(mod.__dict__) ## ## finally: ## # Restore the users default editor if it failed and they requested not to disable it. ## if restorePrefModule: ## WriteDefaultEditorModule(restorePrefModule)
Example #7
Source File: dbgcommands.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnAdd(self, msg, code): doc, view = scriptutils.GetActiveEditorDocument() if doc is None: ## Don't do a messagebox, as this could be triggered from the app's ## idle loop whenever the debug toolbar is visible, giving a never-ending ## series of dialogs. This can happen when the OnUpdate handler ## for the toolbar button IDC_DBG_ADD fails, since MFC falls back to ## sending a normal command if the UI update command fails. ## win32ui.MessageBox('There is no active window - no breakpoint can be added') warnings.warn('There is no active window - no breakpoint can be added') return None pathName = doc.GetPathName() lineNo = view.LineFromChar(view.GetSel()[0])+1 # If I have a debugger, then tell it, otherwise just add a marker d=self._GetDebugger() if d is None: import pywin.framework.editor.color.coloreditor doc.MarkerToggle(lineNo, pywin.framework.editor.color.coloreditor.MARKER_BREAKPOINT) else: if d.get_break(pathName, lineNo): win32ui.SetStatusText('Clearing breakpoint',1) rc = d.clear_break(pathName, lineNo) else: win32ui.SetStatusText('Setting breakpoint',1) rc = d.set_break(pathName, lineNo) if rc: win32ui.MessageBox(rc) d.GUIRespondDebuggerData()
Example #8
Source File: intpyapp.py From ironpython2 with Apache License 2.0 | 5 votes |
def DoLoadModules(self, moduleNames): # ", sep string of module names. if not moduleNames: return modules = moduleNames.split(",") for module in modules: try: __import__(module) except: # Catch em all, else the app itself dies! 'ImportError: traceback.print_exc() msg = 'Startup import of user module "%s" failed' % module print msg win32ui.MessageBox(msg) # # DDE Callback #
Example #9
Source File: bitmap.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnNewDocument(self): # I can not create new bitmaps. win32ui.MessageBox("Bitmaps can not be created.")
Example #10
Source File: bitmap.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnOpenDocument(self, filename): self.bitmap=win32ui.CreateBitmap() # init data members f = open(filename, 'rb') try: try: self.bitmap.LoadBitmapFile(f) except IOError: win32ui.MessageBox("Could not load the bitmap from %s" % filename) return 0 finally: f.close() self.size = self.bitmap.GetSize() return 1
Example #11
Source File: duckhunt.py From duckhunt with MIT License | 5 votes |
def caught(event): global intrusion, policy, randdrop print "Quack! Quack! -- Time to go Duckhunting!" intrusion = True; #Paranoid Policy if (policy == "paranoid"): win32ui.MessageBox("Someone might be trying to inject keystrokes into your computer.\nPlease check your ports or any strange programs running.\nEnter your Password to unlock keyboard.", "KeyInjection Detected",4096) # MB_SYSTEMMODAL = 4096 -- Always on top. return False; #Sneaky Policy elif (policy == "sneaky"): randdrop += 1 #Drop every 5th letter if (randdrop==7): randdrop = 0; return False; else: return True; #Logging Only Policy elif (policy == "log"): log(event) return True; #Normal Policy log(event) return False #This is triggered every time a key is pressed
Example #12
Source File: document.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnSaveDocument( self, fileName ): win32ui.SetStatusText("Saving file...",1) # rename to bak if required. dir, basename = os.path.split(fileName) if self.bakFileType==BAK_DOT_BAK: bakFileName=dir+'\\'+os.path.splitext(basename)[0]+'.bak' elif self.bakFileType==BAK_DOT_BAK_TEMP_DIR: bakFileName=win32api.GetTempPath()+'\\'+os.path.splitext(basename)[0]+'.bak' elif self.bakFileType==BAK_DOT_BAK_BAK_DIR: tempPath=os.path.join(win32api.GetTempPath(),'bak') try: os.mkdir(tempPath,0) except os.error: pass bakFileName=os.path.join(tempPath,basename) try: os.unlink(bakFileName) # raise NameError if no bakups wanted. except (os.error, NameError): pass try: # Do a copy as it might be on different volumes, # and the file may be a hard-link, causing the link # to follow the backup. shutil.copy2(fileName, bakFileName) except (os.error, NameError, IOError): pass try: self.SaveFile(fileName) except IOError, details: win32ui.MessageBox("Error - could not save file\r\n\r\n%s"%details) return 0
Example #13
Source File: document.py From ironpython2 with Apache License 2.0 | 5 votes |
def MakeDocumentWritable(self): pretend_ss = 0 # Set to 1 to test this without source safe :-) if not self.scModuleName and not pretend_ss: # No Source Control support. win32ui.SetStatusText("Document is read-only, and no source-control system is configured") win32api.MessageBeep() return 0 # We have source control support - check if the user wants to use it. msg = "Would you like to check this file out?" defButton = win32con.MB_YESNO if self.IsModified(): msg = msg + "\r\n\r\nALL CHANGES IN THE EDITOR WILL BE LOST" defButton = win32con.MB_YESNO if win32ui.MessageBox(msg, None, defButton)!=win32con.IDYES: return 0 if pretend_ss: print "We are only pretending to check it out!" win32api.SetFileAttributes(self.GetPathName(), win32con.FILE_ATTRIBUTE_NORMAL) self.ReloadDocument() return 1 # Now call on the module to do it. if self.scModule is None: try: self.scModule = __import__(self.scModuleName) for part in self.scModuleName.split('.')[1:]: self.scModule = getattr(self.scModule, part) except: traceback.print_exc() print "Error loading source control module." return 0 if self.scModule.CheckoutFile(self.GetPathName()): self.ReloadDocument() return 1 return 0
Example #14
Source File: vss.py From ironpython2 with Apache License 2.0 | 5 votes |
def FindVssProjectInfo(fullfname): """Looks up the file system for an INI file describing the project. Looking up the tree is for ni style packages. Returns (projectName, pathToFileName) where pathToFileName contains the path from the ini file to the actual file. """ path, fnameonly = os.path.split(fullfname) origPath = path project = "" retPaths = [fnameonly] while not project: iniName = os.path.join(path, g_iniName) database = win32api.GetProfileVal("Python","Database", "", iniName) project = win32api.GetProfileVal("Python","Project", "", iniName) if project: break; # No valid INI file in this directory - look up a level. path, addpath = os.path.split(path) if not addpath: # Root? break retPaths.insert(0, addpath) if not project: win32ui.MessageBox("%s\r\n\r\nThis directory is not configured for Python/VSS" % origPath) return return project, "/".join(retPaths), database
Example #15
Source File: editor.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnOpenDocument(self, filename): # # handle Unix and PC text file format. # # Get the "long name" of the file name, as it may have been translated # to short names by the shell. self.SetPathName(filename) # Must set this early! # Now do the work! self.BeginWaitCursor() win32ui.SetStatusText("Loading file...",1) try: f = open(filename,"rb") except IOError: win32ui.MessageBox(filename + '\nCan not find this file\nPlease verify that the correct path and file name are given') self.EndWaitCursor() return 0 raw=f.read() f.close() contents = self.TranslateLoadedData(raw) rc = 0 if win32ui.IsWin32s() and len(contents)>62000: # give or take a few bytes win32ui.MessageBox("This file is too big for Python on Windows 3.1\r\nPlease use another editor to view this file.") else: try: self.GetFirstView().SetWindowText(contents) rc = 1 except TypeError: # Null byte in file. win32ui.MessageBox("This file contains NULL bytes, and can not be edited") rc = 0 self.EndWaitCursor() self.SetModifiedFlag(0) # No longer dirty self._DocumentStateChanged() return rc
Example #16
Source File: vssutil.py From ironpython2 with Apache License 2.0 | 5 votes |
def MakeNewBuildNo(project, buildDesc = None, auto=0, bRebrand = 0): if buildDesc is None: buildDesc = "Created by Python" ss = GetSS() i = ss.VSSItem(project) num = CountCheckouts(i) if num > 0: msg = "This project has %d items checked out\r\n\r\nDo you still want to continue?" % num import win32ui if win32ui.MessageBox(msg, project, win32con.MB_YESNO) != win32con.IDYES: return oldBuild = buildNo = GetLastBuildNo(project) if buildNo is None: buildNo = "1" oldBuild = "<None>" else: try: buildNo = string.atoi(buildNo) if not bRebrand: buildNo = buildNo + 1 buildNo = str(buildNo) except ValueError: raise error("The previous label could not be incremented: %s" % (oldBuild)) if not auto: from pywin.mfc import dialog buildNo = dialog.GetSimpleInput("Enter new build number", buildNo, "%s - Prev: %s" % (project, oldBuild)) if buildNo is None: return i.Label(buildNo, "Build %s: %s" % (buildNo,buildDesc)) if auto: print "Branded project %s with label %s" % (project, buildNo) return buildNo
Example #17
Source File: __init__.py From OTMql4AMQP with GNU Lesser General Public License v3.0 | 5 votes |
def iMessageBox(sMsg, sTitle, iType, iIcon): """ A frivolity that demonstrates that Mark Hammond's win32 code is all callable by Python under Mt4. """ i = win32ui.MessageBox(sMsg, sTitle, iType | iIcon) # while != 0 ? win32ui.PumpWaitingMessages() return i
Example #18
Source File: cli.py From stuntcat with GNU Lesser General Public License v2.1 | 5 votes |
def __windowsbox(title, message): raise ImportError #the MessageBox command is crashing! import win32ui, win32con win32ui.MessageBox(message, title, win32con.MB_ICONERROR)
Example #19
Source File: testHost4Dbg.py From ironpython2 with Apache License 2.0 | 5 votes |
def msgbox(self, *args): msg = ''.join(map(str, args)) win32ui.MessageBox(msg)
Example #20
Source File: scriptutils.py From ironpython2 with Apache License 2.0 | 5 votes |
def RunTabNanny(filename): import cStringIO as io tabnanny = FindTabNanny() if tabnanny is None: win32ui.MessageBox("The TabNanny is not around, so the children can run amok!" ) return # Capture the tab-nanny output newout = io.StringIO() old_out = sys.stderr, sys.stdout sys.stderr = sys.stdout = newout try: tabnanny.check(filename) finally: # Restore output sys.stderr, sys.stdout = old_out data = newout.getvalue() if data: try: lineno = data.split()[1] lineno = int(lineno) _JumpToPosition(filename, lineno) try: # Try and display whitespace GetActiveEditControl().SCISetViewWS(1) except: pass win32ui.SetStatusText("The TabNanny found trouble at line %d" % lineno) except (IndexError, TypeError, ValueError): print "The tab nanny complained, but I cant see where!" print data return 0 return 1
Example #21
Source File: regedit.py From ironpython2 with Apache License 2.0 | 5 votes |
def EditValue(self, item): # Edit the current value class EditDialog(dialog.Dialog): def __init__(self, item): self.item = item dialog.Dialog.__init__(self, win32ui.IDD_LARGE_EDIT) def OnInitDialog(self): self.SetWindowText("Enter new value") self.GetDlgItem(win32con.IDCANCEL).ShowWindow(win32con.SW_SHOW) self.edit = self.GetDlgItem(win32ui.IDC_EDIT1) # Modify the edit windows style style = win32api.GetWindowLong(self.edit.GetSafeHwnd(), win32con.GWL_STYLE) style = style & (~win32con.ES_WANTRETURN) win32api.SetWindowLong(self.edit.GetSafeHwnd(), win32con.GWL_STYLE, style) self.edit.SetWindowText(str(self.item)) self.edit.SetSel(-1) return dialog.Dialog.OnInitDialog(self) def OnDestroy(self,msg): self.newvalue = self.edit.GetWindowText() try: index = self.GetNextItem(-1, commctrl.LVNI_SELECTED) except win32ui.error: return # No item selected. if index==0: keyVal = "" else: keyVal = self.GetItemText(index,0) # Query for a new value. try: newVal = self.GetItemsCurrentValue(item, keyVal) except TypeError, details: win32ui.MessageBox(details) return
Example #22
Source File: regedit.py From ironpython2 with Apache License 2.0 | 5 votes |
def OnDeleteKey(self,command, code): hitem = self.hierList.GetSelectedItem() item = self.hierList.ItemFromHandle(hitem) msg = "Are you sure you wish to delete the key '%s'?" % (item.keyName,) id = win32ui.MessageBox(msg, None, win32con.MB_YESNO) if id != win32con.IDYES: return if SafeApply(win32api.RegDeleteKey, (item.keyRoot, item.keyName), "deleting registry key" ): # Get the items parent. try: hparent = self.GetParentItem(hitem) except win32ui.error: hparent = None self.hierList.Refresh(hparent)
Example #23
Source File: hierlist.py From ironpython2 with Apache License 2.0 | 5 votes |
def TakeDefaultAction(self, item): win32ui.MessageBox('Got item ' + self.GetText(item)) ########################################################################## # # Classes for use with seperate HierListItems. # #
Example #24
Source File: view.py From ironpython2 with Apache License 2.0 | 5 votes |
def DoConfigChange(self): # Bit of a hack I dont kow what to do about - these should be "editor options" from pywin.framework.editor import GetEditorOption self.bAutoCompleteAttributes = GetEditorOption("Autocomplete Attributes", 1) self.bShowCallTips = GetEditorOption("Show Call Tips", 1) # Update the key map and extension data. configManager.configure(self, self._GetSubConfigNames()) if configManager.last_error: win32ui.MessageBox(configManager.last_error, "Configuration Error") self.bMatchBraces = GetEditorOption("Match Braces", 1) self.ApplyFormattingStyles(1)
Example #25
Source File: IDLEenvironment.py From ironpython2 with Apache License 2.0 | 5 votes |
def askyesno(self, caption, prompt, parent=None): return win32ui.MessageBox(prompt, caption, win32con.MB_YESNO)==win32con.IDYES ###################################################################### # The IDLE "Virtual Text Widget" methods that are exposed to the IDLE extensions. # # Is character at text_index in a Python string? Return 0 for # "guaranteed no", true for anything else.
Example #26
Source File: IDLEenvironment.py From ironpython2 with Apache License 2.0 | 5 votes |
def GetIDLEModule(module): try: # First get it from Pythonwin it is exists. modname = "pywin.idle." + module __import__(modname) except ImportError, details: msg = "The IDLE extension '%s' can not be located.\r\n\r\n" \ "Please correct the installation and restart the" \ " application.\r\n\r\n%s" % (module, details) win32ui.MessageBox(msg) return None
Example #27
Source File: demoutils.py From ironpython2 with Apache License 2.0 | 5 votes |
def NeedApp(): import win32ui rc = win32ui.MessageBox(NeedAppMsg % sys.argv[0], "Demos", win32con.MB_YESNO) if rc==win32con.IDYES: try: parent = win32ui.GetMainFrame().GetSafeHwnd() win32api.ShellExecute(parent, None, 'pythonwin.exe', '/app "%s"' % sys.argv[0], None, 1) except win32api.error, details: win32ui.MessageBox("Error executing command - %s" % (details), "Demos")
Example #28
Source File: demoutils.py From ironpython2 with Apache License 2.0 | 5 votes |
def NeedGoodGUI(): from pywin.framework.app import HaveGoodGUI rc = HaveGoodGUI() if not rc: win32ui.MessageBox(NeedGUIMsg, "Demos") return rc
Example #29
Source File: demoutils.py From ironpython2 with Apache License 2.0 | 5 votes |
def NotAScript(): import win32ui win32ui.MessageBox(NotScriptMsg, "Demos")
Example #30
Source File: demoutils.py From ironpython2 with Apache License 2.0 | 5 votes |
def NotAScript(): import win32ui win32ui.MessageBox(NotScriptMsg, "Demos")