def _try_installing_ijulia(self): """Prompts user to install IJulia.""" # First find out active project to ask user's permission to change it program = "{0}".format(self.julia_exe) args = list() args.append(f"--project={self.julia_project_path}") args.append("-e") args.append("println(Base.active_project())") exec_mngr = QProcessExecutionManager(self._toolbox, program, args, silent=True) exec_mngr.start_execution() if not exec_mngr.wait_for_process_finished(msecs=5000): self._toolbox.msg_error.emit( "\tCouldn't find out Julia active project. " "Make sure that Julia is correctly installed and try again.") self.execution_failed.emit(-1) return julia_active_project = exec_mngr.process_output msg = QMessageBox(parent=self._toolbox) msg.setIcon(QMessageBox.Question) msg.setWindowTitle("IJulia installation needed") msg.setText( "Spine Toolbox needs to do the following modifications to the Julia project at <b>{0}</b>:" "<p>Install the IJulia package.".format(julia_active_project)) allow_button = msg.addButton("Allow", QMessageBox.YesRole) msg.addButton("Cancel", QMessageBox.RejectRole) msg.exec_() # Show message box if msg.clickedButton() != allow_button: self.starting = False self._control.viewport().setCursor(self.normal_cursor) self.execution_failed.emit(-1) return self._do_try_installing_ijulia()
def confirm_negative_start_time(self, negative_starts: List[Package]) -> bool: formatted = '<br />'.join([ f"{p.primary_task.name} {p.target.name}" for p in negative_starts ]) mbox = QMessageBox( QMessageBox.Question, "Continue with past start times?", ("Some flights in the following packages have start times set " "earlier than mission start time:<br />" "<br />" f"{formatted}<br />" "<br />" "Flight start times are estimated based on the package TOT, so it " "is possible that not all flights will be able to reach the " "target area at their assigned times.<br />" "<br />" "You can either continue with the mission as planned, with the " "misplanned flights potentially flying too fast and/or missing " "their rendezvous; automatically fix negative TOTs; or cancel " "mission start and fix the packages manually."), parent=self) auto = mbox.addButton("Fix TOTs automatically", QMessageBox.ActionRole) ignore = mbox.addButton("Continue without fixing", QMessageBox.DestructiveRole) cancel = mbox.addButton(QMessageBox.Cancel) mbox.setEscapeButton(cancel) mbox.exec_() clicked = mbox.clickedButton() if clicked == auto: self.fix_tots(negative_starts) return True elif clicked == ignore: return True return False
def on_check_for_update(self): self.setCursor(Qt.WaitCursor) current_version = get_current_version_name() try: latest_version = get_latest_version_name() except ValueError as ve: QMessageBox.critical(self, "Error while checking for updates", f"Error: {ve}") return if current_version != latest_version: latest_release_url = f"{releases_link}/tag/{latest_version}" go_to_github_button = QPushButton(icon("external-link.svg"), "Go to latest release") go_to_github_button.clicked.connect( lambda: open_url(latest_release_url)) info_box = QMessageBox( QMessageBox.Information, "New release available", f"New Version {latest_version} is available.") info_box.addButton(QMessageBox.Cancel) info_box.addButton(go_to_github_button, QMessageBox.AcceptRole) info_box.exec_() else: QMessageBox.information( self, "No newer release", f"Version {current_version} is up to date.") self.setCursor(Qt.ArrowCursor)
def import_from_excel(self): msg_box = QMessageBox() msg_box.setText( "Use one of the available templates to import your collection from an Excel spreadsheet." ) msg_box.setInformativeText( "Note: do not change the filename of the template.") msg_box.setStandardButtons(QMessageBox.Open | QMessageBox.Cancel) expanded = msg_box.addButton('Create Expanded...', QMessageBox.ApplyRole) condensed = msg_box.addButton('Create Condensed...', QMessageBox.ApplyRole) msg_box.setDefaultButton(QMessageBox.Cancel) ret = msg_box.exec_() if msg_box.clickedButton() == expanded: path = QFileDialog.getExistingDirectory( self, "Select Directory for Template...") + '/' import_export.generate_sheet(path, expanded=True) elif msg_box.clickedButton() == condensed: path = QFileDialog.getExistingDirectory( self, "Select Directory for Template...") + '/' import_export.generate_sheet(path, expanded=False) elif ret == QMessageBox.Open: path = QFileDialog.getOpenFileName( self, "Select Filled-Out Template...") import_export.import_db(path[0])
def runPython(cmd=str): ''' Run python commands. Parameters ---------- cmd: (str) commands in Python language. ''' if cmd: try: exec(cmd) except SyntaxError as err: dial = QMessageBox() dial.setText(str(err)) dial.setWindowTitle("Caution!") dial.setIcon(QMessageBox.Warning) dial.addButton('Ok', QMessageBox.RejectRole) dial.exec_() except Exception as err: dial = QMessageBox() dial.setText(str(err)) dial.setWindowTitle("Caution!") dial.setIcon(QMessageBox.Warning) dial.addButton('Ok', QMessageBox.RejectRole) dial.exec_()
def save_image_dialog(self): raw_image = False checkBox = QCheckBox("Save raw image") checkBox.setChecked(True) msgBox = QMessageBox(self) msgBox.setWindowTitle("Save Image") msgBox.setText( "Save the image displayed in the preview or the raw image from the camera" ) msgBox.setIcon(QMessageBox.Question) msgBox.addButton(QMessageBox.Ok) msgBox.addButton(QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Cancel) msgBox.setCheckBox(checkBox) val = msgBox.exec() if val == QMessageBox.Cancel: return raw_image = msgBox.checkBox().isChecked() now = datetime.now().strftime("%y-%m-%d_%H-%M") save_path, filter = QFileDialog.getSaveFileName( self, "Choose save file", f"{userpaths.get_my_pictures()}/screenshot_{now}.png", "Images (*.png *.jpg *.bmp)") if save_path is None: return qimg = self.ui.camera_prev.grab_image(raw=raw_image) if qimg is None: return qimg.save(save_path, quality=100)
def disable_ui_and_execute_wisdem(self): """ This method disables all widgets on the UI and executes WISDEM. It displays message boxes depending on whether WISDEM executed successfully. """ self.main_widget.setEnabled(False) self.status_label.setText("Running WISDEM") try: wt_opt, modeling_options, analysis_options = run_wisdem( self.geometry_filename, self.modeling_filename, self.analysis_filename ) except Exception as err: short_error_message = f"{type(err)}: {err}. More details on command line." traceback.print_exc(file=sys.stdout) self.status_label.setText("Execution error") msg = QMessageBox() msg.setText("WISDEM execution error") msg.setInformativeText(short_error_message) msg.addButton(QMessageBox.Ok) msg.exec() self.main_widget.setEnabled(True) else: self.status_label.setText("Execution success") msg = QMessageBox() msg.setText("WISDEM executed successfully") msg.addButton(QMessageBox.Ok) msg.exec() self.main_widget.setEnabled(True)
def convert_evernote(): makefolder() recursive() dial = QMessageBox() dial.setText("Finished Converting!") dial.setWindowTitle("Success!") dial.addButton(QMessageBox.Ok) dial.exec_()
def spiders_info(self): self.spider.universities_spider() MESSAGE = "更新/爬取学术信息完成" msgBox = QMessageBox(QMessageBox.Question, "提示", MESSAGE, QMessageBox.NoButton, self) msgBox.addButton("确定", QMessageBox.AcceptRole) msgBox.exec_()
def spider_info(self): text=self.comboBox_2.currentText() college = self.session.query(Seed).filter(Seed.college == text).first() self.spider.university_spider(college) MESSAGE = "更新/爬取学术信息完成" msgBox = QMessageBox(QMessageBox.Question, "提示", MESSAGE, QMessageBox.NoButton, self) msgBox.addButton("确定", QMessageBox.AcceptRole) msgBox.exec_()
def custom_message(self): msg_box = QMessageBox(self._window) msg_box.setIcon(QMessageBox.Information) msg_box.setWindowTitle('Custom Box') msg_box.setText('Dekban Massage') msg_box.setInformativeText('Welcome to tutorial! plz follow us') msg_box.setDetailedText('Follow our Bucketing page, and learn more' 'about PySide2, Java, Design pattern!\n' 'Enjoy!') msg_box.addButton('follow', QMessageBox.AcceptRole) msg_box.show()
def msgbox(message_text, title=None, icon=None, buttons=None, parent=None, default_index=-1, enable_close_button=False): ''' Show message_text to user and wait until window will be closed @param icon: message box can also have one of standart icon QMessageBox.NoIcon QMessageBox.Question QMessageBox.Information QMessageBox.Warning QMessageBox.Critical @param buttoons: You can pass list of tuples (caption, result) to specify which buttons will be shown on the messagebox window. appropriate 'result' value of pushed button is returned as result. By default only one OK button is shown with empty string as result @return 'result' value of pushed button or empty string ''' mymessage = QMessageBox(parent) if title: mymessage.setWindowTitle(title) else: mymessage.setWindowTitle(tr("Pvtbox")) mymessage.setText(str(message_text)) results = {} if buttons: for i, (caption, result) in enumerate(buttons): btn = mymessage.addButton(caption, QMessageBox.ActionRole) if i == default_index: mymessage.setDefaultButton(btn) results[btn] = result if enable_close_button: close_btn = mymessage.addButton('', QMessageBox.RejectRole) close_btn.hide() pvtboxIcon = QIcon(':/images/icon.png') mymessage.setWindowIcon(pvtboxIcon) if icon: mymessage.setIcon(icon) mymessage.raise_() mymessage.exec_() return results.get(mymessage.clickedButton(), "")
def get_permission(self, title, action): """Ask user's permission to perform an action and return True if granted.""" msg = QMessageBox(parent=self) msg.setIcon(QMessageBox.Question) msg.setWindowTitle(title) msg.setText( "Spine Toolbox needs to do the following modifications to the Julia project at <b>{0}</b>:" "<p>{1}".format( self.spine_model_config_asst.julia_active_project(), action)) allow_button = msg.addButton("Allow", QMessageBox.YesRole) msg.addButton("Cancel", QMessageBox.RejectRole) msg.exec_() # Show message box return msg.clickedButton() == allow_button
def run_spliter(self): msgBox = QMessageBox() msgBox.setIcon(QMessageBox.Information) msgBox.setText("The spliter will divide datas "\ "into training set and validation set") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.addButton(QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Ok) ret = msgBox.exec() if ret == QMessageBox.Ok: train_val_spliter.train_val_split(data_dir=self.adc_folder_dir) else: return
def request_to_user( self, dialog_id, text, buttons=("Yes", "No"), title="", close_button_index=-1, close_button_off=False, parent=None, on_clicked_cb=None, details=''): msg_box = QMessageBox(parent) # msg_box = QMessageBox() if not title: title = tr('Pvtbox') msg_box.setWindowTitle(title) msg_box.setText(str(text)) pvtboxIcon = QIcon(':/images/icon.png') msg_box.setWindowIcon(pvtboxIcon) if details: msg_box.setDetailedText(details) if close_button_off: if get_platform() == 'Darwin': msg_box.setWindowFlags(Qt.Tool) else: msg_box.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint) msg_box.setAttribute(Qt.WA_MacFrameworkScaled) msg_box.setModal(True) buttons = list(buttons) for button in buttons: msg_box.addButton(button, QMessageBox.ActionRole) msg_box.show() msg_box.raise_() msg_box.exec_() try: button_index = buttons.index(msg_box.clickedButton().text()) except (ValueError, AttributeError): button_index = -1 # message box was closed with close button if len(buttons) == 1 and close_button_index == -1: # if only one button then call callback close_button_index = 0 if len(buttons) > close_button_index >= 0: button_index = close_button_index if button_index >= 0 and callable(on_clicked_cb): on_clicked_cb(dialog_id, button_index)
def showContinueSearchDialog(self, searchlimit: int) -> bool: messagebox = QMessageBox(self) messagebox.setWindowTitle('Unusual search depth') messagebox.setText(f''' <p>No mod detected after searching through {searchlimit} directories.</p> <p>Are you sure this is a valid mod?</p> ''') messagebox.setTextFormat(Qt.RichText) messagebox.setStandardButtons(QMessageBox.Cancel) yes: QPushButton = QPushButton(' Yes, continue searching ', messagebox) yes.setAutoDefault(True) yes.setDefault(True) messagebox.addButton(yes, QMessageBox.YesRole) messagebox.exec_() return messagebox.clickedButton() == yes
def check_no_missing_pilots(self) -> bool: missing_pilots = [] for package in self.game.blue_ato.packages: for flight in package.flights: if flight.missing_pilots > 0: missing_pilots.append((package, flight)) if not missing_pilots: return False formatted = "<br />".join( [f"{p.primary_task} {p.target}: {f}" for p, f in missing_pilots] ) mbox = QMessageBox( QMessageBox.Critical, "Flights are missing pilots", ( "The following flights are missing one or more pilots:<br />" "<br />" f"{formatted}<br />" "<br />" "You must either assign pilots to those flights or cancel those " "missions." ), parent=self, ) mbox.setEscapeButton(mbox.addButton(QMessageBox.Close)) mbox.exec_() return True
def export_alleles(): msgBox = QMessageBox(QApplication.activeWindow()) msgBox.setText("Data export") msgBox.setInformativeText("What would you like to export?") exp_orig = msgBox.addButton("Original Data", QMessageBox.ActionRole) exp_renamed = msgBox.addButton("Renamed Alleles Data", QMessageBox.ActionRole) if len(Data.mod_alleles_dict) == 0: msgBox.removeButton(msgBox.buttons()[1]) msgBox.addButton(QMessageBox.Cancel) export = True msgBox.exec_() if msgBox.clickedButton() == exp_orig: data = Data.orig_alleles_dict print("Exporting renames alleles data...") elif msgBox.clickedButton() == exp_renamed: data = Data.mod_alleles_dict print("Exporting renamed alleles data...") else: export = False print("Cancel") if export: try: path, _ = QFileDialog().getSaveFileName( QApplication.activeWindow(), filter='*.csv') df = DataFrame.from_dict( data, orient='index', columns=['marker_id', 'allele', 'marker_name']) df = df.drop(labels="marker_id", axis=1) df = df.reindex(columns=["marker_name", "allele"]) df.to_csv(path_or_buf=path, sep="\t", header=False, index=False) #with ExcelWriter(path) as writer: # df.to_excel(writer) QMessageBox.information( GraphicalGenotypeController.ui, "Info", "Export Success\nAlleles data was " "exported successfully to path") except (): QMessageBox.information( GraphicalGenotypeController.ui, "Warning", "Export Failed\nAn error has occurred!")
def abortDialog(): msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText("Soll die Auswertung abgebrochen werden?") msg.setInformativeText("Keine Auswertung wird erstellt.\n" + "Wenn dieses Fenster abgebrochen wird, wird der Dialog wiederholt.") msg.setWindowTitle("DKB Auswertung") yesButton = msg.addButton('Ja', QMessageBox.YesRole) msg.addButton('Nein', QMessageBox.NoRole) msg.setDefaultButton(yesButton) retval = msg.exec_() if retval == 0: return True else: return False
def check_slvs(): if not _param.GetBool('CheckSLVS', True): return try: import py_slvs return except ImportError: pass def dont_ask(checked): param.SetBool('CheckSLVS', checked) checkbox = QCheckBox(translate('asm3', "Don't ask again")) dlg = QMessageBox(FreeCADGui.getMainWindow()) dlg.setWindowTitle(translate('asm3', 'Install Assembly Solver')) dlg.setText(translate('asm3', """ The Assembly3 workbench uses <a href="https://solvespace.com/">SolveSpace</a> as the assembly solver. It is not included in this package due to licensing restrictions. <br><br> Would you like to download and install the Python bindings of SolveSpace (<a href="https://pypi.org/project/py-slvs/">py-slvs</a>)? """)) dlg.setIcon(QMessageBox.Icon.Question) dlg.addButton(QMessageBox.Yes) dlg.addButton(QMessageBox.No) dlg.setDefaultButton(QMessageBox.Yes) dlg.setCheckBox(checkbox) checkbox.toggled.connect(dont_ask) if dlg.exec() != QMessageBox.Yes: return pip_install("py-slvs") try: import importlib importlib.invalidate_caches() import py_slvs QMessageBox.information(FreeCADGui.getMainWindow(), translate('asm3', 'Succeed'), translate('asm3', 'Done!')) except ImportError: QMessageBox.critical(FreeCADGui.getMainWindow(), translate('asm3', 'Failed'), translate('asm3', 'Failed to install py-slvs'))
def fireworks(self): """ As of now, - display a dialog when the target is successfully solved, - replace the target by a message "No more goal" Note that the dialog is displayed only the first time the signal is triggered, thanks to the flag self.cqdf. """ # TODO: make it a separate class # Display msg_box unless redoing or test mode # (Previously was: Display unless exercise already solved) # if not self.exercise_solved: if not self.proof_step.is_redo() and not self.test_mode: title = _('Target solved') text = _('The proof is complete!') msg_box = QMessageBox(parent=self) msg_box.setText(text) msg_box.setWindowTitle(title) button_ok = msg_box.addButton(_('Back to exercise'), QMessageBox.YesRole) button_change = msg_box.addButton(_('Change exercise'), QMessageBox.YesRole) button_change.clicked.connect(self.change_exercise) msg_box.exec() self.proof_step.no_more_goal = True self.proof_step.new_goals = [] # Artificially create a final proof_state by replacing target by a msg # (We do not get the final proof_state from Lean). proof_state = deepcopy(self.proof_step.proof_state) target = proof_state.goals[0].target target.math_type = MathObject( node="NO_MORE_GOAL", info={}, children=[], ) # Update proof_step and UI self.update_proof_state(proof_state) if not self.exercise_solved: self.exercise_solved = True if not self.test_mode: # Save exercise for auto-test self.lean_file.save_exercise_for_autotest(self)
def askYesNo(message, title=bdstr.question): """Uses `QMessageBox` to ask "Yes" or "No" for a given question. Parameters: message: the question to be displayed title: the window title Output: return True if the "Yes" button has been clicked, False otherwise """ mbox = QMessageBox(QMessageBox.Question, title, message) yesButton = mbox.addButton(QMessageBox.Yes) noButton = mbox.addButton(QMessageBox.No) mbox.setDefaultButton(noButton) mbox.exec_() if mbox.clickedButton() == yesButton: return True else: return False
def draw_pajek(): msgBox = QMessageBox(QApplication.activeWindow()) msgBox.setText("Plot network with Pajek") msgBox.setInformativeText("Which network would you like to plot?") net_plot = msgBox.addButton("Network", QMessageBox.ActionRole) mst_plot = msgBox.addButton("MST of Network", QMessageBox.ActionRole) plot = True if Data.network.mst == None: msgBox.removeButton(msgBox.buttons()[1]) msgBox.addButton(QMessageBox.Cancel) msgBox.exec_() if msgBox.clickedButton() == net_plot: to_plot = Data.network print("Plotting network with Pajek...") elif msgBox.clickedButton() == mst_plot: to_plot = Data.network.mst print("Plotting MST with Pajek...") else: plot = False print("Cancel") if plot: pajek_path = os.getcwd() + '\Pajek64\Pajek.exe' try: path, _ = QFileDialog().getSaveFileName( QApplication.activeWindow(), filter='*.net') Network.print_pajek_network(plot_net=to_plot, sFileName=path) QMessageBox.information( NetworkTabController.ui, "Info", "Save Success\nMap " "was successfully saved to path") except (): QMessageBox.information(NetworkTabController.ui, "Warning", "Save Failed\nAn error has occurred!") NetworkTabController.ui.log_plainTextEdit.appendPlainText( f"Network was exported to Pajek format successfully" f"\n\t#Nodes: {len(to_plot.nodes)}" f"\n\t#Edges: {len(to_plot.edges)}" f"\n\tNetwork save path: {path}\n") subprocess.Popen([pajek_path, path])
def run_weis_clicked(self): """ When the "Run WEIS" button is clicked, a popup dialog will pop up asking what the user wants to do. If the user has skipped any configuration files, then it will tell them to go back and create those configuration files. If the user has specified all the configuration files, then it will prompt the user for confirmation before saving the WEIS configuration files. """ if self.geometry_filename is None: msg = QMessageBox() msg.setText("Run WISDEM: Missing file") msg.setInformativeText("You did not specify a geometry file.") msg.addButton(QMessageBox.Cancel) msg.exec() elif self.modeling_filename is None: msg = QMessageBox() msg.setText("Run WISDEM: Missing file") msg.setInformativeText("You did not specify a modeling file.") msg.addButton(QMessageBox.Cancel) msg.exec() elif self.analysis_filename is None: msg = QMessageBox() msg.setText("Run WISDEM: Missing file") msg.setInformativeText("You did not specify an analysis file.") msg.addButton(QMessageBox.Cancel) msg.exec() else: self.status_label.setText("Writing files...") self.write_configuration_files() self.status_label.setText("Configuration files written.") msg = QMessageBox() msg.setText("Run WISDEM: Configuration files complete!") msg.setInformativeText("Click cancel to back out and continue editing. Click OK to run WISDEM.") msg.addButton(QMessageBox.Cancel) msg.addButton(QMessageBox.Ok) choice = msg.exec() if choice == QMessageBox.Ok: self.disable_ui_and_execute_wisdem()
def run_handler(self): self.py_ = G.config.installed_apps[self.pack_name].get('py_') if not self.py_: QMessageBox.warning(self.parent, "提示", "未选择Python解释器") self.act_setting_slot() return if not os.path.exists(self.py_) or not os.path.isfile(self.py_): QMessageBox.warning(self.parent, "提示", f"{self.py_} 不存在") return try: self.entry_, requirement_ = self.get_build() except Exception as e: QMessageBox.warning(self.parent, "提示", str(e)) return ##检测依赖 p = QProcess() p.start(' '.join(([self.py_, "-m", 'pip', "freeze"]))) p.waitForFinished() out = p.readAllStandardOutput().data().decode() output = out.splitlines() with open(requirement_, 'r') as f: requirement = f.read().splitlines() dissatisfy, version_less = diff_pip(output, requirement) if dissatisfy: msgbox = QMessageBox(self.parent) msgbox.setWindowTitle("缺少依赖") msgbox.setText("\n".join(dissatisfy[:15]) + "\n...") yes = msgbox.addButton('立即安装', QMessageBox.AcceptRole) no = msgbox.addButton('稍后', QMessageBox.RejectRole) msgbox.setDefaultButton(yes) reply = msgbox.exec_() if reply == QMessageBox.AcceptRole: self.requirement_ = dissatisfy self.install_handler() return # run TipDialog("正在启动...") cmd = ' '.join([self.py_, self.entry_]) QProcess().startDetached(cmd)
def popUpBoxTable(path): ''' A pop-up window to confirm if one should save a table in ASCII path [string] is the displayed path to the new history file Will return buttonRole of pressed button ''' msgBox = QMessageBox() msgBox.setText('Confirm the following action:') text = 'Save table in ASCII-format as:' + path msgBox.setInformativeText(text) msgBox.addButton(QMessageBox.Save) msgBox.addButton(QMessageBox.Cancel) msgBox.exec_() pressed_button = msgBox.clickedButton() return msgBox.buttonRole(pressed_button)
def yesNoDialog(parent, msg, title): """ Convenience function to display a Yes/No dialog Returns: bool: return True if yes button press. No otherwise """ m = QMessageBox(parent) m.setText(msg) m.setIcon(QMessageBox.Question) yesButton = m.addButton(_(Text.txt0082), QMessageBox.ButtonRole.YesRole) noButton = m.addButton(" No ", QMessageBox.ButtonRole.NoRole) m.setDefaultButton(noButton) m.setFont(parent.font()) m.setWindowTitle(title) m.exec_() if m.clickedButton() == yesButton: return True return False
def popUpBoxEdit(msg): ''' A pop-up window to confirm if one should save tracked changes msg [string] is the displayed information in the window Will return buttonRole of pressed button ''' msgBox = QMessageBox() msgBox.setText('Confirm saving your changes:') msgBox.setDetailedText(msg) save_button = msgBox.addButton(QMessageBox.Save) msgBox.addButton(QMessageBox.Cancel) msgBox.addButton(QMessageBox.Reset) msgBox.exec_() pressed_button = msgBox.clickedButton() return msgBox.buttonRole(pressed_button)
def show_start_countdown_dialog(self): def get_cur_time(): time = over_timer.remainingTime() return math.trunc(time / 1000) + 1 def timeout(): msg_box.close() over_timer.stop() countdown_timer.stop() self.start_game() msg_box = QMessageBox() msg_box.setIcon(QMessageBox.Information) msg_box.setText('Игра начнется через 5 секунд') msg_box.addButton('Начать сейчас', QMessageBox.YesRole) countdown_timer = QTimer(msg_box) over_timer = QTimer(msg_box) countdown_timer.timeout.connect(lambda: msg_box.setText( 'Игра начнется через {} секунд'.format(get_cur_time()))) over_timer.timeout.connect(timeout) msg_box.buttonClicked.connect(timeout) over_timer.start(5000) countdown_timer.start(1000) msg_box.exec_()
def show_settings_missing_dialog(self, username): msg_box = QMessageBox() msg_box.setIcon(QMessageBox.Information) msg_box.setText('Добро пожаловать, {}!'.format(username)) msg_box.setInformativeText( 'Желаете загрузить настройки Inventor или оставить по умолчанию?') msg_box.addButton('Загрузить', QMessageBox.YesRole) msg_box.addButton('По-умолчанию', QMessageBox.NoRole) msg_box.addButton('Отмена', QMessageBox.RejectRole) result = msg_box.exec_() return result