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
def OnAddComment(self, cmd, code): addspecific= cmd==ID_ADDPYCHECKNO2 _=list(self.GetSel()) _.sort() start,end=_ line_start, line_end = self.LineFromChar(start), self.LineFromChar(end) first=1 for i in range(line_start,line_end+1): line = self.GetLine(i) m = regexGrep.match(line) if m: if first: first=0 cmnt=dialog.GetSimpleInput( "Add to %s lines" % (line_end-line_start+1), addspecific and " #$pycheck_no=%(errtext)s" or " #$pycheck_no" ) if not cmnt: return 0 ##import pywin.debugger;pywin.debugger.set_trace() fname = m.group(1) line = int(m.group(2)) view = scriptutils.JumpToDocument(fname,line) pos=view.LineIndex(line)-1 if view.GetTextRange(pos-1,pos) in ('\r','\n'): pos -= 1 view.SetSel(pos, pos) errtext=m.group(3) if start!=end and line_start==line_end: errtext=self.GetSelText() errtext=repr(re.escape(errtext).replace('\ ',' ')) view.ReplaceSel( addspecific and cmnt % locals() or cmnt ) return 0
def OnFileLocate(self, id, code): from pywin.mfc import dialog import scriptutils import os global lastLocateFileName # save the new version away for next time... # Loop until a good name, or cancel while 1: name = dialog.GetSimpleInput('File name', lastLocateFileName, 'Locate Python File') if name is None: # Cancelled. break lastLocateFileName = name # if ".py" supplied, rip it off! if string.lower(lastLocateFileName[-3:]) == '.py': lastLocateFileName = lastLocateFileName[:-3] lastLocateFileName = string.translate(lastLocateFileName, string.maketrans(".", "\\")) newName = scriptutils.LocatePythonFile(lastLocateFileName) if newName is None: win32ui.MessageBox("The file '%s' can not be located" % lastLocateFileName) else: win32ui.GetApp().OpenDocumentFile(newName) break
def OnAddKey(self, command, code): from pywin.mfc import dialog val = dialog.GetSimpleInput("New key name", '', "Add new key") if val is None: return # cancelled. hitem = self.hierList.GetSelectedItem() item = self.hierList.ItemFromHandle(hitem) if SafeApply(win32api.RegCreateKey, (item.keyRoot, item.keyName + "\\" + val)): self.hierList.Refresh(hitem)
def OnAddValue(self, command, code): from pywin.mfc import dialog val = dialog.GetSimpleInput("New value", "", "Add new value") if val is None: return # cancelled. hitem = self.hierList.GetSelectedItem() item = self.hierList.ItemFromHandle(hitem) if SafeApply(win32api.RegSetValue, (item.keyRoot, item.keyName, win32con.REG_SZ, val)): # Simply re-select the current item to refresh the right spitter. self.PerformItemSelected(item)
def Win32RawInput(prompt=None): "Provide raw_input() for gui apps" # flush stderr/out first. try: sys.stdout.flush() sys.stderr.flush() except: pass if prompt is None: prompt = "" ret = dialog.GetSimpleInput(prompt) if ret == None: raise KeyboardInterrupt("operation cancelled") return ret
def OnViewBrowse(self, id, code): " Called when ViewBrowse message is received " 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')
def OnFileLocate(self, id, code): from . import scriptutils 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)
def Win32InputBox(title,prompt,defaultvalue=''): from pywin.mfc import dialog return dialog.GetSimpleInput(prompt,defaultvalue,title)
def set_key(sysTrayIcon): current_val = sg_settings.get('key') new_val = dialog.GetSimpleInput('Key', current_val, 'Secret Key') if new_val is not None: sg_settings.save('key', new_val)
def min_send_interval(sysTrayIcon): current_val = sg_settings.get('min_send_interval') new_val = dialog.GetSimpleInput('Min time between SMS in secs', current_val, 'SMS Send Rate Limiting') if new_val is not None: sg_settings.save('min_send_interval', new_val)
def modem_port(sysTrayIcon): current_val = sg_settings.get('com_port') new_val = dialog.GetSimpleInput('Port, i.e. COM3', current_val, 'GSM Modem Port') if new_val is not None: sg_settings.save('com_port', new_val)
def server_port(sysTrayIcon): current_val = sg_settings.get('web_port') new_val = dialog.GetSimpleInput('Port', current_val, 'Web API Server Port') if new_val is not None: sg_settings.save('web_port', new_val)
def configurar(maquinas): url = json.loads(obter_configs(PLUGIN_NAME, 0))['configs'].get('url', {}).get('valor', 'http://127.0.0.1:4300/') url = dialog.GetSimpleInput(u"url do serviço", url, u"Configuração") if url is not None: gravar_config(PLUGIN_NAME, 'url', 0, url)