def installLanguageSupportForLocale(self, locale): locale = locale.partition("_")[0] if subprocess.call( ['gksu', "apt-get -q -y install language-pack-%s" % locale]) != 0: QMessageBox().critical(self.menuNotebook, "Installation Error", self.messages['installLocaleError'], buttons=QMessageBox.Ok, defaultButton=QMessageBox.Ok) else: QMessageBox().information(self.menuNotebook, "Success", self.messages['installLocaleSuccess'], buttons=QMessageBox.Ok, defaultButton=QMessageBox.Ok)
def exportar(self): usuario = self.lbl_user.text() cont = self.lbl_pwd.text() url = self.lbl_url.text() coment = self.lbl_comm.toPlainText() try: file_name = 'exportado' + datetime.datetime.now().strftime( '%H:%M:%S') + '.txt' file = open(file_name, 'w') file.write('Usuario: ' + usuario + '\n') file.write('Contraseña: ' + cont + '\n') file.write('Url o Plataforma: ' + url + '\n') file.write('Comentarios: ' + coment + '\n') file.close() dialog = QMessageBox() dialog.setIcon(QMessageBox.Information) dialog.setText('Exportado, archivo: ' + file_name) dialog.setStandardButtons(QMessageBox.Ok) dialog.setWindowTitle('Exportado') dialog.exec_() except IOError: print()
def run(self): target = self._run_widget.target_case() source = self._run_widget.source_case() ert = ERT.ert fs_manager = ert.getEnkfFsManager() es_update = ESUpdate(ert) target_fs = fs_manager.getFileSystem(target) source_fs = fs_manager.getFileSystem(source) run_context = ErtRunContext.ensemble_smoother_update( source_fs, target_fs, ) success = es_update.smootherUpdate(run_context) if not success: msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setWindowTitle("Run Analysis") msg.setText("Unable to run analysis for case '%s'." % source) msg.setStandardButtons(QMessageBox.Ok) msg.exec_() return ERT.ertChanged.emit() self._dialog.accept()
def refresh_project(self): if not self.finders['project'].activated: return if not self.settings.value("refreshAuto"): return n_days = self.settings.value("refreshDelay") # do not ask more ofen than 3 days ask_limit = min(3, n_days) recently_asked = self.settings.value("refreshLastAsked") >= n_days_ago_iso_date(ask_limit) if recently_asked: return thresh_date = n_days_ago_iso_date(n_days) uptodate = True for search in self.finders['project'].searches.values(): if search.dateEvaluated <= thresh_date: uptodate = False break if uptodate: return self.settings.setValue("refreshLastAsked", n_days_ago_iso_date(0)) ret = QMessageBox(QMessageBox.Warning, "Quick Finder", QCoreApplication.translate("Auto Refresh", "Some searches are outdated. Do you want to refresh them ?"), QMessageBox.Cancel | QMessageBox.Yes).exec_() if ret == QMessageBox.Yes: RefreshDialog(self.finders['project']).exec_()
def errorGUI(error): # Display error messsage warning = QMessageBox() warning.setIcon(QMessageBox.Critical) warning.setWindowTitle("Error!") warning.setText(error) warning.exec_()
def changeParameters(self): msg = QMessageBox() msg.setText("No Parameters") msg.setInformativeText("There are no parameters for " + self.name + " to change") msg.setStandardButtons(QMessageBox.Ok) retval = msg.exec_()
def wrapped(inst, *args, **kwargs): if not getattr(inst, 'connection', False): QMessageBox( QMessageBox.Warning, "Menu Builder", inst.tr( "Not connected to any database, please select one"), QMessageBox.Ok, inst).exec_() return if inst.connection.closed: QMessageBox( QMessageBox.Warning, "Menu Builder", inst.tr( "Not connected to any database, please select one"), QMessageBox.Ok, inst).exec_() return return func(inst, *args, **kwargs)
def generateAlert(self): self.alertBox = QMessageBox() self.alertBox.setText("If SelfRestraint has been helpful, please consider donating to the project so development can continue! =)") self.alertBox.donateButton = self.alertBox.addButton("Donate", 3) self.alertBox.donateButton.clicked.connect(self.openURL) self.alertBox.addButton("Not Now", 1) self.alertBox.show()
def connect_and_open(db_file_path, connection_name): """ Create a QSqlDatabase connection to the database and open it. :param db_file_path: String with database location :param connection_name: String with name of connection for Qt use :return db: QSqlDatabase object representing open database """ db = QSqlDatabase.addDatabase("QSPATIALITE", connection_name) db.setDatabaseName(db_file_path) # db.setConnectOptions("QSQLITE_BUSY_TIMEOUT") # Also a read only option could use to restrict concurrent access if not db.open(): db_not_open_msg_box = QMessageBox(QMessageBox.Warning, " ", "Database error: {}").format( db.lastError().text(), QMessageBox.Ok, None) db_not_open_msg_box.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint) db_not_open_msg_box.exec_() return if config.DEBUG_MODE: print('DEBUG_MODE: opening QSqlDatabase {}'.format( db.connectionName())) return db
def on_btnGen_clicked(self): import os self.cfg.gen(os.path.dirname(self.arxml)) QMessageBox( QMessageBox.Information, 'GaInOS Info', 'Gen C Code Successfully at <%s>!' % (os.path.dirname(self.arxml))).exec_()
def open_image(self, checked=False, path=None): if path is None: dlg = QFileDialog() dlg.setFileMode(QFileDialog.ExistingFile) dlg.setFilter("Image Files (*.NEF *.TIFF *.TIF)") filenames = [] if dlg.exec_(): filenames = dlg.selectedFiles() if len(filenames) >= 1: path = unicode(filenames[0]) else: #TODO: add messagebox return if os.path.isfile(path): filename = os.path.basename(path) if path not in self.current_images: im = cv2.imread(path, -1) widget = QImageWidget() visualization = im.copy() if visualization .shape[0] > self.screen_size.height(): visualization = self.image_resize(visualization , height=self.screen_size.height()-200) if visualization .shape[1] > self.screen_size.width(): visualization = self.image_resize(visualization , width=self.screen_size.width()-200) widget.set_opencv_image(visualization ) new_image = {"filename": filename, "path": path, "data":im, "widget": widget} self.create_image_tab(new_image) else: #TODO: Go to tab pass self.current_images.append(new_image) self.statusBar().showMessage("Opened file %s"%filename) else: mb = QMessageBox("ERROR in path", "Path to file \n%s\ncould not be found."%path, QMessageBox.Warning, QMessageBox.Ok, 0, 0) mb.exec_()
def confirm(title, msg, parent=None): box = QMessageBox(QMessageBox.Question, title, msg, QMessageBox.Yes | QMessageBox.No) #reply = QMessageBox.question(parent,title,msg,QMessageBox.Yes|QMessageBox.No) box.setButtonText(QMessageBox.Yes, u"Yes") box.setButtonText(QMessageBox.No, u"No") return (box.exec_() == QMessageBox.Yes)
def startThread(self): global thread try: if thread == "unactive": try: startStream() self.th = MyThread() self.th.changePixmap.connect(self.setImage) self.th.start() thread = "active" print('Starting Thread') except: print('Failed!!!!') exit(1) else: print('Already Started Camera') except: msgBox = QMessageBox() reply = msgBox.question( self, 'Message', "Error Starting Camera - Plug or Re-Plug Camera into Computer, Wait at Least 10 Seconds, then Click Ok and Try Again.", QMessageBox.Ok) print('Message Box Displayed') if reply == QMessageBox.Ok: print('Ok Clicked') else: event.ignore()
def onSaveButton(self): logger.info( "save object as?" ) if self.topLevelOperatorView.dataIsStorable(): prevName = "" if self.topLevelOperatorView.hasCurrentObject(): prevName = self.topLevelOperatorView.currentObjectName() if prevName == "<not saved yet>": prevName = "" name = self.saveAsDialog(name=prevName) if name is None: return objects = self.topLevelOperatorView.AllObjectNames[:].wait() if name in objects and name != prevName: QMessageBox.critical(self, "Save Object As", "An object with name '%s' already exists.\nPlease choose a different name." % name) return self.topLevelOperatorView.saveObjectAs(name) logger.info( "save object as %s" % name ) if prevName != name and prevName != "": self.topLevelOperatorView.deleteObject(prevName) else: msgBox = QMessageBox(self) msgBox.setText("The data does not seem fit to be stored.") msgBox.setWindowTitle("Problem with Data") msgBox.setIcon(2) msgBox.exec_() logger.error( "object not saved due to faulty data." )
def on_cmbxOSConfCls_currentIndexChanged(self, p0): """修改GaInOS 最高任务类型""" #从高到低的转变提示,并抉择 if (self.xGaInOSGeneralCfg.xOSConfCls == 'ECC1' or self.xGaInOSGeneralCfg.xOSConfCls == 'ECC2'): if (p0 == 'BCC1' or p0 == 'BCC2'): dlg = QMessageBox( QMessageBox.Question, 'GaInOS Warning', 'Do You Really Want To Rollback All Tasks To Basic Task!', QMessageBox.Yes | QMessageBox.No) if (dlg.exec_() == QMessageBox.Yes): self.vDoRollbackAllTaskToBasic() else: if (self.xGaInOSGeneralCfg.xOSConfCls == 'ECC1'): self.cmbxOSConfCls.setCurrentIndex(2) else: self.cmbxOSConfCls.setCurrentIndex(3) return #改变GaInOS最高任务类型 self.xGaInOSGeneralCfg.xOSConfCls = p0 if (p0 == 'ECC1' or p0 == 'ECC2'): self.cmbxTskType.setDisabled(False) if (self.cmbxAlarmType.count() == 2): self.cmbxAlarmType.addItem('ALARM_EVENT') elif (p0 == 'BCC1' or p0 == 'BCC2'): self.cmbxTskType.setDisabled(True) if (self.cmbxAlarmType.count() == 3): self.cmbxAlarmType.removeItem(2) try: self.vDoRefreshSpbxTskMaxActCnt(p0, self.pxCurSelGaInOsObj) except: print "Error."
def change_db_path(params, params_file): """ Open a dialogue to allow user to select new path, then run test query on file. In case of success, the xml file is updated and nothing is returned. :param params: Dictionary containing parameters, including old path :param params_file: ParamsFile object linked to xml file. :return bool: True if in db_path_dlg the OK button is pressed, False if cancel """ old_path = os.path.join(params['RNDataStorePath'], params['DbName']) db_path_selector = DbPathSelect(params, params_file) # executes the window on button clicked db_path_selector.db_path_dlg.exec_() # cancel clicked if db_path_selector.db_path_dlg.result() == QDialog.Rejected: return False # ok clicked if db_path_selector.db_path_dlg.result() == QDialog.Accepted: db_path = os.path.join(params['RNDataStorePath'], params['DbName']) check_file(db_path) if db_path != old_path: db_changed_msg_box = QMessageBox( QMessageBox.Information, " ", "Database location successfully updated.\n\n" "Changes will take effect when roadNet next " "starts.", QMessageBox.Ok, None) db_changed_msg_box.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint) db_changed_msg_box.exec_() return True
def ask_question(self, text, title=None, inf_text=None, context_name=None, parameter=None): """ Ask question to the user """ msg_box = QMessageBox() msg = self.tr(text, context_name) if parameter: msg += ": " + str(parameter) msg_box.setText(msg) if title: title = self.tr(title, context_name) msg_box.setWindowTitle(title) if inf_text: inf_text = self.tr(inf_text, context_name) msg_box.setInformativeText(inf_text) msg_box.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok) msg_box.setDefaultButton(QMessageBox.Ok) msg_box.setWindowFlags(Qt.WindowStaysOnTopHint) ret = msg_box.exec_() if ret == QMessageBox.Ok: return True elif ret == QMessageBox.Discard: return False
def check_lock_file(params): """ Checks for presence of RNLock in the data directory. :param params: Dictionary of parameters including data directory path :return bool: True/False """ lock_file_path = os.path.join(params['RNDataStorePath'], 'RNLock') if os.path.isfile(lock_file_path): # Database is locked by another user with open(lock_file_path, 'r') as infile: lock_username = infile.readline().split(":")[1].strip() message = ('Database locked for editing by {} with lock file at:\n\n' '{}\n\n' 'Opening as read only.'.format(lock_username, lock_file_path)) # Check for stray lock file. working_files = [ f for f in os.listdir(params['RNDataStorePath']) if f.endswith('_working.sqlite') ] if len(working_files) == 0: message = (message + '\n\nNo database currently being edited. ' 'Check for stray lock file.') lock_file_msg_box = QMessageBox(QMessageBox.Information, " ", message, QMessageBox.Ok, None) lock_file_msg_box.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint) lock_file_msg_box.exec_() return True else: return False
def compare_depth(self, widget_y, widget_node, show_message): widget_node = self.dialog.findChild(QLineEdit, widget_node) widget_y.setStyleSheet("border: 1px solid gray") node_id = utils_giswater.getWidgetText(self.dialog, widget_node) text = utils_giswater.getWidgetText(self.dialog, widget_y) if text is None: return if widget_node is None: return sql = ("SELECT ymax FROM " + self.schema_name + ".v_edit_node " "WHERE node_id='" + str(node_id) + "'") row = self.controller.get_row(sql, log_sql=True) if row: if row['ymax'] is not None: if float(row['ymax']) < float(text): widget_y.setStyleSheet("border: 1px solid red") if show_message: msg = "The depth of {} is less than the y{}".format( widget_node.objectName(), widget_node.objectName()[5:6]) # self.controller.show_info_box(text=msg, title="Info") msg_box = QMessageBox() msg_box.setIcon(3) msg_box.setWindowTitle("Warning") msg_box.setText(msg) msg_box.exec_()
def capture_image(self): """ Summary => starts the process to capture the picture. Description => starts the process to capture the picture from the video feed. This image will be saved to 'Image/takenPicture'. args => None return => None """ print("taken picture!!!!!") if self.ui.check_process.isChecked(): # sleep to let the program to update, before changing screen time.sleep(0.1) self.camera.stop_video_capture() # changed to the acceptance page, after picture has been taken self.display_stack(1) else: error = QMessageBox() error.setIcon(QMessageBox.Information) error.setText("Please confirm that we can process your picture") error.setWindowTitle("Confirmation") error.setStandardButtons(QMessageBox.Ok) error.exec_()
def _q_replace_db_data(self, tbl=None): schema = self.dock_widget.CBDataType.currentText() tables_in_db = self.DB.get_tables_in_db(schema=schema) if tbl is not None: tbl_name = tbl else: tbl_name = str(self.IH.file_name) tbls = [] for row in tables_in_db: tbls.append(str(row[0])) if tbl_name in tbls: qm = QMessageBox() ret = qm.question( None, 'Message', self. tr("The name of the data set already exist in your database, would you like to replace it?" ), qm.Yes, qm.No) if ret == qm.No: return False else: self.DB.execute_sql("DROP TABLE {schema}.{tbl}".format( schema=schema, tbl=tbl_name)) return True else: return True
def infoBox(title, message): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText(message) msg.setWindowTitle(title) msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def makeTiff(self): global lastFrame print('Collecting Data Frames...') for i in range(1,lastFrame): #print('Frame to Tiff: ' + str(i)) data = self.f_read[('image'+str(i))][:] if i == 1: dataCollection = data else: dataCollection = np.dstack((dataCollection,data)) i += 1 if i == lastFrame/2: print('Half Way Through File...') print('Completed Save') filename = ("Lepton TIFF Vid " + QDateTime.currentDateTime().toString()) filename2 = filename.replace(" ", "_") filename3 = str(filename2.replace(":", "-")) print('File Name: ' + filename3) imsave((filename3 + '.tiff'), dataCollection) print('File Saved to .py or .exe directory') msgBox = QMessageBox() reply = msgBox.question(self, 'Message', (filename3 + " save to .py or .exe directory"), QMessageBox.Ok) print('Message Box Displayed') if reply == QMessageBox.Ok: print('Ok Clicked') else: event.ignore()
def criticalBox(title, message): msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setText(message) msg.setWindowTitle(title) msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def successGUI(): """Display succesfully downloaded file messsage""" success = QMessageBox() success.setIcon(QMessageBox.Information) success.setWindowTitle("Success!") success.setText("File Downloaded") success.exec_()
def toggleInteractive(self, checked): logger.debug("toggling interactive mode to '%r'" % checked) if checked == True: if not self.topLevelOperatorView.FeatureImages.ready() \ or self.topLevelOperatorView.FeatureImages.meta.shape==None: self.labelingDrawerUi.liveUpdateButton.setChecked(False) mexBox = QMessageBox() mexBox.setText("There are no features selected ") mexBox.exec_() return # If we're changing modes, enable/disable our controls and other applets accordingly if self.interactiveModeActive != checked: if checked: self.labelingDrawerUi.labelListView.allowDelete = False self.labelingDrawerUi.AddLabelButton.setEnabled(False) else: self.labelingDrawerUi.labelListView.allowDelete = True self.labelingDrawerUi.AddLabelButton.setEnabled(True) self.interactiveModeActive = checked self.topLevelOperatorView.FreezePredictions.setValue(not checked) self.labelingDrawerUi.liveUpdateButton.setChecked(checked) # Auto-set the "show predictions" state according to what the user just clicked. if checked: self._viewerControlUi.checkShowPredictions.setChecked(True) self.handleShowPredictionsClicked() # Notify the workflow that some applets may have changed state now. # (For example, the downstream pixel classification applet can # be used now that there are features selected) self.parentApplet.appletStateUpdateRequested.emit()
def cancel(self): if self.xmodem and self.xmodem.isRunning(): QMessageBox(self).warning(self, "Warning", "\nXmodem is running\n", QMessageBox.Ok) return self.reject()
def _handle_no_selection(self, move_icon): if self.selected_env == None: q = QMessageBox(QMessageBox.Warning, "Warning", "Element could not be added. No environment selected.") q.exec(); move_icon.setParent(None); return False
def accept(self): if not self.current_customer[0]: msgBox = QMessageBox() msgBox.setWindowTitle(u'操作提示') msgBox.setText(u'未找到要操作的记录!') msgBox.setStandardButtons(QMessageBox.Yes) msgBox.exec_() self.dlg.hide() elif self.dateEdit.date() == QtCore.QDate.currentDate(): sqldb = mydb() sqldb.update_cust_plan(self.current_customer) self.dlg.hide() elif self.dateEdit.date() > QtCore.QDate.currentDate(): msgBox = QtGui.QMessageBox() msgBox.setWindowTitle(u'操作提示') msgBox.setText(u'是否要添加提示计划?') msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msgBox.setDefaultButton(QMessageBox.Yes) ret = msgBox.exec_() if ret == QMessageBox.Yes: sqldb = mydb() sqldb.update_cust_plan(self.current_customer) sqldb.insert_cust_plan([ self.current_customer[0], unicode(self.dateEdit.date().toString("yyyy/MM/dd")) ]) self.dlg.hide()
def remove_theme_callback(self): '''remove selected theme''' theme_name = str(self.comboBox.currentText()) msb = QMessageBox() msb.setIcon(QMessageBox.Critical) msb.setWindowTitle("Message") if theme_name in ("Current theme", "Default theme"): msb.setStandardButtons(QMessageBox.Ok) msb.setText("'{}' cannot be deleted.".format(theme_name)) msb.exec_() else: msb.setText( "Are you sure you want to delete '{}'?".format(theme_name)) msb.setIcon(QMessageBox.Warning) msb.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok) if msb.exec_() == QMessageBox.Ok: index = self.themeList.index(self.curent_theme_name) self.comboBox.setCurrentIndex(index) CHOSEN_THEME = DealXML.get_child_by_name( self.SETTINGS, "THEME", theme_name) self.SETTINGS.remove(CHOSEN_THEME) ET.ElementTree(self.SETTINGS).write(self.prefFileName) index = self.themeList.index(theme_name) self.comboBox.removeItem(index) self.themeList.remove(theme_name)