def onDeleteItem(self, evt): """Remove selected items.""" # delete? title = 'Do you really want to delete selected monomers?' message = 'Monomer definitions will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # delete items for i in self.itemsList.getSelected(): index = self.itemsList.GetItemData(i) name = self.itemsMap[index][0] if not name in self.used: del mspy.monomers[name] else: wx.Bell() dlg = mwx.dlgMessage( self, title='Monomer "' + name + '" is currently used\nand cannot be removed.', message= 'Remove the monomer from all of your documents first.') dlg.ShowModal() dlg.Destroy() # update gui self.updateItemsList() self.clearEditor()
def onDeleteItem(self, evt): """Remove selected items.""" # delete? title = 'Do you really want to delete selected monomers?' message = 'Monomer definitions will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # delete items for i in self.itemsList.getSelected(): index = self.itemsList.GetItemData(i) name = self.itemsMap[index][0] if not name in self.used: del mspy.monomers[name] else: wx.Bell() dlg = mwx.dlgMessage(self, title='Monomer "'+name+'" is currently used\nand cannot be removed.', message='Remove the monomer from all of your documents first.') dlg.ShowModal() dlg.Destroy() # update gui self.updateItemsList() self.clearEditor()
def onAddItem(self, evt): """Add/replace item.""" # get item data itemData = self.getItemData() if not itemData: return # check regular amino acids if itemData.abbr in self._aminoacids: wx.Bell() dlg = mwx.dlgMessage(self, title='Specified abbreviation is reserved!', message='Specified abbreviation is already used for regular amino acids\nwhich cannot be modified.') dlg.ShowModal() dlg.Destroy() return # check name if itemData.abbr in mspy.monomers: wx.Bell() title = 'Monomer with the same abbreviation already exists.\nDo you want to replace it?' message = 'Old monomer definition will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # add/replace item mspy.monomers[itemData.abbr] = itemData # update gui self.updateItemsList() self.clearEditor()
def onGenerate(self, evt=None): """Generate formulae.""" # check processing if self.processing: return # clear previous data self.currentFormulae = None # get params if not self.getParams(): self.updateFormulaeList() wx.Bell() return # check mass limit if not self.checkMassLimit(): wx.Bell() message = "Neutral mass of your specified ion is too high (%.0f Da max)." % config.massToFormula['massLimit'] dlg = mwx.dlgMessage(self, title="Neutral mass is too high.", message=message) dlg.ShowModal() dlg.Destroy() return # show processing gauge self.onProcessing(True) self.generate_butt.Enable(False) # do processing self.processing = threading.Thread(target=self.runGenerator) self.processing.start() # pulse gauge while working while self.processing and self.processing.isAlive(): self.gauge.pulse() # update gui self.updateFormulaeList() # hide processing gauge self.onProcessing(False) self.generate_butt.Enable(True) # show limit warning if self.currentFormulae and len(self.currentFormulae) >= config.massToFormula['countLimit']: wx.Bell() dlg = mwx.dlgMessage(self, title="Maximum number of formulae reached.", message="The internal limit for number of formulae has been reached.\nPlease note that your formula could be missing.") dlg.ShowModal() dlg.Destroy()
def onDeleteItem(self, evt): """Remove selected items.""" # check group if not self.group: wx.Bell() return # delete? title = 'Do you really want to delete selected references?' message = 'Reference definitions will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # delete items indexes = [] for i in self.itemsList.getSelected(): index = self.itemsList.GetItemData(i) indexes.append(index) # delete items for i in sorted(indexes, reverse=True): del libs.references[self.group][i] # update gui self.updateItemsList() self.clearEditor()
def onDeleteGroup(self, evt): """Delete selected group.""" # check group if not self.group: wx.Bell() return # delete selected group title = 'Do you really want to delete selected group?' message = 'All references within the group will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # remove group del libs.references[self.group] # update gui self.updateGroups() self.groupName_choice.Select(0) self.onGroupSelected()
def onAddGroup(self, evt): """Add new group.""" # get group name dlg = dlgGroupName(self) if dlg.ShowModal() == wx.ID_OK: name = dlg.name dlg.Destroy() else: dlg.Destroy() return # check group name if name in libs.compounds: wx.Bell() dlg = mwx.dlgMessage(self, title='Group with the same name already exists.', message='Type a different name.') dlg.ShowModal() dlg.Destroy() return # add group libs.references[name] = [] # update gui self.updateGroups() self.groupName_choice.SetStringSelection(name) self.onGroupSelected()
def onDeleteItem(self, evt): """Remove selected items.""" # check group if not self.group: wx.Bell() return # delete? title = "Do you really want to delete selected compounds?" message = "Compound definitions will be lost." buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # delete items for i in self.itemsList.getSelected(): index = self.itemsList.GetItemData(i) name = self.itemsMap[index][0] del libs.compounds[self.group][name] # update gui self.updateItemsList() self.clearEditor()
def onAddItem(self, evt): """Add/replace item.""" # check group if not self.group: wx.Bell() return # get item data itemData = self.getItemData() if not itemData: return # check name if itemData.name in libs.compounds[self.group]: wx.Bell() title = "Compound with the same name already exists.\nDo you want to replace it?" message = "Old compound definition will be lost." buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # add/replace item libs.compounds[self.group][itemData.name] = itemData # update gui self.updateItemsList() self.clearEditor()
def onAddItem(self, evt): """Add/replace item.""" # get item data itemData = self.getItemData() if not itemData: return # check name name = self.itemName_value.GetValue() if name in libs.mascot: wx.Bell() title = 'Server with the same name already exists.\nDo you want to replace it?' message = 'Old server definition will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # add/replace item libs.mascot[name] = itemData # update gui self.updateItemsList() self.clearEditor()
def onApply(self, evt): """Apply current profile to current document.""" # check data and document if self.currentDocument == None or self.currentProfile == None: wx.Bell() return # ask to owerwrite spectrum if self.currentDocument.spectrum.hasprofile(): title = 'Do you really want to apply generated spectrum\nto current document?' message = 'Original profile data will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Apply", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # backup document self.currentDocument.backup(('spectrum')) # set profile to document points = self.currentProfile.copy() self.currentDocument.spectrum.setprofile(points) # update document self.parent.onDocumentChanged(items=('spectrum'))
def onRenameItem(self, evt): """Rename item.""" # check selection if self.selectedItem == None: wx.Bell() return # get item data itemData = self.getItemData() if not itemData: return # check name if itemData[0] in libs.presets[itemData[1]]: wx.Bell() dlg = mwx.dlgMessage(self, title='Presets with the same name already exists.', message='Type a different name.') dlg.ShowModal() dlg.Destroy() return # rename item oldName = self.itemsMap[self.selectedItem][0] data = copy.deepcopy(libs.presets[itemData[1]][oldName]) libs.presets[itemData[1]][itemData[0]] = data del libs.presets[itemData[1]][oldName] # update gui self.updateItemsList() self.clearEditor()
def onDeleteItem(self, evt): """Remove selected items.""" # delete? title = 'Do you really want to delete selected presets?' message = 'Presets definitions will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # delete items for i in self.itemsList.getSelected(): index = self.itemsList.GetItemData(i) name = self.itemsMap[index][0] category = self.itemsMap[index][1] del libs.presets[category][name] # update gui self.updateItemsList() self.clearEditor()
def onAddItem(self, evt): """Add/replace item.""" # get item data itemData = self.getItemData() if not itemData: return # check name if itemData.name in mspy.enzymes: wx.Bell() title = 'Enzyme with the same name already exists.\nDo you want to replace it?' message = 'Old enzyme definition will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # add/replace item mspy.enzymes[itemData.name] = itemData # update gui self.updateItemsList() self.clearEditor()
def checkParams(self): """Check search parameters.""" errors = '' # check taxonomy and database if not config.profound['taxonomy']: errors += '- Taxonomy must be selected.\n' if not config.profound['database']: errors += '- Database must be selected.\n' if not config.profound['enzyme']: errors += '- Enzyme must be selected.\n' # check query if not self.paramQuery_value.GetValue(): errors += '- Peak list is empty.\n' # show warning if errors if errors: wx.Bell() dlg = mwx.dlgMessage(self, title="You have the following errors in the search form.", message=errors) dlg.ShowModal() dlg.Destroy() return False else: return True
def onDeleteGroup(self, evt): """Delete selected group.""" # check group if not self.group: wx.Bell() return # delete selected group title = 'Do you really want to delete selected group?' message = 'All compounds within the group will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # remove group del libs.compounds[self.group] # update gui self.updateGroups() self.groupName_choice.Select(0) self.onGroupSelected()
def onAddItem(self, evt): """Add/replace item.""" # check group if not self.group: wx.Bell() return # get item data itemData = self.getItemData() if not itemData: return # check name if itemData.name in libs.compounds[self.group]: wx.Bell() title = 'Compound with the same name already exists.\nDo you want to replace it?' message = 'Old compound definition will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # add/replace item libs.compounds[self.group][itemData.name] = itemData # update gui self.updateItemsList() self.clearEditor()
def onRenameItem(self, evt): """Rename item.""" # check selection if self.selectedItem == None: wx.Bell() return # get item data itemData = self.getItemData() if not itemData: return # check name if itemData[0] in libs.presets[itemData[1]]: wx.Bell() dlg = mwx.dlgMessage( self, title='Presets with the same name already exists.', message='Type a different name.') dlg.ShowModal() dlg.Destroy() return # rename item oldName = self.itemsMap[self.selectedItem][0] data = copy.deepcopy(libs.presets[itemData[1]][oldName]) libs.presets[itemData[1]][itemData[0]] = data del libs.presets[itemData[1]][oldName] # update gui self.updateItemsList() self.clearEditor()
def onAddGroup(self, evt): """Add new group.""" # get group name dlg = dlgGroupName(self) if dlg.ShowModal() == wx.ID_OK: name = dlg.name dlg.Destroy() else: dlg.Destroy() return # check group name if name in libs.compounds: wx.Bell() dlg = mwx.dlgMessage( self, title='Group with the same name already exists.', message='Type a different name.') dlg.ShowModal() dlg.Destroy() return # add group libs.compounds[name] = {} # update gui self.updateGroups() self.groupName_choice.SetStringSelection(name) self.onGroupSelected()
def onCalculate(self, evt): """Generate compounds ions.""" # check processing if self.processing: return # clear recent self.currentCompound = None self.currentFit = None # check document if not self.currentDocument or not (self.currentDocument.spectrum.hasprofile() or self.currentDocument.spectrum.haspeaks()): wx.Bell() return # get params if not self.getParams(): self.updateAverageLabel() self.updateSpectrumCanvas() self.updateResultsList() return # show processing gauge self.onProcessing(True) self.calculate_butt.Enable(False) # do processing self.processing = threading.Thread(target=self.runEnvelopeFit) self.processing.start() # pulse gauge while working while self.processing and self.processing.isAlive(): self.gauge.pulse() # check error error = False if self.currentFit is False: self.currentFit = None error = True # update gui self.updateAverageLabel() self.updateSpectrumCanvas() self.updateResultsList() # hide processing gauge self.onProcessing(False) self.calculate_butt.Enable(True) # check errors if error: wx.Bell() dlg = mwx.dlgMessage(self, title="No data to fit.", message="There are no data in relevant mass range. Please check\nspecified formula, charge and default FWHM.") dlg.ShowModal() dlg.Destroy()
def onAddItem(self, evt): """Add/replace item.""" # get item data itemData = self.getItemData() if not itemData: return # check regular amino acids if itemData.abbr in self._aminoacids: wx.Bell() dlg = mwx.dlgMessage( self, title='Specified abbreviation is reserved!', message= 'Specified abbreviation is already used for regular amino acids\nwhich cannot be modified.' ) dlg.ShowModal() dlg.Destroy() return # check name if itemData.abbr in mspy.monomers: wx.Bell() title = 'Monomer with the same abbreviation already exists.\nDo you want to replace it?' message = 'Old monomer definition will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # add/replace item mspy.monomers[itemData.abbr] = itemData # update gui self.updateItemsList() self.clearEditor()
def onItemSearch(self, evt): """Make query and send formula to selected database.""" # get selected formula selected = self.formulaeList.getSelected() if selected: index = self.formulaeList.GetItemData(selected[0]) formula = self.currentFormulae[index][0] else: wx.Bell() return # get selected server if evt.GetId() == ID_massToFormulaSearchPubChem: server = 'PubChem' elif evt.GetId() == ID_massToFormulaSearchChemSpider: server = 'ChemSpider' elif evt.GetId() == ID_massToFormulaSearchMETLIN: server = 'METLIN' elif evt.GetId() == ID_massToFormulaSearchHMDB: server = 'HMDB' elif evt.GetId() == ID_massToFormulaSearchLipidMaps: server = 'Lipid MAPS' else: wx.Bell() return # make search html htmlData = self.makeSearchHTML(server, formula) # run search try: path = os.path.join(tempfile.gettempdir(), 'mmass_formula_search.html') htmlFile = file(path, 'w') htmlFile.write(htmlData.encode("utf-8")) htmlFile.close() webbrowser.open('file://'+path, autoraise=1) except: wx.Bell() dlg = mwx.dlgMessage(self, title='Unable to send data to '+server+' server.', message='Unknown error occured while creating the search page.') dlg.ShowModal() dlg.Destroy()
def onRenameGroup(self, evt): """Rename selected group.""" # check group if not self.group: wx.Bell() return # get group name dlg = dlgGroupName(self, self.group) if dlg.ShowModal() == wx.ID_OK: name = dlg.name dlg.Destroy() else: dlg.Destroy() return # check group name if name == self.group: return if name in libs.compounds: wx.Bell() dlg = mwx.dlgMessage( self, title='Group with the same name already exists.', message='Type a different name.') dlg.ShowModal() dlg.Destroy() return # rename group data = copy.deepcopy(libs.compounds[self.group]) libs.compounds[name] = data del libs.compounds[self.group] # update gui self.updateGroups() self.groupName_choice.SetStringSelection(name) self.onGroupSelected()
def onRenameGroup(self, evt): """Rename selected group.""" # check group if not self.group: wx.Bell() return # get group name dlg = dlgGroupName(self, self.group) if dlg.ShowModal() == wx.ID_OK: name = dlg.name dlg.Destroy() else: dlg.Destroy() return # check group name if name == self.group: return if name in libs.compounds: wx.Bell() dlg = mwx.dlgMessage( self, title="Group with the same name already exists.", message="Type a different name." ) dlg.ShowModal() dlg.Destroy() return # rename group data = copy.deepcopy(libs.compounds[self.group]) libs.compounds[name] = data del libs.compounds[self.group] # update gui self.updateGroups() self.groupName_choice.SetStringSelection(name) self.onGroupSelected()
def onDeleteItem(self, evt): """Remove selected items.""" # delete? title = 'Do you really want to delete selected servers?' message = 'Server definitions will be lost.' buttons = [(wx.ID_CANCEL, "Cancel", 80, False, 15), (wx.ID_OK, "Delete", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) if dlg.ShowModal() != wx.ID_OK: dlg.Destroy() return else: dlg.Destroy() # delete items for i in self.itemsList.getSelected(): index = self.itemsList.GetItemData(i) name = self.itemsMap[index][0] del libs.mascot[name] # update gui self.updateItemsList() self.clearEditor()
def onSearch(self, evt): """Make query and send data to ProFound.""" # get params if not self.getParams(): return # check params if not self.checkParams(): return # make temporary search file htmlData = self.makeSearchHTML() try: path = os.path.join(tempfile.gettempdir(), 'mmass_profound_search.html') htmlFile = file(path, 'w') htmlFile.write(htmlData.encode("utf-8")) htmlFile.close() webbrowser.open('file://'+path, autoraise=1) except: wx.Bell() dlg = mwx.dlgMessage(self, title='Unable to send data to ProFound server.', message='Unknown error occured while creating the search page.') dlg.ShowModal() dlg.Destroy()
def onImport(self, evt): """Import items from xml library.""" # show open file dialog wildcard = "Library files|*.xml;*.XML" dlg = wx.FileDialog(self, "Import Library", wildcard=wildcard, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() dlg.Destroy() else: dlg.Destroy() return # read data importedItems = self.readLibraryXML(path) if importedItems == False: wx.Bell() dlg = mwx.dlgMessage(self, title="Unrecognized library format.", message="Specified file is not a valid reference library.") dlg.ShowModal() dlg.Destroy() return elif importedItems == {}: wx.Bell() dlg = mwx.dlgMessage(self, title="No data to import.", message="Specified library contains no data.") dlg.ShowModal() dlg.Destroy() return # select groups to import dlg = dlgSelectItemsToImport(self, importedItems) if dlg.ShowModal() == wx.ID_OK: selected = dlg.selected dlg.Destroy() else: dlg.Destroy() return # check same items selectAfter = 'Reference lists' replaceAll = False for item in selected: if replaceAll or not item in libs.references: libs.references[item] = importedItems[item] selectAfter = item else: title = 'Group entitled "%s"\nis already in you library. Do you want to replace it?' % item message = "All references within this group will be lost." buttons = [(ID_dlgReplaceAll, "Replace All", 120, False, 40), (ID_dlgSkip, "Skip", 80, False, 15), (ID_dlgReplace, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) ID = dlg.ShowModal() if ID == ID_dlgSkip: continue elif ID == ID_dlgReplaceAll: replaceAll = True libs.references[item] = importedItems[item] selectAfter = item elif ID == ID_dlgReplace: libs.references[item] = importedItems[item] selectAfter = item # update gui self.updateGroups() self.groupName_choice.SetStringSelection(selectAfter) self.onGroupSelected()
def onCalculate(self, evt): """Generate compounds ions.""" # check processing if self.processing: return # clear recent self.currentCompound = None self.currentFit = None # check document if not self.currentDocument or not ( self.currentDocument.spectrum.hasprofile() or self.currentDocument.spectrum.haspeaks() ): wx.Bell() return # get params if not self.getParams(): self.updateAverageLabel() self.updateSpectrumCanvas() self.updateResultsList() return # show processing gauge self.onProcessing(True) self.calculate_butt.Enable(False) # do processing self.processing = threading.Thread(target=self.runEnvelopeFit) self.processing.start() # pulse gauge while working while self.processing and self.processing.isAlive(): self.gauge.pulse() # check error error = False if self.currentFit is False: self.currentFit = None error = True # update gui self.updateAverageLabel() self.updateSpectrumCanvas() self.updateResultsList() # hide processing gauge self.onProcessing(False) self.calculate_butt.Enable(True) # check errors if error: wx.Bell() dlg = mwx.dlgMessage( self, title="No data to fit.", message="There are no data in relevant mass range. Please check\nspecified formula, charge and default FWHM.", ) dlg.ShowModal() dlg.Destroy()
def onImport(self, evt): """Import items from xml library.""" # show open file dialog wildcard = "Library files|*.xml;*.XML" dlg = wx.FileDialog(self, "Import Library", wildcard=wildcard, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() dlg.Destroy() else: dlg.Destroy() return # read data importedItems = self.readLibraryXML(path) if importedItems == False: wx.Bell() dlg = mwx.dlgMessage( self, title="Unrecognized library format.", message="Specified file is not a valid compounds library.") dlg.ShowModal() dlg.Destroy() return elif importedItems == {}: wx.Bell() dlg = mwx.dlgMessage(self, title="No data to import.", message="Specified library contains no data.") dlg.ShowModal() dlg.Destroy() return # select groups to import dlg = dlgSelectItemsToImport(self, importedItems) if dlg.ShowModal() == wx.ID_OK: selected = dlg.selected dlg.Destroy() else: dlg.Destroy() return # check same items selectAfter = 'Compounds lists' replaceAll = False for item in selected: if replaceAll or not item in libs.compounds: libs.compounds[item] = importedItems[item] selectAfter = item else: title = 'Group entitled "%s"\nis already in you library. Do you want to replace it?' % item message = "All compounds within this group will be lost." buttons = [(ID_dlgReplaceAll, "Replace All", 120, False, 40), (ID_dlgSkip, "Skip", 80, False, 15), (ID_dlgReplace, "Replace", 80, True, 0)] dlg = mwx.dlgMessage(self, title, message, buttons) ID = dlg.ShowModal() if ID == ID_dlgSkip: continue elif ID == ID_dlgReplaceAll: replaceAll = True libs.compounds[item] = importedItems[item] selectAfter = item elif ID == ID_dlgReplace: libs.compounds[item] = importedItems[item] selectAfter = item # update gui self.updateGroups() self.groupName_choice.SetStringSelection(selectAfter) self.onGroupSelected()