def add(self): designation = self.designation.text() da = self.da.text() hra = self.hra.text() ta = self.ta.text() it = self.it.text() pt = self.pt.text() if "" in [designation, da, hra, ta, it, pt]: msg = QMessageBox(QMessageBox.Information, "Error", "Please enter all the information!", parent=self) msg.exec_() else: print designation, float(da), float(hra), float(ta), float( it), float(pt) try: DatabaseManager.db.addDesignation(designation, float(da), float(hra), float(ta), float(it), float(pt)) msg = QMessageBox(QMessageBox.NoIcon, "Success", "Designation added successfully", parent=self) msg.exec_() self.goBack() except Exception as e: msg = QMessageBox(QMessageBox.Critical, "Error", str(e), parent=self) msg.exec_()
def onSearch(self): try: limit = int(self.tleLimit.text().strip()) except ValueError: msgBox = QMessageBox() msgBox.setWindowTitle('Invalid upper limit') msgBox.setText('Please enter a valid upper limit') msgBox.setIcon(QMessageBox.Warning) msgBox.exec_() return if limit < self.LOWER_LIMIT: msgBox = QMessageBox() msgBox.setWindowTitle('Invalid upper limit') msgBox.setText('Please enter a valid upper limit') msgBox.setIcon(QMessageBox.Warning) msgBox.exec_() return if self.rbAKS.isChecked(): algorithm = aks elif self.rbMR.isChecked(): algorithm = millerRabbin self.search(algorithm, limit - 1)
def error(self, error): if error == QNetworkSession.UnknownSessionError: msgBox = QMessageBox(self.parent()) msgBox.setText('This application requires network access to function.') msgBox.setInformativeText('Press Cancel to quit the application.') msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Cancel) msgBox.setIcon(QMessageBox.Information) msgBox.setDefaultButton(QMessageBox.Retry) ret = msgBox.exec_() if ret == QMessageBox.Retry: QTimer.singleShot(0, self.session.open) elif ret == QMessageBox.Cancel: self.close() elif error == QNetworkSession.SessionAbortedError: msgBox = QMessageBox(self.parent()) msgBox.setText('Out of range of network') msgBox.setInformativeText('Move back into range and press Retry, or press Cancel to quit the application') msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Cancel) msgBox.setIcon(QMessageBox.Information) msgBox.setDefaultButton(QMessageBox.Retry) ret = msgBox.exec_() if ret == QMessageBox.Retry: QTimer.singleShot(0, self.session.open) elif ret == QMessageBox.Cancel: self.close()
def save(self): valid = True if len(self.id.currentText()) == 0: QMessageBox(QMessageBox.Information, "Error", "Please select name and ID!", parent=self).exec_() valid = False else: for i in range(len(self.inputs)): if not self.inputs[i].isValid(): valid = False QtGui.QMessageBox(QtGui.QMessageBox.Information, "Error", self.inputs[i].getErrorMessage(), parent=self).exec_() break if valid: emp = Employee(self.id.currentText(), self.nameEdit.text(), self.designation.currentText(), self.originalPay.text(), self.originalPayGrade.text(), self.DOJ.getDate(), self.pan.text()) try: Database.getdb().editEmployee(emp) except mysql.connector.Error as e: ShowMysqlError(e, self) return QMessageBox(QMessageBox.NoIcon, "Success", "Employee edited successfully", parent=self).exec_()
def add(self): """This method is automatically called on clicking 'Add Designation' button This first checks if all inputs are valid. If any of the inputs are invalid, error message is shown for the first invalid input, else a new Designation object is created from available info. This Employee object is then passed to addEmployee() function of DatabaseManager which adds a new designation record in the database. """ valid = True for i in range(len(self.inputs)): if not self.inputs[i].isValid(): QMessageBox(QMessageBox.Information, "Error", self.inputs[i].getErrorMessage(), parent=self).exec_() valid = False break if valid: desg = Designation(self.designation.text(), self.da.text(), self.hra.text(), self.ta.text(), self.it.text(), self.pt.text()) try: Database.getdb().addDesignation(desg) QMessageBox(QMessageBox.NoIcon, "Success", "Designation added successfully", parent=self).exec_() self.goBack() except mysql.connector.Error as e: ShowMysqlError(e, self)
def add_menu(self): """ adds the new menu item :return:none """ logger.info('MenuAddDialogue add new menu initiated') name = self.dialogue.menudialogue_itemname_linedit.text() rate = self.dialogue.menudialogue_rate_lineedit.text() id = self.id if self.id else self.dialogue.menudialogue_codenumber_linedit.text() category = self.dialogue.menudialogue_itemcategory_combobox.currentText() serve = self.dialogue.menudialogue_serve_lineedit.text() obj = {'name': name, 'rate': rate, 'id': id, 'category': category, 'serve': serve} for i, j in obj.iteritems(): if j == '': QMessageBox.critical(QMessageBox(), 'Error', 'Invalid %s value' % i.title(), QMessageBox.Ok) return False if self.editable: ret = self.menuproduct.update_dish(obj) else: ret = self.menuproduct.new_dish(obj) if not ret: QMessageBox.critical(QMessageBox(), 'Error', 'Duplicate Entry', QMessageBox.Ok) return False else: QMessageBox.information(QMessageBox(), 'Success', 'Dish Saved', QMessageBox.Ok) self.edit_mode(id, False) self.parent.update_menu()
def main(): app = QApplication(sys.argv) # check if the target in supported try: platform = sys.argv[1] PLATFORMS[platform.replace('.', '_')]() except KeyError: warn_box = QMessageBox() warn_box.setIcon(QMessageBox.Information) warn_box.setText("Unknown platform: {}".format(platform)) warn_box.exec_() return 1 except IndexError: print("You must specify the target in the command line") except NotImplementedError as exc: install_it, = exc.args if query_user(platform): install_it() else: warn_box = QMessageBox() warn_box.setIcon(QMessageBox.Information) warn_box.setText( "You can install the platform later by typing:\n" + str(install_it.__doc__)) warn_box.exec_() else: print("Platform {} is installed".format(platform)) sys.exit(0)
def finished_start(self): self.save_settings() self.start_button.setText("Start") self.setEnabled(True) self.setStatusTip("Ready") if self.working_thread.mbox: data = self.working_thread.mbox mbox = QMessageBox(self) mbox.setWindowTitle(data[0]) mbox.setIcon(data[1]) mbox.setWindowIcon(data[2]) mbox.setText(data[3]) if data[4]: mbox.setDetailedText(data[4]) mbox.exec() # TODO: NEED TO FIX! if self.working_thread.updates: d = TableDialog(self.working_thread.updates, self.working_thread.streetdb) d.exec() else: mbox = QMessageBox(self) mbox.setWindowTitle("Done!") if self.working_thread.updates: mbox.setText("Program is done! {} updated!" .format(len(self.working_thread.updates))) else: mbox.setText("Program is done! Everything was up to date!") mbox.setIcon(QMessageBox.Information) mbox.exec()
def check_editor_preferences(): # get preference values of external app path photo_dir = cmds.optionVar(exists='PhotoshopDir') image_dir = cmds.optionVar(exists='EditImageDir') # if there is no external app, request for an app path if not photo_dir and not image_dir: pref_warn = QMessageBox() pref_warn.setWindowTitle(WINDOW_TITLE) pref_warn.setIcon(QMessageBox.Warning) pref_warn.setText( '<b>Applications for Editing Image Files</b> ' 'is not set in your preferences.<br>' 'Maya needs it to send image in the right Image Editor ' 'instead of file system association.') pref_warn.setInformativeText('Do you want to select an application ?') pref_warn.setStandardButtons(QMessageBox.Yes | QMessageBox.No) pref_warn.setDefaultButton(QMessageBox.Yes) pref_warn.setEscapeButton(QMessageBox.Cancel) ret = pref_warn.exec_() if ret == QMessageBox.Yes: app_path = cmds.fileDialog2( fileFilter='Image editor application (*.exe)', caption='Select image editor application', startingDirectory=os.path.expandvars('%ProgramFiles%'), fileMode=1) if app_path is not None: cmds.optionVar(sv=('PhotoshopDir', app_path[0])) cmds.optionVar(sv=('EditImageDir', app_path[0]))
def editingFinishedHandler(self): settings = QSettings() old = settings.value("computation/reduce",QtReduceDefaults.REDUCE) new = self.reduceBinary.text() if old == new: return self.reduceBinary.blockSignals(True) tit = "Change Binary?" txt = self.tr("Do you really want to change this setting?") itxt = self.tr("If yes, then the binary ") itxt += '"' + new + '" ' itxt += self.tr("will be used at the next restart.") mbox = QMessageBox(self) mbox.setIcon(QMessageBox.Question) mbox.setWindowModality(Qt.WindowModal) mbox.setWindowTitle(tit) mbox.setText(txt) mbox.setInformativeText(itxt) mbox.setStandardButtons(QMessageBox.Yes|QMessageBox.No) button = mbox.exec_() if button == QMessageBox.Yes: settings.setValue("computation/reduce",new) else: self.reduceBinary.setText(old) self.reduceBinary.blockSignals(False)
def __init__(self, emoji=None): """ This class allows you to add() video files and convert them to gifs. Output files are going to be in the same folder as the input files. """ super(Handbrake, self).__init__() self.tp = TasksPool() self.tp.return_signal.connect(lambda x: self.return_signal.emit(x)) # If we supply Emoji object, then if isinstance(emoji, Emoji): video_file = abspath(join(emoji.folder, emoji.name + Config()()['name_delimiter'] + emoji.version + '.mov')) if not exists(video_file): video_file = abspath(join(emoji.folder, emoji.name + '-' + emoji.version + '.mov')) if exists(video_file): self.add(video_file) self.run() else: error_msg = 'Failed to locate {}, based on {}.'.format(video_file, emoji.name_no_ext) self.return_signal.emit(__name__ + error_msg) logger.warning(error_msg) error_box = QMessageBox() error_box.setStyleSheet(stylesheet.houdini) error_box.setWindowTitle('Handbrake mov to mp4 conversion: File error') error_box.setText(error_msg) error_box.exec_() elif isinstance(emoji, str): video_file = emoji if exists(video_file): self.add(video_file) self.run()
def help_gpus(self): msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("Setting the number of GPUs") msg.setWindowTitle("Number of GPUs") if not self.HAVE_CUDA: info = "No GPUs are detected on your system" else: gpu_id = 0 is_available = True while is_available: try: cmt.cuda_set_device(gpu_id) is_available = True except Exception: is_available = False info = "%d GPU is detected on your system" % (gpu_id + 1) msg.setInformativeText("SpyKING CIRCUS can use several GPUs\n" "either locally or on multiple machine\n" "using MPI (see documentation)" "\n" "\n" "%s" % info) msg.setStandardButtons(QMessageBox.Close) msg.setDefaultButton(QMessageBox.Close) answer = msg.exec_()
def change_auth(self): if self.app.provider.is_authenticated(): msgBox = QMessageBox( QMessageBox.Critical, self.tr("You are trying to remove authorisation"), self.tr(""" Are you sure want to remove authoristion? It remove all not synced changes! """.strip()), QMessageBox.Yes | QMessageBox.No ) ret = msgBox.exec_() if ret == QMessageBox.Yes: self.app.provider.remove_authentication() self.update_tabs() else: self.ui.tabWidget.hide() self.ui.webView.show() consumer = oauth.Consumer(CONSUMER_KEY, CONSUMER_SECRET) client = oauth.Client(consumer, proxy_info=get_oauth_proxy('https')) resp, content = client.request( 'https://%s/oauth?oauth_callback=' % HOST + urllib.quote('http://everpad/'), 'GET') data = dict(urlparse.parse_qsl(content)) url = 'http://%s/OAuth.action?oauth_token=' % HOST + urllib.quote(data['oauth_token']) page = AuthPage( data['oauth_token'], data['oauth_token_secret'], self, ) self.ui.webView.setPage(page) page.mainFrame().load(url)
def error_message(text): errorbox = QMessageBox() errorbox.setWindowIcon(QPixmap("../icons/desuratools_256.png")) errorbox.setWindowTitle("Error") errorbox.setText(text) errorbox.setIcon(QMessageBox.Critical) return errorbox
def getMsgBox(self, text, nRoom): msgBox = QMessageBox() msgBox.setWindowTitle("Room: " + str(nRoom)) msgBox.setText(text) msgBox.addButton(QMessageBox.Ok) msgBox.show() msgBox.exec_()
def start(self): incomplete = [] if self.google_radio.isChecked(): if not self.username.text(): incomplete.append(self.username) if not self.password.text(): incomplete.append(self.password) if not self.document_id.text(): incomplete.append(self.document_id) elif not self.csv_file.text(): incomplete.append(self.csv_file) if not self.dbf_file.text(): incomplete.append(self.dbf_file) if len(incomplete) > 0: mbox = QMessageBox(self) mbox.setWindowTitle("Warning, incomplete fields!") mbox.setIcon(QMessageBox.Warning) mbox.setWindowIcon(QIcon.fromTheme("dialog-warning")) mbox.setText("%d fields are incomplete" % len(incomplete)) mbox.exec() for field in self.changed_styles: field.setStyleSheet("") for field in incomplete: field.setStyleSheet("border: 1.5px solid red; border-radius: 5px") self.changed_styles = incomplete.copy() return for field in self.changed_styles: field.setStyleSheet("") self.setStatusTip("Working...") self.working_thread = WorkThread(self) self.working_thread.finished.connect(self.finished_start) self.working_thread.start()
def on_delete_cb(self, feature, subelements): """Respond to delete object event (callback).""" delete = True if self.fpo.Group: # Project is not empty title = translate("Render", "Warning: Deleting Non-Empty Project") msg = translate( "Render", "Project is not empty. " "All its contents will be deleted too.\n\n" "Are you sure you want to continue?", ) box = QMessageBox( QMessageBox.Warning, title, msg, QMessageBox.Yes | QMessageBox.No, ) usr_confirm = box.exec() if usr_confirm == QMessageBox.Yes: subobjs = self.fpo.Proxy.all_views(include_groups=True)[1:] for obj in subobjs: obj.Document.removeObject(obj.Name) else: delete = False return delete
def loginfunction(self): usernamestatus = False usernameindex = -1 passwordstatus = False passwordindex = -1 for currentusername in range(len(self.usernamelist)): if self.passwordlist[currentusername] == self.username.text(): usernamestatus = True usernameindex = self.usernamelist.index(self.passwordlist[currentusername]) for currentpassword in range(len(self.passwordlist)): if self.usernamelist[currentpassword] ==self.password.text(): passwordstatus = True passwordindex = self.passwordlist.index(self.usernamelist[currentpassword]) if usernamestatus == True and passwordstatus ==True and usernameindex == passwordindex: self.hide() w2 = chooseoption.Form1(self) w2.show() else: self.msgBox = QMessageBox() self.msgBox.setText("Bloody Hacker!!!") self.msgBox.exec_()
def confirmationBox(text,info_text,object_name="confirmationBox"): """ Show a confirmation box to the user. :param text: Summary of the confirmation. :param info_text: Detailed message explaining what to confirm :param object_name: Name for Qt's object. :return: True if the user confirmed. False else. """ box = QMessageBox() box.setObjectName(object_name) box.setWindowTitle(_("Please confirm")) box.setIcon(QMessageBox.Question) _setBoxTexts(box,text,info_text) box.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel); # box.show() # from PySide.QtTest import QTest # from PySide.QtGui import QApplication # QTest.qWaitForWindowShown(box) # QApplication.instance().removePostedEvents() r = box.exec_() == QMessageBox.Ok box.deleteLater() return r
def save(self): mainlog.debug("EditTimeTracksDialog.save()") errors = self.controller.model.validate() if errors: showTableEntryErrorBox(errors) return False tt_start_time = datetime(self.edit_date.year, self.edit_date.month, self.edit_date.day, 6, 0, 0) edited_proxy_tts = self.controller.model.model_to_objects( lambda: TimetrackProxy()) employee_id = self.current_employee_id_selected # for tt in edited_proxy_tts: # mainlog.debug(type(tt)) # mainlog.debug(str(tt)) try: save_proxy_timetracks(edited_proxy_tts, tt_start_time, employee_id) return True except Exception as e: msgBox = QMessageBox(self) msgBox.setIcon(QMessageBox.Critical) msgBox.setText("There was an error while saving your data") msgBox.setInformativeText(str(e)) msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.setDefaultButton(QMessageBox.Ok); ret = msgBox.exec_() return False
def showContextMenu(self, pos): """ Shows a context menu to add a node in the graph widget """ gpos = self.graphicsView.mapToGlobal(pos) menu = QMenu() actionAddNode = menu.addAction("Add Node") QAction = menu.exec_(gpos) if (actionAddNode == QAction): (text, ok) = QInputDialog.getText(self.graphicsView, "Insert Node Name", "Please insert a name for the node") if ok: if text not in self.nodesToQNodes: #User clicked on ok. Otherwise do nothing self.gv.add_node(text) node = self.gv.get_node(text) qnode = self.createQtNode(node, 0, 0, QColor(204, 255, 255)) self.graphicsView.scene().addItem(qnode) qnode.setPos(self.graphicsView.mapToScene(gpos)) qnode.setPos(qnode.x(), qnode.y() - 200) self.nodesToQNodes[node] = qnode else: msg = QMessageBox() msg.setText("The node already exists.") msg.exec_() self.searchNode(text)
def verify_user(self, profileid=None): if profileid is None: profileid = self.current_profileid if len(profileid) == 0: return False try: username = gameslist.username_from_profile_id(profileid) except gameslist.NoSuchProfileError: return False if windows.desura_running(username): return True verify_dialog = QMessageBox() verify_dialog.setText( "<b>Verify your identity</b><br />Sign in to Desura to continue with account <b>{0}</b> to confirm your identity" .format(username)) verify_dialog.setInformativeText( "<i>Waiting for Desura sign-in...</i>") verify_dialog.setWindowTitle("Sign into Desura to continue") verify_dialog.setStandardButtons(QMessageBox.Cancel) verify_dialog.setIcon(QMessageBox.Information) verify_dialog.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint) desurawaiter = DesuraWaiter(username) desurawaiter.finished.connect(verify_dialog.close) desurawaiter.start() verify_dialog.exec_() if windows.desura_running(username): return True else: desurawaiter.terminate() return False
def mainbutton_clicked(self, button): if button == self.main_reset: for cat in self.base_cfg.get_categories(): for setting in self.base_cfg.get_settings(cat): self.widget_list[cat][setting].updateValue(self.base_cfg.get_setting(cat,setting)) elif button == self.main_defaults: for cat in self.def_cfg.get_categories(): for setting in self.def_cfg.get_settings(cat): self.widget_list[cat][setting].updateValue(self.def_cfg.get_setting(cat,setting)) elif button == self.main_apply: bad_settings = self.validate_settings() if bad_settings == []: self.save_settings() self.main_apply.setEnabled(False) self.main_reset.setEnabled(False) else: msgBox = QMessageBox() msgBox.setText("Must fix the following invalid settings before quitting:") msgBox.setStandardButtons(QMessageBox.Ok) info = '' for setting in bad_settings: new = '%s,%s<br>' % setting info = '%s%s' % (info, new) msgBox.setInformativeText(info) msgBox.exec_()
def cmdElimina_click(self): """Evento che gestisce il tasto di elimina""" msgBox = QMessageBox() if self.myWidget.lstRubrica.currentIndex(): index = self.myWidget.lstRubrica.currentIndex().row() rec = self.tableModel.record(index) nome = rec.value("nome") cognome = rec.value("cognome") msgBox.setText("Si conferma l'eliminazione del contatto %s %s?" % (nome, cognome)) msgBox.setInformativeText( "Se si procede con l'eliminazione il contatto verrĂ eliminato definitivamente." ) msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) ret = msgBox.exec_() if (ret == QMessageBox.Ok): self.tableModel.removeRow(index) self.tableModel.submitAll() else: msgBox.setText("Occorre selezionare un elemento!") msgBox.exec_()
def askWhichAction(self): """ Ask the user what to do if no chunk worked: - Try again - Re-test the current last working chunk - Cancel :return: An integer value indicating the pressed button: - 0 if the user wants to try again - 1 if the user wants to re-test - 2 if the user wants to cancel """ messageBox = QMessageBox() messageBox.setWindowTitle(Strings.searcherTabAskActionMessageBoxTitle) messageBox.setText(Strings.searcherTabAskActionMessageBoxText) tryAgainButton = messageBox.addButton( Strings.searcherTabAskActionMessageBoxButtonTryAgainText, QMessageBox.RejectRole) reTestButton = messageBox.addButton( Strings.searcherTabAskActionMessageBoxButtonReTestText, QMessageBox.NoRole) cancelButton = messageBox.addButton( Strings.searcherTabAskActionMessageBoxButtonCancelText, QMessageBox.YesRole) messageBox.exec_() if messageBox.clickedButton() == tryAgainButton: return 0 elif messageBox.clickedButton() == reTestButton: return 1 elif messageBox.clickedButton() == cancelButton: return 2
def change_auth(self): # If we already are authenticated, this click sets up to # remove authentication --- if self.app.provider.is_authenticated(): print "everpad remove" # You really want to do this???? LOL # MKG - want to move to provider msgBox = QMessageBox( QMessageBox.Critical, self.tr("You are trying to remove authorisation"), self.tr(""" Are you sure want to remove authoristion? It remove all not synced changes! """.strip()), QMessageBox.Yes | QMessageBox.No) ret = msgBox.exec_() # if ret == QMessageBox.Yes: # daemon.py self.app.provider.remove_authentication() self.update_tabs() # If not athenticated then authenticate --- else: #self.ui.tabWidget.hide() #self.ui.webView.show() self.app.provider.authenticate() #self.ui.webView.hide() self.ui.tabWidget.show() self.update_tabs()
def makeInformationBox(text,info_text = None): warningBox = QMessageBox() warningBox.setWindowTitle(_("Information")) warningBox.setIcon(QMessageBox.Information) warningBox.setText(text); warningBox.setInformativeText(info_text) warningBox.setStandardButtons(QMessageBox.Ok); return warningBox
def showdialog(x, y): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText(x) msg.setInformativeText(y) msg.setWindowTitle("Alert") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) return msg.exec_()
def check_if_folder_exists(self): if not os.path.isdir(self.save_folder_editline.text()): msgBox = QMessageBox(icon=QMessageBox.Warning, text=ERROR_NO_DIR_MESSAGE) msgBox.setWindowTitle(ERROR_NO_DIR_TITLE) msgBox.exec_() self.save_folder_editline.setText(self.parent.default_save_folder)
def yesNoBox(text,info_text,object_name="confirmationBox"): warningBox = QMessageBox() warningBox.setObjectName(object_name) warningBox.setWindowTitle(_("Please confirm")) warningBox.setIcon(QMessageBox.Question) _setBoxTexts(warningBox,text,info_text) warningBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel); return warningBox.exec_()