def LibraryOrganizerUndo(books): try: if File.Exists(UNDOFILE): loworkerform.ComicRack = ComicRack locommon.ComicRack = ComicRack lobookmover.ComicRack = ComicRack profiles, lastused = load_profiles(PROFILEFILE) undo_collection = UndoCollection() undo_collection.load(UNDOFILE) if len(undo_collection) > 0: undo_form = WorkerFormUndo(undo_collection, profiles) undo_form.ShowDialog() undo_form.Dispose() File.Delete(UNDOFILE) else: MessageBox.Show("Error loading Undo file", "Library Organizer - Undo") else: MessageBox.Show("Nothing to Undo", "Library Organizer - Undo") except Exception, ex: print "The following error occured" print Exception MessageBox.Show(str(ex))
def ShowAMPLLicenseFileMenuHandler(key, e): ampl_lic_path = None ampl_lic_source = "" # First, look for ampl_lic file in the same folder as ampl.exe exeFile = SolverStudio.GetAMPLPath(preferSolverStudioAMPL=False, mustExist=False) if exeFile != None: ampl_lic_path = SolverStudio.GetFileInSameDirectory(exeFile, "ampl.lic", mustExist=False) ampl_lic_source = "found in AMPL directory" #Next, look for an environment file AMPL_LICFILE that specifies the LICFILE path, # eg AMPL_LICFILE = C:\Ampl-Cplex-Gurobi-2013\ampl.lic if ampl_lic_path == None: ampl_lic_path = os.getenv("AMPL_LICFILE") ampl_lic_source = "specified by %AMPL_LICFILE%" # Finally, search the path for ampl.lic if ampl_lic_path == None: ampl_lic_path = SolverStudio.FindFileOnSystemPath("ampl.lic") ampl_lic_source = "found on system %PATH%" if ampl_lic_path == None: MessageBox.Show("No ampl.lic file could be found.", "SolverStudio") return try: with open(ampl_lic_path, "rb") as inFile: licenseText = inFile.read() except Exception as ex: MessageBox.Show( "An error occurred try to read the AMPL license file '" + ampl_lic_path + "' " + ampl_lic_source + "\n\n" + str(ex), "SolverStudio") return MessageBox.Show( "AMPL License File '" + ampl_lic_path + "' " + ampl_lic_source + ":\n\n" + licenseText, "SolverStudio")
def P3_update1(self, sender, args): temp = False check_1 = self.check1.Checked check_2 = self.check2.Checked check_3 = self.check3.Checked check_4 = self.check4.Checked check_5 = self.check5.Checked check_6 = self.check6.Checked check_7 = self.check7.Checked for x in range(1, 8): if locals()['check_' + str(x)] == True: AddMaterial(metal_material_name[x - 1], 1, metal_material_cond[x - 1]) temp = True if temp == True: MessageBox.Show("创建完成") self.check1.CheckState = self.check1.CheckState.Unchecked self.check2.CheckState = self.check2.CheckState.Unchecked self.check3.CheckState = self.check3.CheckState.Unchecked self.check4.CheckState = self.check4.CheckState.Unchecked self.check5.CheckState = self.check5.CheckState.Unchecked self.check6.CheckState = self.check6.CheckState.Unchecked self.check7.CheckState = self.check7.CheckState.Unchecked self.check8.CheckState = self.check8.CheckState.Unchecked self.check8.Text = "全选" else: MessageBox.Show("请选择材料!!")
def button1_Click_1(self, sender, e): dialog = SaveFileDialog() dialog.Filter = "aedt files (*.aedt)|*.aedt" if dialog.ShowDialog() == DialogResult.OK: for i in self.Controls: i.Enabled = False model = generateSourceSinkModel(padInfo) ExportQ3D(dialog.FileName) source_sink_faces = getSourceSinkFaces(model) isSourceMerge = self.checkBox1.Checked isSinkMerge = self.checkBox2.Checked try: global rule rule = self.toolStripComboBox1.Text setSourceSink(source_sink_faces, isSourceMerge, isSinkMerge) removeSheet() except: logging.exception(source_sink_faces) MessageBox.Show("Failed!", 'Error') raise MessageBox.Show("Completed!", 'Information') self.Close() else: pass
def BackgroundWorkerCompleted(self, sender, e): self._progressBar.Visible = False #Catch any errors. if e.Error: MessageBox.Show("An error occured when trying to find the series. The error was:\n\n" + e.Error.InnerException.Message + "\n" + e.Error.Message, "Error occured", MessageBoxButtons.OK, MessageBoxIcon.Error) self.DialogResult = DialogResult.Abort else: series = e.Result #series should be list #If more than one series: if len(series) > 1: chooser = SeriesChooserForm(series) result = chooser.ShowDialog() if result == DialogResult.OK: self._series = chooser._lbSeries.SelectedItem self.DialogResult = DialogResult.OK else: self.DialogResult = DialogResult.Cancel elif len(series) == 1: self._series = series[0] self.DialogResult = DialogResult.OK else: MessageBox.Show("No comics found with this barcode", "No results") self.DialogResult = DialogResult.Cancel
def update(self, sender, event): temp1 = self.textbox1.Text temp2 = self.textbox2.Text if (float(temp1) > 0) and (float(temp2) > 0): MessageBox.Show("根据工艺添加介质层参数") else: MessageBox.Show("错误参数!!")
def ImportGDXMenuHandler(key, e): oldDirectory = SolverStudio.ChangeToWorkingDirectory() #if SolverStudio.Is64Bit(): # DLLpath=SolverStudio.GetGAMSDLLPath() + "\\gdxdclib64.dll" #else: # DLLpath=SolverStudio.GetGAMSDLLPath() + "\\gdxdclib.dll" #if not os.path.exists(SolverStudio.WorkingDirectory() + "\\gdxdclib.dll"): # copy2(DLLpath,SolverStudio.WorkingDirectory() + "\\gdxdclib.dll") gdxPath = GetGDXPath(key, e) if gdxPath == "CANCELLED": return initialScreenUpdating = Application.ScreenUpdating Application.ScreenUpdating = False varChoice = MessageBox.Show("Would you like to import the variables only?", "SolverStudio", MessageBoxButtons.YesNo) if varChoice == DialogResult.Yes: varOnly = True else: varOnly = False groupChoice = MessageBox.Show( "Would you like to group the data items for easier viewing?", "SolverStudio", MessageBoxButtons.YesNo) if groupChoice == DialogResult.Yes: group = True else: group = False PGX = SolverStudio.OpenGDX(gdxPath) SolverStudio.ImportGDX(PGX, gdxPath, varOnly, group) SolverStudio.CloseGDX(PGX) Application.ScreenUpdating = initialScreenUpdating SolverStudio.SetCurrentDirectory(oldDirectory) return
def BtnSearchClick(self, sender, e): if not self._backgroundWorker.IsBusy: barcode = self._tbBarcode.Text if barcode: #first checks if the barcode contains letters: try: int(barcode) except ValueError: MessageBox.Show("The value entered can only contain numbers. Please enter a valid barcode", "Barcode not valid") self._tbBarcode.Text = "" return #Several cases here depending on if the barcode is upc or ean and what supplmentals are added if len(barcode) not in [12, 13, 14, 15, 17, 18]: MessageBox.Show("The barcode entered was not a vaild UPC/EAN. Please try again", "Barcode not valid") return else: barcode, self._issue, type = FindBarcodeType(barcode) if barcode: self._publisher = FindPublisher(barcode) self._backgroundWorker.RunWorkerAsync(dict({"Barcode" : barcode, "Type" : type})) self._progressBar.Visible = True else: self.DialogResult = DialogResult.Cancel else: MessageBox.Show("Please enter a barcode", "No Barcode entered")
def handle_error(error): ''' Handles the given error object (a python or .net exception) by formatting it nicely and then printing it to the debug log. If the 'app_window' provided to the 'install' method was not None, an "unexpected error" message will also be displayed for the user in a modal dialog owned by the app_window. This method should be an application's normal way to handle unexpected errors and exceptions. ''' global __logger, __app_window if not __logger: return # if none, do current python exception. else sstr() the given exception if isinstance(error, Exception): debug("------------------- PYTHON ERROR ------------------------") debug_exc() # a python exception else: debug("-------------------- .NET ERROR -------------------------") debug(utils.sstr(error).replace('\r','')) # a .NET exception if __app_window: handled = False if type(error) == DatabaseConnectionError: # if this is a DatabaseConnectionError, then it is a semi-expected # error that may get a special error message if error.get_error_code_s() == "100": # coryhigh: i18n MessageBox.Show(__app_window, # invalid api key i18n.get("LogDBErrorApiKeyText").format(error.get_db_name_s()), i18n.get("LogDBErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Warning) handled = True elif error.get_error_code_s() == "107": MessageBox.Show(__app_window, # rate limit reached i18n.get("LogDBErrorRateText").format(error.get_db_name_s()), i18n.get("LogDBErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Warning) handled = True elif error.get_error_code_s() == "0": MessageBox.Show(__app_window, # generic i18n.get("LogDBErrorText").format(error.get_db_name_s()), i18n.get("LogDBErrorTitle"), MessageBoxButtons.OK, MessageBoxIcon.Warning) handled = True if not handled: # all other errors are considered "unexpected", and handled generically result = MessageBox.Show(__app_window, i18n.get("LogErrorText"), i18n.get("LogErrorTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Error) if result == DialogResult.Yes: save(True)
def StopAMPLLicenseServerMenuHandler(key, e): AMPLLicenseMgrPath = SolverStudio.GetRunningAMPLLicenseMgrPath() if AMPLLicenseMgrPath == None: MessageBox.Show("No running AMPL license server was found.", "SolverStudio") return SolverStudio.StartEXE(AMPLLicenseMgrPath, "stop", createWindow=False) MessageBox.Show("Stopping AMPL License Manager:\n" + AMPLLicenseMgrPath, "SolverStudio")
def CheckTextBox(self, sender, e): if not self.TextBox.Text.strip(): MessageBox.Show("Please enter a name into the textbox") self.DialogResult = DialogResult.None if self.TextBox.Text.strip() in self.Owner.ScannerNames.Items: MessageBox.Show( "The entered name is already in entered. Please enter another") self.DialogResult = DialogResult.None
def p2reset(self, sender, event): global refresh_count2 if (self.p2list1.SelectedItem != None): self.p2list1.Items.Clear() self.p2list1.Text = '——Select' refresh_count2 = 0 MessageBox.Show("已重置!!") else: MessageBox.Show("已重置!!")
def load_profiles_from_file(file_path): """ Loads profiles from a file. file_path->The absolute path the xml file Returns a dict of the profiles """ profiles = {} lastused = "" if File.Exists(file_path): try: with StreamReader(file_path) as xmlfile: xmldoc = XmlDocument() xmldoc.Load(xmlfile) if xmldoc.DocumentElement.Name == "Profiles": nodes = xmldoc.SelectNodes("Profiles/Profile") #Individual exported profiles are saved with the document element as Profile elif xmldoc.DocumentElement.Name == "Profile": nodes = xmldoc.SelectNodes("Profile") #Changed from 1.7 to 2.0 to use Profiles/Profile instead of Settings/Setting elif xmldoc.DocumentElement.Name == "Settings": nodes = xmldoc.SelectNodes("Settings/Setting") elif xmldoc.DocumentElement.Name == "Setting": nodes = xmldoc.SelectNodes("Setting") #No valid root elements else: MessageBox.Show(file_path + " is not a valid Library Organizer profile file.", "Not a valid profile file", MessageBoxButtons.OK, MessageBoxIcon.Error) return profiles, lastused if nodes.Count > 0: for node in nodes: profile = Profile() profile.Name = node.Attributes["Name"].Value result = profile.load_from_xml(node) #Error loading the profile if result == False: MessageBox.Show("An error occured loading the profile " + profile.Name + ". That profile has been skipped.") else: profiles[profile.Name] = profile #Load the last used profile rootnode = xmldoc.DocumentElement if rootnode.HasAttribute("LastUsed"): lastused = rootnode.Attributes["LastUsed"].Value.split(",") except Exception, ex: MessageBox.Show("Something seems to have gone wrong loading the xml file.\n\nThe error was:\n" + str(ex), "Error loading file", MessageBoxButtons.OK, MessageBoxIcon.Error)
def check_profile_name(self, sender, e): """Checks the entered profile name against all the existing profile names to ensure there are no duplicates.""" if not self._textbox.Text.strip(): MessageBox.Show("Please enter a name into the textbox") self.DialogResult = DialogResult.None if self._textbox.Text in self._profile_names: MessageBox.Show( "The entered name is already in use. Please enter another") self.DialogResult = DialogResult.None
def CheckTextBox(self, sender, e): if len(self.TextBox.Text) == 0: MessageBox.Show("Please enter a character into the textbox") self.DialogResult = DialogResult.None if self.TextBox.Text in self.existingchracters: MessageBox.Show( "The entered character is already in use. Please enter another" ) self.DialogResult = DialogResult.None
def p2update(self, sender, event): temp = self.p2list1.SelectedItem unPort = oEditor.GetObjectsInGroup("Unassigned") unPortID = [] for x in range(0, len(unPort)): unPortID.append(oEditor.GetFaceIDs(unPort[x])[0]) if unPortID and (temp != None): CreatePort(unPortID, unPort, temp) elif temp == None: MessageBox.Show("请选择参考金属") elif len(unPortID) == 0: MessageBox.Show("全部Port已完成") else: MessageBox.Show("错误参数!!")
def GetLicenseMgr(): exeFile = SolverStudio.GetAMPLPath(preferSolverStudioAMPL=False, mustExist=False) if exeFile == None: MessageBox.Show( "AMPL does not appear to be installed on this machine.") return None AMPLLicenseMgrPath = SolverStudio.GetAssociatedAMPLLicenseMgr(exeFile) if AMPLLicenseMgrPath == None: MessageBox.Show( "An AMPL license server does not appear to be installed on this machine.\nNote that the student version of AMPL does not use a license manager.", "SolverStudio") return None return AMPLLicenseMgrPath
def recursivevTextBoxCheck(self): isOK = True if (len(self.ListPanel.Controls) == 0): isOK = isOK & False MessageBox.Show("Please select list !") else: for panel in self.ListPanel.Controls: for control in panel.Controls: if (control.GetType() == type(TextBox())): if control.Text == "": isOK = isOK & False MessageBox.Show( "Please fill in number input box !") break return isOK
def __Run(self, message, modules, modifyDB = False): # Reload the Modules to make sure we're using the latest code. if self.reloadFunction: self.reloadFunction() if not self.dbName: self.reportWindow.Reporter.Error("No database selected! Use the Database button in the toolbar.") return if not modifyDB: modifyDB = (Control.ModifierKeys == Keys.Shift) self.reportWindow.Clear() if modifyDB: dlgmsg = "Are you sure you want to make changes to the '%s' database? "\ "(Please backup the project first.)" title = "Confirm allow changes" result = MessageBox.Show(dlgmsg % self.dbName, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question) if (result == DialogResult.No): return message += " (Changes enabled)" self.reportWindow.Reporter.Info(message) self.reportWindow.Refresh() self.moduleManager.RunModules(self.dbName, modules, self.reportWindow.Reporter, modifyDB) # Make sure the progress indicator is off self.reportWindow.Reporter.ProgressStop()
def SubmitHandler(self, sender, e): #Check if computer is part of a domain. try: clr.AddReference("System.DirectoryServices.ActiveDirectory") ctxType = ContextType.Domain except IOError: ctxType = ContextType.Machine ctx = PrincipalContext(ctxType) if ctx.ValidateCredentials(Env.UserName, self.inpBox.Text): startWatch.Stop() print "[+] CRED SUCCESS: Credentials validated against {0} -- {1}:{2}".format( ctx.ConnectedServer, Env.UserName, self.inpBox.Text) self.form.Dispose() self.form.Close() self.NewProcess = Process() self.NewProcess.StartInfo.FileName = self.path self.NewProcess.StartInfo.Arguments = self.proc['TargetInstance'][ 'CommandLine'].replace("\"{0}\"".format(self.path), "") GOT_CRED = True else: print "[-] CRED FAIL: Credentials failed against {0} -- {1}:{2}".format( Env.MachineName, Env.UserName, self.inpBox.Text) MessageBox.Show("Invalid Credentials!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
def Dialog_dir_backup(self): """ Ask user to use same directory as Revit file or Open a DialogBox to select destination folder manually.""" try: #>>>>>>>>>> Check if Revit file exists. file_exist = os.path.exists(doc.PathName) if file_exist: dialogResult = MessageBox.Show( "Would you like to save CAD files in the same folder as current Revit file?\n\n" + "Current file's path: " + str(doc.PathName), __title__, MessageBoxButtons.YesNo) if (dialogResult == DialogResult.Yes): #>>>>>>>>>> Saving folder is the same as Revit location doc_path = doc.PathName rvt_name = doc_path.split("\\")[-1] temp = len(doc_path) - len(rvt_name) doc_dir = doc_path[:temp] return doc_dir #>>>>>>>>>> CHOOSE SAVING DIR fileDialog = FolderBrowserDialog() fileDialog.Description = "Select folder for saving dwg files." fileDialog.ShowDialog() #>>>>>>>>>> SELECTED PATH dir_backup = fileDialog.SelectedPath if not dir_backup: alert("Backup path was not selected!\n Please try again.", title=__title__, exitscript=True) return dir_backup except: return None
def button_click(self, sender, event): number = int(self.tb.Text) file = self.filepath.Text netlist = '.subckt switch in ' + ' '.join( ['o' + str(i + 1) for i in range(number)]) + ' on=1 Zt=50\n' for i in range(number): if i == 0: netlist += '.if(on=={})\n'.format(i + 1) else: netlist += '.elseif(on=={})\n'.format(i + 1) for j in range(number): if i == j: netlist += 'r{0} o{0} in 0\n'.format(j + 1) else: netlist += 'r{0} o{0} 0 Zt\n'.format(j + 1) netlist += '.else\n' netlist += '\n'.join( ['r{0} o{0} 0 Zt'.format(i + 1) for i in range(number)]) netlist += '\n.endif\n.ends' with open(file, 'w') as f: f.writelines(netlist) MessageBox.Show(self.filepath.Text + " is generated!")
def IsVersionOK(): requiredVersion = Version(0, 9, 177) if str(ComicRack.App.ProductVersion) != str(requiredVersion): MessageBox.Show( ComicRack.MainWindow, "Version check failed!\n\nThe ComicRack Web Viewer Plugin requires a different version of ComicRack.\nComicRack version required: " + str(requiredVersion) + ".\nExiting...", "Incompatible ComicRack version", MessageBoxButtons.OK, MessageBoxIcon.Warning) return str(ComicRack.App.ProductVersion) == str(requiredVersion)
def _saveCSV(self,sender,event): csv = "" results = self.conn.executeGeneratedQuery(self.query) rows = [row for row in results.Tables[0].Rows] columns = [col for col in results.Tables[0].Columns] csv = ", ".join([item for item in self.lstSelectedGrpAttributesTabSelectTbcMain.Items]) if len(csv) == 0: csv = ", ".join([item for item in self.lstAvailableGrpAttributesTabSelectTbcMain.Items]) for row in rows: csv += "\n" for col in columns: csv += "{}, ".format(row[col]) fileName = "query_results" if self.txtFileName.Text != "": fileName = self.txtFileName.Text.replace(".csv",'') fileName = fileName + ".csv" filePath = os.path.join(self.txtFilePath.Text, fileName) try: with open(filePath,'w') as f: f.write(csv) except: status = "Save Failed." message = "Encountered an error while saving CSV. Ensure that file path is correct and not already open." status = "Save Complete." message = "CSV Saved Successfully to :\n\t{}".format(filePath) MessageBox.Show(message, status)
def _generateMetrics(self, sender, event): try: results = self.conn.executeGeneratedQuery(self.query) except: MessageBox.Show("Make sure your 'Where' datatypes are correct.", "Query Failed" ) return try: rows = [row for row in results.Tables[0].Rows] columns = [col for col in results.Tables[0].Columns] except: rows = [] columns = [] metrics = ['Minimum', 'Maximum', 'Range', 'Mean', 'Variance','Standard Deviation', 'Mode', 'Null Count'] #generalize dates so that they match more often for row in rows: try: if re.match("\d{4}-\d{2}-\d{2}",row[0].ToString()): for col in columns: row[col] = row[col][:10] except: pass #create list of selected attributes selectedAttributes = [item for item in self.lstSelectedGrpAttributesTabSelectTbcMain.Items] if len(selectedAttributes) == 0: selectedAttributes = [item for item in self.lstAvailableGrpAttributesTabSelectTbcMain.Items] #show metrics form frmMetrics = FrmMetrics(rows, columns, metrics, selectedAttributes) frmMetrics.Show()
def __OnLinkClicked(self, sender, event): try: os.startfile(event.LinkText) except WindowsError: MessageBox.Show("Error opening link", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
def Initialise(): #Menu.DropDownItems.Add( ToolStripMenuItem("Test",None,MenuTester) ) Menu.ToolStripMenuItem.MouseDown += Update NeosWarning() DLLPath = CheckDLL() try: if DLLPath[0]==";": DLLPath=DLLPath[1:] if not os.path.exists(DLLPath + "\\gmszlib1.dll"): choice = MessageBox.Show("The GAMS compression library not found. Check that gmszlib1.dll still exists in the GAMSDLLs folder included in SolverStudio. If not you will need to download a new copy of SolverStudio.","SolverStudio",MessageBoxButtons.OK) except: choice = MessageBox.Show("The GAMS compression library not found. Check that gmszlib1.dll still exists in the GAMSDLLs folder included in SolverStudio. If not you will need to download a new copy of SolverStudio.","SolverStudio",MessageBoxButtons.OK) # Menu.Add( "View last text data file",OpenDataFile) Menu.Add( "View last GAMS input data file in GAMSIDE",OpenInputDataInGamsIDE) Menu.AddSeparator() Menu.Add( "Import a GDX file",ImportGDXMenuHandler) #Menu.Add( "Create a GDX file using the Model Data",SaveGDXMenuHandler) Menu.AddSeparator() global doFixChoice doFixChoice=Menu.Add( "Fix Minor Errors",FixErrorClickMenu) global queueChoice queueChoice=Menu.Add( "Run in short queue",QueueClickMenu) global solverMenu chooseSolverMenu = Menu.Add ("Choose Solver",emptyClickMenu) gamsSolvers, categoryDict = ChooseSolver() solverMenu = {} try: for i in gamsSolvers: solverMenu[i]=[] categoryMenu = ToolStripMenuItem(categoryDict[i],None,emptyClickMenu) solverMenu[i].append(categoryMenu) chooseSolverMenu.DropDownItems.Add(categoryMenu) solverMenu[i].append({}) for j in gamsSolvers[i]: solverMenu[i][1][j] = ToolStripMenuItem(j,None,SolverClickMenu) categoryMenu.DropDownItems.Add(solverMenu[i][1][j]) except: choice = MessageBox.Show("A NEOS category is no longer supported by GAMSonNEOS.\nLaunch NEOS solver list updater.","SolverStudio",MessageBoxButtons.OK) if choice == DialogResult.OK: SolverStudio.RunInDialog("This will update the NEOS Solver List for GAMS.",UpdateSolverListWorker,True,True,True) Menu.AddSeparator() Menu.Add( "Open GAMS web page",OpenGAMSWebSite) Menu.Add( "Open GAMS online documentation",OpenGAMSOnlineDocumentation) Menu.Add( "Open GAMS download web page",OpenGAMSDownload) Menu.AddSeparator() Menu.Add( "Update NEOS Solvers",UpdateSolverListMenuHandler) Menu.Add( "Open the NEOS web page",OpenNEOSWebSite)
def FindBarcodeType(barcode): issueNumber = "" type = "" barcodeLength = len(barcode) #UPC-A if barcodeLength == 12: result = MessageBox.Show( "No issue code was entered. The script can try and look for the series but no issue number will be entered.\n\nContinue?", "No Issue code", MessageBoxButtons.YesNo, MessageBoxIcon.Question) if result == DialogResult.Yes: type = "upc" else: return None, None, None #EAN elif barcodeLength == 13: result = MessageBox.Show( "No issue code was entered. The script can try and look for the series but no issue number will be entered.\n\nContinue?", "No Issue code", MessageBoxButtons.YesNo, MessageBoxIcon.Question) if result == DialogResult.Yes: type = "ean" else: return None, None, None #UPC-A + UPC-5 elif barcodeLength == 17: issueNumber = ParseIssueNumber(barcode[12:17]) barcode = barcode[0:12] type = "upc" #EAN-13 + UPC-5 elif barcodeLength == 18: issueNumber = ParseIssueNumber(barcode[13:18]) barcode = barcode[0:13] type = "ean" #UPC-A + UPC-2 elif barcodeLength == 14: issueNumber = barcode[12:14] barcode = barcode[0:12] type = "upc" #EAN-13 + UPC-2 elif barcodeLength == 15: issueNumber = barcode[13:15] barcode = barcode[0:13] type = "ean" return barcode, issueNumber, type
def OpenInputDataInGamsIDE(key,e): try: oldDirectory = SolverStudio.ChangeToLanguageDirectory() gamsIDEPath=SolverStudio.GetEXEPath(exeName="gamside.exe", exeDirectory="gams*", mustExist=True) subprocess.call([gamsIDEPath, SolverStudio.WorkingDirectory()+"\\SheetData.gdx"]) SolverStudio.SetCurrentDirectory(oldDirectory) except: choice = MessageBox.Show("Unable to open last data file. You need a version of GAMS installed to view GDX files. You can always use \"GAMS>Import a GDX file>SheetData.gdx\" to open it in excel.","SolverStudio",MessageBoxButtons.OK)
def Help(helpfile): try: os.startfile(helpfile) except WindowsError: MessageBox.Show("Couldn't open help file '%s'" % helpfile, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)