def updateMainRNG6(self): if self.mainRNG: values = self.manager.updateFrameCount() # Handle infinite loop if values is None: self.toggleMainRNG6() message = QMessageBox() message.setText("Exiting an infinite loop. Make sure no patches are installed and the game is on the latest version") message.exec_() return difference, initialSeed, currentSeed, frameCount, save, tiny3, tiny2, tiny1, tiny0 = values # Check to see if frame changed at all if difference != 0: self.lineEditInitialSeed6.setText(hexify(initialSeed)) self.lineEditCurrentSeed6.setText(hexify(currentSeed)) self.lineEditFrame6.setText(str(frameCount)) self.lineEditSaveVariable.setText(hexify(save)) self.lineEditTiny3.setText(hexify(tiny3)) self.lineEditTiny2.setText(hexify(tiny2)) self.lineEditTiny1.setText(hexify(tiny1)) self.lineEditTiny0.setText(hexify(tiny0))
def guess(self): if self.ui.txt_input.text().isnumeric(): if int(self.ui.txt_input.text()) == self.number: self.ui.lbl_comment.setText('✨🎁🧡تو بردی 😍🌺🎉') elif int(self.ui.txt_input.text()) > self.number: self.score -= 1 if self.score == 0: self.ui.lbl_comment.setText('نتونستی تشخیص بدی😒🤦♀️') self.new_game() else: self.ui.lbl_comment.setText('برو پایین تر') else: self.score -= 1 if self.score == 0: self.ui.lbl_comment.setText('نتونستی تشخیص بدی😒🤦♀️') self.new_game() else: self.ui.lbl_comment.setText('برو بالا تر') self.ui.lbl_joon.setText(str(self.score)) else: msg_box = QMessageBox() msg_box.setText("باهوش جان، مقدار عددی وارد کن") msg_box.exec_()
def showDialog(self, text: str, title: str, buttons, callback): dialog = QMessageBox(self.window) dialog.setWindowTitle(title) dialog.setText(text) dialog.setStandardButtons(buttons) dialog.buttonClicked.connect(callback) dialog.exec_()
def accepting(self): """ Process the event when the user clicks "ok" in the dialog box. """ # Make sure the patient weight is a number if self.patient_weight_entry.text() != '': try: num = float(self.patient_weight_entry.text()) if num < 0: raise ValueError self.accept() except ValueError: button_reply = \ QMessageBox(QMessageBox.Icon.Warning, "Invalid Patient Weight", "Please enter a valid number.", QMessageBox.StandardButton.Ok, self) button_reply.button( QMessageBox.StandardButton.Ok).setStyleSheet( self.stylesheet) button_reply.exec_() # Make sure the patient weight is not blank else: button_reply = \ QMessageBox(QMessageBox.Icon.Warning, "Invalid Patient Weight", "Please enter a valid number.", QMessageBox.StandardButton.Ok, self) button_reply.button(QMessageBox.StandardButton.Ok).setStyleSheet( self.stylesheet) button_reply.exec_()
def message_box_error(self, title, text, error=None): message = QMessageBox(self, title, text) message.setIcon(QMessageBox.Warning) message.setWindowTitle(title) message.setText(text) if error is not None: message.setDetailedText(str(error)) message.exec_()
def show_success(self): box = QMessageBox() box.setWindowTitle('Export Complete') box.setWindowIcon(self.icon) box.setText( 'Success. The file has been exported and should show up in the same folder as this program.\n\nDCC by Gideon Tong v1.0' ) box.exec_()
def blurrer_alert(self, message: str): """ Display blurrer messages in the GUI :param message: Message to be displayed """ msg_box = QMessageBox() msg_box.setText(message) msg_box.exec_()
def prompt_calc_dvh(self): """ Windows displays buttons in a different order from Linux. A check for platform is performed to ensure consistency of button positioning across platforms. """ message = "DVHs not present in RTDOSE or do not correspond to ROIs. " message += "Would you like to calculate DVHs? (This may take up to " message += "several minutes on some systems.)" if platform.system() == "Linux": choice = QMessageBox.question(self, "Calculate DVHs?", message, QMessageBox.Yes | QMessageBox.No) if choice == QMessageBox.Yes: self.signal_advise_calc_dvh.emit(True) else: self.signal_advise_calc_dvh.emit(False) else: stylesheet_path = "" # Select appropriate style sheet if platform.system() == 'Darwin': stylesheet_path = Path.cwd().joinpath('res', 'stylesheet.qss') else: stylesheet_path = Path.cwd().joinpath( 'res', 'stylesheet-win-linux.qss') # Create a message box and add attributes mb = QMessageBox() mb.setIcon(QMessageBox.Question) mb.setWindowTitle("Calculate DVHs?") mb.setText(message) button_no = QtWidgets.QPushButton("No") button_yes = QtWidgets.QPushButton("Yes") # We want the buttons 'No' & 'Yes' to be displayed in that # exact order. QMessageBox displays buttons in respect to # their assigned roles. (0 first, then 1 and so on) # 'AcceptRole' is 0 and 'RejectRole' is 1 thus by assigning # 'No' to 'AcceptRole' and 'Yes' to 'RejectRole' the buttons # are positioned as desired. mb.addButton(button_no, QtWidgets.QMessageBox.AcceptRole) mb.addButton(button_yes, QtWidgets.QMessageBox.RejectRole) # Apply stylesheet to the message box and add icon to the window mb.setStyleSheet(open(stylesheet_path).read()) mb.setWindowIcon( QtGui.QIcon( resource_path(Path.cwd().joinpath('res', 'images', 'btn-icons', 'onkodicom_icon.png')))) mb.exec_() if mb.clickedButton() == button_yes: self.signal_advise_calc_dvh.emit(True) else: self.signal_advise_calc_dvh.emit(False)
def error_msg(error_message): message = QMessageBox() message.setText( "There was a problem processing your file. Please click more details for more information." ) message.setInformativeText(error_message) message.setWindowTitle("Error processing file") message.setDetailedText(error_message) message.setStandardButtons(QMessageBox.Ok) QApplication.setOverrideCursor(QCursor(Qt.ArrowCursor)) message.exec_()
def setup_blurrer(self): """ Create and connect a blurrer thread """ weights_name = self.ui.combo_box_weights.currentText() self.blurrer = VideoBlurrer(weights_name) self.blurrer.setMaximum.connect(self.setMaximumValue) self.blurrer.updateProgress.connect(self.setProgress) self.blurrer.finished.connect(self.blurrer_finished) self.blurrer.alert.connect(self.blurrer_alert) msg_box = QMessageBox() msg_box.setText(f"Successfully loaded {weights_name}.pt") msg_box.exec_()
def choose_move(self, active_player: int, game_state: GameState): # noinspection PyBroadException try: if self.player.player_number != active_player: return move = self.player.choose_move(game_state) # noinspection PyUnresolvedReferences self.move_chosen.emit(move) # type: ignore except Exception: print_exc() message = QMessageBox() message.setWindowTitle('Error') message.setText(f'Failed to choose a move.') message.exec_()
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 message_box(self, message: str, buttons: int = 1) -> int: ''' Message box with "Yes/No" or "OK" buttons. Defaults to "OK".\n Parameters:\n message (str): Message shown inside the message box. buttons (int): Amount of buttons, 1 - "OK" button, 2 - "Yes/No" buttons. Returns:\n choice (int): ID of the clicked button. ''' pixmap = QPixmap(resource_path('icon.ico')).scaledToWidth( 35, Qt.SmoothTransformation) msg_box = QMessageBox() msg_box.setFont(ui.font) msg_box.setText(message) if buttons == 2: msg_yes = msg_box.addButton(QMessageBox.Yes) msg_no = msg_box.addButton(QMessageBox.No) msg_yes.setText(self.dialog_yes) msg_no.setText(self.dialog_no) msg_yes.setProperty('class', 'button_yes') msg_no.setProperty('class', 'button_no') msg_box.setWindowFlags(Qt.Dialog | Qt.CustomizeWindowHint) msg_box.setIconPixmap(pixmap) with open(resource_path('style.css'), 'r') as file: msg_box.setStyleSheet(file.read()) msg_box.move(ui.frameGeometry().center() - QRect(QPoint(), msg_box.sizeHint()).center()) choice = msg_box.exec_() return choice
def open_url(url: str): try: # QDesktopServices.openUrl(QUrl(url)) pass except Exception as e: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) title = 'Network error: No connection' msg.setText(title) msg.setInformativeText('Please check your network connection.') msg.setWindowTitle(title) msg.setDetailedText(e) msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msg.exec_()
def _handle_file_open(self): if self.config_has_changes: msg = QMessageBox( QMessageBox.Warning, "Are you sure?", ("You have unsaved changes to your current config. " "If you continue all unsaved changes will be lost."), buttons=QMessageBox.Open | QMessageBox.Cancel, ) if msg.exec_() == QMessageBox.Cancel: return file_path = QFileDialog.getOpenFileName( self, caption="Open a new config...", dir=os.getcwd(), filter="Config Files (*.yml *.yaml)", )[0] if file_path: self.reset_changes(file_path) # update the new log location self.update_log_paths(file_path) # setup the config tabs self.initialise_config_tabs(self.config)
def safeClose(self): check_folder = False for i in range(self.tab_folders.count()): if len(self.tab_folders.widget(i).model()) > 0: check_folder = True break if not (check_folder or self._executing): self.close() return msgbox = QMessageBox(self) msgbox.setWindowTitle("Close") msgbox.setIcon(QMessageBox.Warning) if self._executing: msgbox.setText( "There are pending jobs. Do you really want to close?") else: msgbox.setText("Do you really want to close?") msgbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msgbox.setDefaultButton(QMessageBox.No) if msgbox.exec_() == QMessageBox.Yes: if self._task is not None: self._task.cancel() self.close()
def show_update_info(info: dict): print(info) html_url = info.get('html_url', '') content = [ f'New v{info.get("version")} (Now v{VERSION})', info.get('name', ''), html_url, ] title = 'Update available, download now?' msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText(title) msg.setInformativeText('\n\n'.join(content)) msg.setWindowTitle(title) msg.setDetailedText(info.get('desc', '')) msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) btn_ret = msg.exec_() if btn_ret == QMessageBox.Yes: print('Yes clicked.') open_url(html_url) elif btn_ret == QMessageBox.Ok: print('Ok clicked.') elif btn_ret == QMessageBox.No: print('No clicked.') elif btn_ret == QMessageBox.Cancel: print('Cancel')
def inputChanged(self, content): path = Path(content) if not (content and path.exists()): return if self._input_folder == path: return self.reset() # read file list self._input_folder = path glob = (p for p in path.rglob("*") if p.is_file()) files = [str(p.relative_to(path)) for p in islice(glob, 50)] self.list_input_files.addItems(files) self._network.add_nodes_from(files) # read more files remains = True try: remains = next(glob) except StopIteration: remains = False if remains: msgbox = QMessageBox(self) msgbox.setIcon(QMessageBox.Warning) msgbox.setText("There are too many files in the directory.") msgbox.setInformativeText("Do you still want to list them?") msgbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msgbox.setDefaultButton(QMessageBox.No) if msgbox.exec_() != QMessageBox.Yes: self.reset() return self.list_input_files.addItem(str(remains.relative_to(path))) self._network.add_node(str(remains.relative_to(path))) files = [str(p.relative_to(path)) for p in glob] self.list_input_files.addItems(files) self._network.add_nodes_from(files) # generate keywords keywords = set() keypattern = re.compile(global_config.organizer.keyword_splitter) keywords.update(k.strip() for k in keypattern.split(path.name) if k.strip()) if len(os.listdir(path)) == 0: subf = next(path.iterdir()) if subf.is_dir(): keywords.update(k.strip() for k in keypattern.split(subf.name) if k.strip()) # TODO: extract metadata from input audio files self.widget_keywords.extendKeywords(keywords) # default output path if not global_config.organizer.default_output_dir: self.txt_output_path.setText(str(path.parent / "organized"))
def showErrorDialog(message): box = QMessageBox() box.setIcon(QMessageBox.Critical) box.setText(message) box.setWindowTitle("puya-dl") box.setStandardButtons(QMessageBox.Ok) return box.exec_()
async def apply_stream(self, input_root, output_root): if isinstance(self._input[0], OrganizeTarget): cdfile = Path(output_root, self._input[0].output_name) else: cdfile = Path(input_root, self._input[0]) results = await verify_accurip(cdfile) parsed = parse_accurip(results) if parsed.fail: msgbox = QMessageBox() msgbox.setWindowTitle("Verify failed") msgbox.setIcon(QMessageBox.Critical) msgbox.setText( "AccurateRip verification failed! Please check the output file " + str(Path(output_root, self.output_name))) msgbox.exec_() return BytesIO(results)
def showSimpleDialog(message): box = QMessageBox() box.setIcon(QMessageBox.Question) box.setText(message) box.setWindowTitle("puya-dl") box.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok) return box.exec_()
def connect_emulator(self): if self.hook.running: box = QMessageBox() box.setIcon(QMessageBox.Information) box.setWindowTitle("Already Connected") box.setText("Already connected. Disconnect first.") box.setStandardButtons(QMessageBox.Ok) box.exec_() return pids = hook.get_emu_process_ids() if len(pids) == 0: box = QMessageBox() box.setIcon(QMessageBox.Information) box.setWindowTitle("No Emulators Detected") box.setText("No emulators that can be connected to were detected.") box.setStandardButtons(QMessageBox.Ok) box.exec_() return ConnectEmuDialog(pids, self).exec_()
def blurrer_finished(self): """ Create a new blurrer, setup UI and notify the user """ msg_box = QMessageBox() if self.blurrer and self.blurrer.result["success"]: minutes = int(self.blurrer.result["elapsed_time"] // 60) seconds = round(self.blurrer.result["elapsed_time"] % 60) msg_box.setText( f"Video blurred successfully in {minutes} minutes and {seconds} seconds." ) else: msg_box.setText("Blurring resulted in errors.") msg_box.exec_() if not self.blurrer: self.setup_blurrer() self.ui.button_start.setEnabled(True) self.ui.button_abort.setEnabled(False) self.ui.progress.setValue(0)
def handleFinished(self): self.ui.startButton.setEnabled(True) self.ui.progressBar.setValue(0) msgBox = QMessageBox() msgBox.setIcon(QMessageBox.Information) msgBox.setText("수집이 완료되었습니다.") msgBox.setDefaultButton(QMessageBox.Ok) ret = msgBox.exec_() if ret == QMessageBox.Ok: path = os.getcwd() + "/result" webbrowser.open('file:///' + path)
async def applyRequested(self): # check all targets has been initialized for target in self._network.nodes: if isinstance(target, OrganizeTarget) and not target.initialized: msgbox = QMessageBox(self) msgbox.setWindowTitle("Close") msgbox.setIcon(QMessageBox.Critical) msgbox.setText("There are uninitialized targets!") msgbox.exec_() return # flush folder meta self.flushFolderMeta() for folder, fmeta in self._meta.folders.items(): fmeta.tool = fmeta.tool or self._placeholders[folder].tool fmeta.partnumber = fmeta.partnumber or self._placeholders[ folder].partnumber # flush self._meta.title = self.txt_title.text( ) or self.txt_title.placeholderText() artist_text = self.txt_artists.text( ) or self.txt_artists.placeholderText() self._meta.artists = re.split(global_config.organizer.artist_splitter, artist_text) self._meta.publisher = self.txt_publisher.text( ) or self.txt_publisher.placeholderText() self._meta.vendor = self.txt_vendor.text( ) or self.txt_vendor.placeholderText() self._meta.event = self.txt_event.text( ) or self.txt_event.placeholderText() self._meta.date = self.txt_date.text( ) or self.txt_date.placeholderText() self._meta.genre = self.txt_genre.text( ) or self.txt_genre.placeholderText() self.statusbar.showMessage("Starting execution...") self._task = asyncio.ensure_future(self.executeTargets()) self._status_owner = self._task await self._task self._task = None
def connect_pc(self): if self.hook.running: box = QMessageBox() box.setIcon(QMessageBox.Information) box.setWindowTitle("Already Connected") box.setText("Already connected. Disconnect first.") box.setStandardButtons(QMessageBox.Ok) box.exec_() return pid = hook.get_pc_process_id() if pid is None: box = QMessageBox() box.setIcon(QMessageBox.Information) box.setWindowTitle("FF7 PC Not Detected") box.setText("FF7 PC was not detected.") box.setStandardButtons(QMessageBox.Ok) box.exec_() return self.hook.hooked_platform = hook.Hook.PC_PLATFORM self.hook.hooked_process_id = pid self.hook.start()
def updateMainRNG7(self): if self.mainRNG: values = self.manager.updateFrameCount() # Handle infinite loop if values is None: self.toggleMainRNG7() message = QMessageBox() message.setText("Exiting an infinite loop. Make sure no patches are installed and the game is on the latest version") message.exec_() return difference, initialSeed, currentSeed, frameCount = values # Check to see if frame changed at all if difference != 0: self.lineEditInitialSeed7.setText(hexify(initialSeed)) self.lineEditCurrentSeed7.setText(hexify(currentSeed)) self.lineEditFrame7.setText(str(frameCount))
def debug_show_obj_data_current_frame(self): objs_in_frame = self.tracker.video_data.get_object_points( self.tracker.video_data.current_frame - 1) total_objs = len(objs_in_frame) msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Total objects in frame: " + str(total_objs) + "\n\n" + "First three objects:\n" + "(" + str(objs_in_frame[0][0]) + ", " + str(objs_in_frame[0][1]) + ") Width: " + str(objs_in_frame[0][2]) + ", Height: " + str(objs_in_frame[0][3]) + "\n" + "(" + str(objs_in_frame[1][0]) + ", " + str(objs_in_frame[1][1]) + ") Width: " + str(objs_in_frame[1][2]) + ", Height: " + str(objs_in_frame[1][3]) + "\n" + "(" + str(objs_in_frame[2][0]) + ", " + str(objs_in_frame[2][1]) + ") Width: " + str(objs_in_frame[2][2]) + ", Height: " + str(objs_in_frame[2][3])) msg.setWindowTitle("Objects in current frame") msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def rejecting(self): """ Process the event when the user clicks "cancel" in the dialog box. """ button_reply = \ QMessageBox(QMessageBox.Icon.Warning, "Cannot Proceed with SUV2ROI", "SUV2ROI cannot proceed without patient weight!", QMessageBox.StandardButton.Ok, self) button_reply.button(QMessageBox.StandardButton.Ok).setStyleSheet( self.stylesheet) reply = button_reply.exec_() if reply == QMessageBox.Ok: self.close()
def updateSOSRNG(self): if self.sosRNG: if self.manager.sosInitialSeed is None: self.manager.readSOSInitialSeed() values = self.manager.updateSOSFrameCount() # Handle infinite loop if values is None: message = QMessageBox() message.setText("Exiting an infinite loop. Retry the battle and start updating before taking any actions.") message.exec_() self.toggleSOSRNG() return difference, initialSeed, currentSeed, frameCount, chainCount = values # Check to see if frame changed at all if difference != 0: self.lineEditSOSInitialSeed.setText(hexify(initialSeed)) self.lineEditSOSCurrentSeed.setText(hexify(currentSeed)) self.lineEditSOSFrame.setText(str(frameCount)) self.lineEditSOSChainCount.setText(str(chainCount))