def dataError(): msg = QMessageBox() # msg.setIcon(QMessageBox.icon()) msg.setText("Date-time Error") msg.setInformativeText('Начальная дата обработки данных больше конечной') msg.setWindowTitle("Error") msg.exec()
def about(self): QMessageBox.about( self, '关于', f''' <h2>FGO全自动脚本</h2> <table border="0"> <tr> <td>当前版本</td> <td>{fgoFunc.__version__}</td> </tr> <tr> <td>作者</td> <td>hgjazhgj</td> </tr> <tr> <td>项目地址</td> <td><a href="https://github.com/hgjazhgj/FGO-py">https://github.com/hgjazhgj/FGO-py</a></td> </tr> <tr> <td>电子邮箱</td> <td><a href="mailto:[email protected]">[email protected]</a></td> </tr> </table> <!-- 都看到这里了真的不考虑给点钱吗... --> 这是我的支付宝收款码,请给我打钱,一分钱也行<br/> <img src="data:image/bmp;base64,Qk2yAAAAAAAAAD4AAAAoAAAAHQAAAB0AAAABAAEAAAAAAHQAAAB0EgAAdBIAAAAAAAAAAAAA6KAAAP///wABYWKofU/CKEV/Zt BFXEMwRbiQUH2a5yABj+Uo/zf3AKDtsBjeNa7YcUYb2MrQ04jEa/Ioh7TO6BR150Djjo3ATKgPmGLjdfDleznImz0gcA19mxD/rx/4AVVUAH2zpfBFCgUQRSgtEEVjdRB9 /R3wATtkAA==" height="290" width="290"/><br/> 这是我的微信收款码,请给我打钱,一分钱也行<br/> <img src="data:;base64,Qk2yAAAAAAAAAD4AAAAoAAAAHQAAAB0AAAABAAEAAAAAAHQAAAB0EgAAdBIAAAAAAAAAAAAAOKsiAP///wABNLhYfVLBqEUYG0 hFcn7gRS8QAH2Pd2ABQiVY/x1nMFWzcFhidNUwaXr3GEp1khDJzDfAuqx06ChC9hhPvmIQMJX3SCZ13ehlXB9IVtJQUAQreqj/jv/4AVVUAH0iFfBFuxUQRRAlEEX2fRB9 Wl3wAdBsAA" height="290" width="290"/> ''')
def initialize(self, check_if_trusted: bool = False) -> None: super().initialize() preferences = Application.getInstance().getPreferences() if check_if_trusted: # Need to do this before the preferences are read for the first time, but after obj-creation, which is here. preferences.indicateUntrustedPreference("general", "theme", lambda value: self._isPathSecure(Resources.getPath(Resources.Themes, value))) preferences.indicateUntrustedPreference("backend", "location", lambda value: self._isPathSecure(os.path.abspath(value))) preferences.addPreference("view/force_empty_shader_cache", False) preferences.addPreference("view/opengl_version_detect", OpenGLContext.OpenGlVersionDetect.Autodetect) # Read preferences here (upgrade won't work) to get: # - The language in use, so the splash window can be shown in the correct language. # - The OpenGL 'force' parameters. try: self.readPreferencesFromConfiguration() except FileNotFoundError: Logger.log("i", "Preferences file not found, ignore and use default language '%s'", self._default_language) # Initialize the package manager to remove and install scheduled packages. self._package_manager = self._package_manager_class(self, parent = self) # If a plugin is removed, check if the matching package is also removed. self._plugin_registry.pluginRemoved.connect(lambda plugin_id: self._package_manager.removePackage(plugin_id)) self._mesh_file_handler = MeshFileHandler(self) #type: MeshFileHandler self._workspace_file_handler = WorkspaceFileHandler(self) #type: WorkspaceFileHandler if preferences.getValue("view/force_empty_shader_cache"): self.setAttribute(Qt.ApplicationAttribute.AA_DisableShaderDiskCache) if preferences.getValue("view/opengl_version_detect") != OpenGLContext.OpenGlVersionDetect.ForceModern: major_version, minor_version, profile = OpenGLContext.detectBestOpenGLVersion( preferences.getValue("view/opengl_version_detect") == OpenGLContext.OpenGlVersionDetect.ForceLegacy) else: Logger.info("Force 'modern' OpenGL (4.1 core) -- overrides 'force legacy opengl' preference.") major_version, minor_version, profile = (4, 1, QSurfaceFormat.OpenGLContextProfile.CoreProfile) if major_version is None or minor_version is None or profile is None: Logger.log("e", "Startup failed because OpenGL version probing has failed: tried to create a 2.0 and 4.1 context. Exiting") if not self.getIsHeadLess(): QMessageBox.critical(None, "Failed to probe OpenGL", "Could not probe OpenGL. This program requires OpenGL 2.0 or higher. Please check your video card drivers.") sys.exit(1) else: opengl_version_str = OpenGLContext.versionAsText(major_version, minor_version, profile) Logger.log("d", "Detected most suitable OpenGL context version: %s", opengl_version_str) if not self.getIsHeadLess(): OpenGLContext.setDefaultFormat(major_version, minor_version, profile = profile) self._qml_import_paths.append(os.path.join(os.path.dirname(sys.executable), "qml")) self._qml_import_paths.append(os.path.join(self.getInstallPrefix(), "Resources", "qml")) Logger.log("i", "Initializing job queue ...") self._job_queue = JobQueue() self._job_queue.jobFinished.connect(self._onJobFinished) Logger.log("i", "Initializing version upgrade manager ...") self._version_upgrade_manager = VersionUpgradeManager(self)
def show_trial_over_and_die(self): QMessageBox.information( self, "Trial Over", "Your trial period is over. Please purchase Blobbackup to continue using it.", ) self.logger.info("Trial over displayed.") webbrowser.open(PAYMENT_URL) sys.exit()
def deleteRowFromTable(self): """Using the view's selection model, find out which row is selected and remove it.""" if self.selectionModel().hasSelection(): index = self.selectionModel().currentIndex() self.model.removeRow(index.row(), index) else: QMessageBox.information(self, "No Row Selected", "No row selected for deletion.")
def download_button_click(self): flag = False for check_box in self.check_box_list: if check_box.isChecked(): constant.SERVICE.parse_image(self.comic_info, check_box.property("chapter_info"), self.load_download_task_signa.emit) if not flag: QMessageBox.information(self, "下载通知", "正在解析选中章节", QMessageBox.StandardButton.Yes) flag = True
def mostrar_acerca_de(self): mensaje = QMessageBox() mensaje.setWindowTitle('Acerca de') mensaje.setIcon(QMessageBox.Icon.Information) mensaje.setText( 'A cerca de Mi Aplicación.\n\nAplicacion PyQt6.\nDesarrollador: Mauricio Posada.\nVersion 1.0.0\n2021.' ) mensaje.exec()
def wrapper(self, *args, **kwargs): try: return func(self, *args, **kwargs) except Exception as e: if isinstance(e, serial.serialutil.SerialException): self.disable_widgets() self.clear_servo() self.port_refresh_button_clicked(None) QMessageBox.critical(None, "Error", "Disconnected from device") else: QMessageBox.information(None, "Error", str(e))
def accept(self, success, message): self.set_elements_enabled(True) self.loading_dialog.hide() if not success: QMessageBox.warning(self, "Change Password Failed", message) self.logger.info("Change password failed displayed") return self.logger.info("Changed password") QMessageBox.information(self, "Password Changed", "Password successfully changed.") super().accept()
def accept(self, success): self.setWindowTitle(self.title) if self.reauth: self.loading_dialog.hide() self.set_elements_enabled(True) if not success: QMessageBox.warning(self, "Sign In Failed", "Invalid credentials.") self.logger.info("Login failed displayed") return self.logger.info("Login succeded") super().accept()
def showAboutDialog(self): """Display the application's about dialog.""" QMessageBox.about(self, "Image Manager", """<h3 style='text-align:center'>Image Manager</h3> <p style='font-weight: normal'>The <b><i>Image Manager GUI</i></b> demonstrates how to build an application for managing photos. This program also examines some of the common features found in many GUIs.</p> <p style='font-weight: normal'>This application is part of <b><i>Building Custom UIs with PyQt</i></b>.</p> <p style='font-weight: normal'>Designed by: <b>Joshua Willman</b></p> <p style='font-weight: normal'>Icons created by: <b>Joshua Willman</b></p>""")
def noticeBox(self, msg, title="Notice!"): msgBox = QMessageBox() msgBox.setText(msg) msgBox.setWindowTitle(title) msgBox.setStandardButtons(QMessageBox.StandardButtons.Ok) returnValue = msgBox.exec() if returnValue == QMessageBox.StandardButtons.Ok: return
def converter(): moedaDe = tela.cmbBoxDe.currentText() moedaPara = tela.cmbBoxPara.currentText() valor = tela.txtBoxDe.text() if valor == "": QMessageBox.about(tela, "ALERTA", "DIGITE UM NÚMERO PARA CONVERTER.") if moedaDe == "AOA - KWANZA" and moedaPara == "EUR - EURO": convertAOAEUR(tela) if moedaDe == "AOA - KWANZA" and moedaPara == "USD - DOLAR": convertAOAUSD(tela) if moedaDe == "AOA - KWANZA" and moedaPara == "BRL - REAIS": convertAOABRL(tela) if moedaDe == "AOA - KWANZA" and moedaPara == "GBP - LIBRAS": convertAOAGBP(tela) if moedaDe == "EUR - EURO" and moedaPara == "AOA - KWANZA": convertEURAOA(tela) if moedaDe == "EUR - EURO" and moedaPara == "USD - DOLAR": convertEURUSD(tela) if moedaDe == "EUR - EURO" and moedaPara == "BRL - REAIS": convertEURBRL(tela) if moedaDe == "EUR - EURO" and moedaPara == "GBP - LIBRAS": convertEURGBP(tela) if moedaDe == "USD - DOLAR" and moedaPara == "AOA - KWANZA": convertUSDAOA(tela) if moedaDe == "USD - DOLAR" and moedaPara == "EUR - EURO": convertUSDEUR(tela) if moedaDe == "USD - DOLAR" and moedaPara == "BRL - REAIS": convertUSDBRL(tela) if moedaDe == "USD - DOLAR" and moedaPara == "GBP - LIBRAS": convertUSDGBP(tela) if moedaDe == "BRL - REAIS" and moedaPara == "AOA - KWANZA": convertBRLAOA(tela) if moedaDe == "BRL - REAIS" and moedaPara == "EUR - EURO": convertBRLEUR(tela) if moedaDe == "BRL - REAIS" and moedaPara == "USD - DOLAR": convertBRLUSD(tela) if moedaDe == "BRL - REAIS" and moedaPara == "GBP - LIBRAS": convertBRLGBP(tela) if moedaDe == "GBP - LIBRAS" and moedaPara == "AOA - KWANZA": convertGBPAOA(tela) if moedaDe == "GBP - LIBRAS" and moedaPara == "EUR - EURO": convertGBPEUR(tela) if moedaDe == "GBP - LIBRAS" and moedaPara == "USD - DOLAR": convertGBPUSD(tela) if moedaDe == "GBP - LIBRAS" and moedaPara == "BRL - REAIS": convertGBPBRL(tela)
def removeRow(self, row, index): """Remove a row the model. Call values_edited to update the totals in the Money Left Over table.""" if self._data != [] and index.row() != len(self._data) - 1: self._data.pop(row) else: QMessageBox.information(QApplication.activeWindow(), "No Row Selected", "No row selected for deletion.") self.values_edited.emit() self.layoutChanged.emit() return True
def position_slider_updated(self, pos): if float(self.voltage_readout.text()[:-2]) < 5: QMessageBox.warning( None, "Error", "The voltage going through the servo is too low. Is your battery powered on?", ) return self.active_servo.move(pos) self.position_slider_readout.setText( f"{int(pos * 25 / 6) * 6 / 25:0.2f}°")
def generate(self): temp_cfg = open('_tempcfg.json', 'w') cfg = self.get_current_configuration() json.dump(cfg, temp_cfg, indent=4) temp_cfg.close() generate_header('_tempcfg.json') os.remove('_tempcfg.json') QMessageBox.information(self, "Success", "File Generated Successfully!", QMessageBox.StandardButton.Ok, QMessageBox.StandardButton.Ok)
def doit(self): try: year = int(self.y.currentText()) dates = self.getActiveDates(getDates(year)) except: dates = self.getActiveDates(getDates()) author = git.Actor(self.name.text(), self.email.text()) if not self.name.text() or not self.email.text(): self.err.setText('Did you enter your name and email? 🙄') self.err.exec() return repurl = "https://" + self.name.text() + ":" + self.passw.text( ) + "@" + self.repo.text()[8:] repname = repurl.split('/')[-1].split('.')[0] if not os.path.isdir(repname): try: git.cmd.Git().clone(repurl) except: self.err.setText( 'Could not clone the repo. Ensure that the remote repo exists and that you have access to it.' ) self.err.exec() return rep = git.Repo.init(repname) for date in dates: for n in range(self.nc.value()): rep.index.commit("committed for the lullzz!!", author=author, committer=author, author_date=date.isoformat()) try: rep.remotes.origin.set_url(repurl) except: rep.create_remote('origin', repurl) try: rep.remotes.origin.push() except: self.err.setText( 'Error pushing. Verify you have permissions to push to the repo and that the given credentials are correct' ) self.err.exec() return result = QMessageBox() text = f"Created {len(dates)*2} commits as {self.name.text()} <{self.email.text()}> in {repname} : {self.repo.text()}" result.setWindowIcon(QIcon('icon.png')) result.setWindowTitle('All Done!') result.setText(text) result.exec() os.remove(repname)
def createConnection(databaseName): """Create and open a database connection""" connection = QSqlDatabase.addDatabase("QSQLITE") connection.setDatabaseName(databaseName) if not connection.open(): QMessageBox.warning( None, "RP Contact", f"Database Error: {connection.lastError().text()}", ) return False _createContactsTable() return True
def id_updated(self): new_id = self.set_id_line_edit.text() try: servo = LX16A(int(new_id)) except ServoTimeoutError: # Meaning this ID is not taken self.active_servo.set_id(int(new_id)) self.id_selection_box.item( self.id_selection_box.currentRow()).setText(new_id) return QMessageBox.warning(None, "Error", "ID already taken")
def mostrar_acerca_de(self): mensaje = QMessageBox() mensaje.setIcon(QMessageBox.Icon.Information) mensaje.setText( 'A cerca de Aplicación captura de datos.\n\nAplicacion PyQt6.\nDesarrollador: Mauricio Posada.\nVersión: 1.0.0\n2021.' ) mensaje.exec()
def window_prompt(title: str, prompt_text: str): """ Window prompt template used across the app. :param title: Window title. :param prompt_text: Text to prompt. :return: Nothing, just shows a window prompt. """ # Loads the current ui style and assigns it current_style = stylesheets.load_current_style() prompt = QMessageBox() prompt.setWindowTitle(title) prompt.setText(prompt_text) prompt.setStyleSheet(current_style) prompt.exec()
def runFunc(self, func, *args, **kwargs): if not fgoFunc.base.serialno: return QMessageBox.critical(self, '错误', '未连接设备') def f(): try: self.signalFuncBegin.emit() self.applyAll() func(*args, **kwargs) except fgoFunc.ScriptTerminate as e: logger.critical(e) except Exception as e: logger.exception(e) finally: self.signalFuncEnd.emit() fgoFunc.control.reset() fgoFunc.fuse.reset() QApplication.beep() self.thread = threading.Thread( target=f, name= f'{func.__qualname__}({",".join(repr(i)for i in args)}{","if kwargs else""}{",".join((i+"="+repr(j))for i,j in kwargs.items())})' ) self.thread.start()
def checkCheck(self): if not fgoFunc.base.serialno: return QMessageBox.critical(self, '错误', '未连接设备') try: fgoFunc.Check().show() except Exception as e: logger.critical(e)
def callback_exception(self, exc=None): if exc is None: exc = common.get_exception() Log.append(self.callback_exception, 'Error', exc) if QMessageBox.warning(None, self.lang.title_crash, self.lang.description_crash): self.export_log()
def start_clicked(self): dir = self.download_dir.text() if not dir: QMessageBox.information(self, "错误","请输入存储目录") return if not os.path.exists(dir): os.mkdir(dir) self.thread.dir = dir url = self.url_input.text() print(url) self.thread.url = url pwd = '/'.join(os.getcwd().split('\\'))+'/'+dir btn = QPushButton("删除图片") if pwd not in self.dict: btn.clicked.connect(self.del_pic) self.dict[pwd] = btn self.tableupdate(pwd , self.thread.max_page_num , self.dict[pwd] )
def close_application(self): choice = QMessageBox.question(self, 'exit', "Exit program?", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) if choice == QMessageBox.StandardButton.Yes: self.parent().deleteLater() self.parent().close() else: pass
def pop_exit_dialog(parent) -> bool: return (QMessageBox.question( parent, "Exiting...", "Are you sure?", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, QMessageBox.StandardButton.No, ) == QMessageBox.StandardButton.Yes)
def on_click(self): buttonReply = QMessageBox.question( self, 'PyQt6', 'Do you like PyQt6?', QMessageBox.StandardButtons.Yes | QMessageBox.StandardButtons.No, QMessageBox.StandardButtons.Yes) if buttonReply == QMessageBox.StandardButtons.Yes: self.statusBar().showMessage('You clicked Yes. That' 's good.') else: self.statusBar().showMessage('You clicked No. Why are you here?')
def closeEvent(self, event): if self.thread.is_alive() and QMessageBox.warning( self, '关闭', '战斗正在进行,确认关闭?', QMessageBox.Yes | QMessageBox.No) != QMessageBox.Yes: event.ignore() return fgoFunc.control.terminate() if not self.thread._started: self.thread.join() event.accept()
def saveImage(self): """Save the image displayed in the label.""" #TODO: Add different functionality for the way in which the user can save their image. if self.image.isNull() == False: image_file, _ = QFileDialog.getSaveFileName( self, "Save Image", "", "PNG Files (*.png);;JPG Files (*.jpeg *.jpg );;Bitmap Files (*.bmp);;\ GIF Files (*.gif)") if image_file and self.image.isNull() == False: self.image.save(image_file) else: QMessageBox.information(self, "Error", "Unable to save image.", QMessageBox.Ok) else: QMessageBox.information(self, "Empty Image", "There is no image to save.", QMessageBox.Ok)