def populate_widget(self): settings = Settings() # Update prefix prefix = settings.value("DB_NEW_REACT_PREFIX", DB_NEW_REACT_PREFIX) self.lineEdit_prefix.setText(prefix) # Update checkbox name_setting = settings.value("DB_GET_REACT_NAME", DB_GET_REACT_NAME) self.checkBox_use_name.setChecked(convert_to_bool(name_setting))
def populate_widget(self): settings = Settings() # Update prefix prefix = settings.value("DB_NEW_MET_PREFIX", DB_NEW_MET_PREFIX) self.lineEdit_prefix.setText(prefix) # Update checkbox name_setting = settings.value("DB_GET_MET_NAME", DB_GET_MET_NAME) self.checkBox_use_name.setChecked(convert_to_bool(name_setting)) formula_charge_setting = settings.value("DB_GET_FL_AND_CH", DB_GET_FL_AND_CH) self.checkBox_use_formula.setChecked( convert_to_bool(formula_charge_setting))
def retrieve_data(self): settings = Settings() email = settings.value("Email") tool = quote(settings.applicationName()) if not email: self.error.emit( "NCBI requests users of their webservice to identify themselves with an email adress! \n\nPlease set your email in the settings to download data from ncbi!" ) self.finished.emit() return try: self.information = get_pubmed_information(pmid=self.pmid, email=email, tool=tool) except URLError: self.error.emit( "There appears to be a problem with your internet connection!") except (ValueError, TypeError) as e: self.error.emit(repr(e)) self.finished.emit()
def load_knowns(self): settings = Settings() last_path = settings.value( "LastPath") or QStandardPaths.DesktopLocation or None filename, filters = QFileDialog.getOpenFileName( self, self.tr("Open known publications"), last_path, self.tr("Text file (*.txt)")) if filename: with open(filename, "r") as open_file: try: self.known_ids = dict( (line.strip("\n").split("\t")) for line in open_file) self.known_id_path = filename if self.found_ids: self.update_display(self.current_index, "right") except ValueError: self.error_dialog.showMessage("Wrong file format!") return for reference in self.parent().model.references.values(): if reference.pmid: self.known_ids[reference.pmid] = "Already in model!"
def __init__(self, mainwindow): QDialog.__init__(self, mainwindow) self.setupUi(self) self.error_dialog = QErrorMessage(self) self.found_ids = [] self.known_ids = {} self.known_id_path = None self.current_index = 0 self.count = 0 self.pmid_thread = QtCore.QThread(self) self.pmid_worker = RetrievePubmedData() self.pmid_worker.moveToThread(self.pmid_thread) self.pmid_thread.started.connect(self.pmid_worker.retrieve_data) self.pmid_worker.error.connect(self.error_dialog.showMessage) self.pmid_worker.finished.connect(self.pmid_thread.quit) self.pmid_worker.finished.connect(self.update_info_from_online) # Search parameters settings = Settings() self.email = settings.value("Email") self.tool = quote(settings.applicationName()) # Connect slots self.webView.loadProgress.connect(self.progressBar.setValue) # Adjust window settings self.setWindowFlags(QtCore.Qt.Window) #self.webView.page().setLinkDelegationPolicy(QWebEnginePage.DelegateExternalLinks) self.webView.setContentsMargins(0, 0, 0, 0) self.buttonPrevious.setVisible(False) self.buttonNext.setVisible(False) self.resultsBox.layout().setContentsMargins(9, 0, 9, 9) self.resultsBox.hide() self.adjustSize() self.load_knowns()
def get_database_path(): settings = Settings() return settings.value("DATABASE_PATH", DB_PATH)
class EditSettingsDialog(QDialog, Ui_EditSettingsDialog): def __init__(self, parent): QDialog.__init__(self, parent) self.setupUi(self) # Setup the email field with current value self.settings = Settings() self.eMailLineEdit.setText(self.settings.value("Email")) self.eMailLineEdit.setValidator( QRegExpValidator(QRegExp(r"[^@\s]+@[^@\s]+\.[^@\s.]+$"))) # Setup database path self.label_database_path.setText( self.settings.value("DATABASE_PATH", DB_PATH)) self.pushButton_change_path.clicked.connect(self.change_database_path) # Setup debug checkbox with current state if LOGGER.isEnabledFor(logging.DEBUG): self.debugModeCheckBox.setChecked(True) @pyqtSlot() def toggle_ok_button(self): """ Check that the current E-mail adresse is valid or empty in order to enable the OK button """ self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( self.eMailLineEdit.hasAcceptableInput() or not self.eMailLineEdit.text()) @pyqtSlot() def change_database_path(self): current_path = self.settings.value("DATABASE_PATH", DB_PATH) filename, filter = QFileDialog.getSaveFileName( self, self.tr("Change location"), current_path, self.tr("Database (*.db)")) if filename: self.label_database_path.setText(filename) @pyqtSlot() def save_settings(self): """ Save the currently entered E-mail """ # Set logger to debug mode if self.debugModeCheckBox.isChecked() and not LOGGER.isEnabledFor( logging.DEBUG): logging.disable(logging.NOTSET) LOGGER.info("DEBUG MODE ON") log_package_versions() # Switch debug mode off elif not self.debugModeCheckBox.isChecked() and LOGGER.isEnabledFor( logging.DEBUG): logging.disable(logging.DEBUG) LOGGER.info("DEBUG MODE OFF") # Save settings if self.settings.value("Email") != self.eMailLineEdit.text(): self.settings.setValue("Email", self.eMailLineEdit.text()) if self.settings.value( "DATABASE_PATH") != self.label_database_path.text(): self.settings.setValue("DATABASE_PATH", self.label_database_path.text()) self.settings.sync()