def evt_submit(self, event): """Merges the intended PDF file Args: event: A button event """ # Check if the list is populated if self.ls_paths: # Determine save-to location with wx.FileDialog(None, "Save", wildcard="pdf files (*.pdf)|*.pdf", style=wx.FD_SAVE) as file_dialog: # Check if the user changed their mind about importing if file_dialog.ShowModal() == wx.ID_CANCEL: return # Assemble PDF try: pdf_merger = PyPDF2.PdfFileMerger(strict=False) for document in self.ls_paths: pdf_merger.append(document) # Save merged file to selected location pdf_merger.write(file_dialog.GetPath()) # Close merging gracefully pdf_merger.close() except Exception as e: dialog = wx.RichMessageDialog( self, caption="An exception occurred", message=str(e), style=wx.OK | wx.ICON_ERROR) dialog.ShowModal() dialog.Destroy() return # Merge Success Confirmation dialog = wx.RichMessageDialog( self, caption="PDF Merged", message="The PDF has been successfully saved to:\n\n" + file_dialog.GetPath(), style=wx.OK | wx.ICON_INFORMATION) dialog.ShowModal() dialog.Destroy()
def update_display(self, videos_list): """ Triggered when dropped items, get the item and transform it into VideoInfo with parameters to use it in ObjectListView """ import nmi_video for path in videos_list: file_stats = os.stat(path) try: clip_duration = nmi_video.get_video_duration(path) except Exception as e: dialog = wx.RichMessageDialog(self, i18n.t('i18n.onlyVideosError'), "Error", wx.ICON_ERROR) dialog.ShowDetailedText("Error info:\n" + "\\" + str(e) + "\\") dialog.ShowModal() return minutes_lenght = str(datetime.timedelta(seconds=clip_duration)) file_size = file_stats[stat.ST_SIZE] if (file_size > 1024): file_size = file_size / 1024.0 if (file_size > 1024.0): file_size = file_size / 1024.0 file_size = "%.2f MB" % file_size else: file_size = "%.2f KB" % file_size self.videos_list.append( nmi_video.VideoInfo(path, minutes_lenght, file_size)) self.olv.SetObjects(self.videos_list)
def OnButton(self, event): if self.bannish: print("That's rich!") return def DING(): """Add some audacity...erm annoyance""" wx.Bell() event.Skip() dlg = wx.RichMessageDialog(self, "Hey You! I'm a rich irritating dialog!") dlg.ShowDetailedText( ("bla bla bla " * 3) + '\n...\n\n' + "Detailed Text(translated) == Don't show the welcome dialog again" "\n(That almost always seems to popup...)") dlg.ShowCheckBox("Bannish me forever") dlg.ShowModal() # return value ignored as we have "Ok" only anyhow for i in range(0, 10): wx.CallLater(500, DING) if dlg.IsCheckBoxChecked(): # ... make sure we won't show it again the next time ... self.bannish = True # Plonk! DING() dlg.Destroy()
def after(): if not mqueue: return msg = mqueue[0] dlg = wx.RichMessageDialog(None, msg, conf.Title, wx.OK | wx.ICON_ERROR) if conf.UnexpectedErrorCount > 2: dlg.ShowCheckBox("&Do not pop up further errors") dlg.ShowModal() if dlg.IsCheckBoxChecked(): conf.PopupUnexpectedErrors = False del mqueue[:] conf.save() if mqueue: mqueue.pop(0) if mqueue and conf.PopupUnexpectedErrors: wx.CallAfter(after)
def on_start(self): """ File data redirecting . """ if not self.array: self.parent.statusbar_msg(_("First select a profile in the list"), PrstPan.YELLOW, PrstPan.BLACK) return if (self.array[2].strip() != self.txt_1cmd.GetValue().strip() or self.array[3].strip() != self.txt_2cmd.GetValue().strip()): if self.txtcmdedited: msg = _("The selected profile command has been " "changed manually.\n" "Do you want to apply it " "during the conversion process?") dlg = wx.RichMessageDialog(self, msg, _("Please confirm"), wx.ICON_QUESTION | wx.YES_NO) dlg.ShowCheckBox(_("Don't show this dialog again")) if dlg.ShowModal() == wx.ID_NO: if dlg.IsCheckBoxChecked(): # make sure we won't show it again the next time self.txtcmdedited = False return if dlg.IsCheckBoxChecked(): # make sure we won't show it again the next time self.txtcmdedited = False outext = '' if self.array[5] == 'copy' else self.array[5] extlst = self.array[4] file_src = supported_formats(extlst, self.parent.file_src) checking = check_files( file_src, self.parent.outpath_ffmpeg, self.parent.same_destin, self.parent.suffix, outext, ) if checking is None: # not supported, missing files or user has changed his mind return fsrc, dirdest, cntmax = checking if self.array[3]: # has double pass self.two_Pass(fsrc, dirdest, cntmax, outext) else: self.one_Pass(fsrc, dirdest, cntmax, outext)
def showConfirmationPopup(parent, msg, title, confirmKey=None): if confirmKey and not settings().get(confirmKey): return True with wx.RichMessageDialog(parent, msg, title, wx.YES_NO | wx.ICON_QUESTION) as dlg: if confirmKey: dlg.ShowCheckBox(_('don\'t show this message again')) res = dlg.ShowModal() == wx.ID_YES if res and confirmKey and dlg.IsCheckBoxChecked(): settings().setValue(confirmKey, False) settings().save() return res
def evt_blueprint(self, event): """Loads a dialog or opens a program (unsure) showing the production drawing of said part Args: event: Button click event """ _dlg = wx.RichMessageDialog( self, caption="This feature is not yet implemented", message= "This feature will load a production drawing of the current part", style=wx.OK | wx.ICON_INFORMATION) _dlg.ShowModal() _dlg.Destroy()
def ShowDialog(self): # pop up a message dialog window on submit! if self._dont_show: return None dlg = wx.RichMessageDialog(parent=None, message= "Are you ready to learn wxPython?", caption="wxPythonStuff", style=wx.YES_NO|wx.CANCEL|wx.CENTRE) dlg.ShowCheckBox("Don't show this again") dlg.ShowModal() # shows the dialog if dlg.IsCheckBoxChecked(): print("Is check box checked?", dlg.IsCheckBoxChecked()) self._dont_show=True
def evt_super_help(self, event): """Show the term definition for super-assembly Args: event: A click event object passed from the click event """ _dlg = wx.RichMessageDialog( self, caption="Help: Term Definition", message= "A super-assembly in this context refers to assemblies that contain " "this part.", style=wx.OK | wx.ICON_INFORMATION) _dlg.ShowModal() _dlg.Destroy()
def on_open_exit(self, event): if self.application_settings.exit_dialog_confirmation: exit_dialog = wx.RichMessageDialog(self, preset.message["exit_question"], preset.message["exit_title"], wx.YES_NO | wx.ICON_QUESTION) exit_dialog.ShowCheckBox(preset.message["exit_confirmation"]) exit_value = exit_dialog.ShowModal() if exit_dialog.IsCheckBoxChecked(): self.application_settings.exit_dialog_confirmation = False self.application_settings.save_settings() if exit_value == wx.ID_YES: self.Destroy() else: self.Close()
def check_ffmpeg(): """Checks before all if user has FFMPEG dependency, if not downloads it""" try: import nmi_video except Exception as e: dialog = wx.RichMessageDialog(self, i18n.t('i18n.ffmpegNotFound'), "Error", wx.ICON_ERROR) dialog.ShowDetailedText("Error info:\n" + "\\" + str(e) + "\\") dialog.ShowModal() if (os.path.isdir(os.getenv('LOCALAPPDATA')) is True): thread = multiprocessing.Process(target=nmi_utils.copy_ffmpeg) else: thread = multiprocessing.Process(target=ffmpeg.download) create_progress_dialog(thread, i18n.t('i18n.ffmpegProgressTitle'), i18n.t('i18n.ffmpegProgressMsg'), i18n.t('i18n.ffmpegCancel'), i18n.t('i18n.ffmpegDownloaded'))
def onFilesDrop(self, col, paths, index): if col and col in (self.subs, self.refs): sort = settings().batchSortFiles and len(paths) > 1 if settings().showBatchDropTargetPopup and len(paths) > 1: msg = _('Do you want to sort files between subtitles and references automatically?') title = _('Sort dropped files') flags = wx.YES_NO | wx.ICON_QUESTION with wx.RichMessageDialog(self, msg, title, flags) as dlg: dlg.ShowCheckBox(_('don\'t show this message again')) sort = dlg.ShowModal() == wx.ID_YES if dlg.IsCheckBoxChecked(): settings().set(showBatchDropTargetPopup=False, batchSortFiles=sort) settings().save() self.addFiles(col, paths, index, sort=sort)
def clean(): if os.path.isfile( os.path.join(globalVars.appArgs.configPath, "tsu.ini")): pass else: dlg = wx.RichMessageDialog( None, _("Si es la primera vez que ejecuta ésta acción.\n es necesario crear un perfil de limpieza, solo debe hacerlo una vez.\n puede pulsar en Crear perfil también si desea modificar uno existente, o puede marcar la casilla para no volver a mostrar éste mensaje." ), style=wx.CANCEL) dlg.SetOKLabel(_("Crear perfil")) dlg.ShowCheckBox(_("No volver a mostrar este mensaje")) rp = dlg.ShowModal() if dlg.IsCheckBoxChecked(): with open( os.path.join(globalVars.appArgs.configPath, "tsu.ini"), "w") as tsu_i: tsu_i.write("sageset: True") else: pass if rp == wx.ID_OK: try: os.environ['PROGRAMFILES(X86)'] with disable_file_system_redirection(): shellapi.ShellExecute(None, 'runas', 'cmd.exe', '/c' + 'CLEANMGR /sageset:1', None, 0) except: shellapi.ShellExecute(None, 'runas', 'cmd.exe', '/c' + 'CLEANMGR /sageset:1', None, 0) else: dlg.Destroy() try: os.environ['PROGRAMFILES(X86)'] with disable_file_system_redirection(): shellapi.ShellExecute(None, 'runas', 'cmd.exe', '/c' + 'CLEANMGR /sagerun:1', None, 0) except: shellapi.ShellExecute(None, 'runas', 'cmd.exe', '/c' + 'CLEANMGR /sagerun:1', None, 0)
def test_richmsgdlg3(self): dlg = wx.RichMessageDialog(None, 'Message', 'Caption') dlg.SetExtendedMessage('extended') dlg.SetMessage('message') dlg.SetOKCancelLabels('okidoky', 'bye-bye') self.assertEqual(dlg.GetExtendedMessage(), 'extended') self.assertEqual(dlg.GetMessage(), 'message') self.assertEqual(dlg.GetOKLabel(), 'okidoky') self.assertEqual(dlg.GetCancelLabel(), 'bye-bye') dlg.ShowCheckBox("Checkbox") dlg.ShowDetailedText("Detailed Text") self.assertEqual(dlg.GetCheckBoxText(), "Checkbox") self.assertEqual(dlg.GetDetailedText(), "Detailed Text") self.assertEqual(dlg.CheckBoxText, "Checkbox") self.assertEqual(dlg.DetailedText, "Detailed Text") dlg.Destroy()
def does_user_confirm(parent, title, message): while True: dlg = wx.RichMessageDialog(parent, message, caption=title, style=wx.OK | wx.CANCEL | wx.CANCEL_DEFAULT | wx.ICON_WARNING) dlg.ShowCheckBox("Acknowledged; run the game.") if dlg.ShowModal() == wx.ID_OK: if dlg.IsCheckBoxChecked(): return True else: wx.MessageDialog( parent, 'If you wish to continue running the game, please ' 'tick the box. You may also cancel running the game.', title).ShowModal() else: return False
def show_message(parent, version, blurb): message = f"""A new CellProfiler release is available:\n\nVersion {version}\n Would you like to visit the download page?""" dlg = wx.RichMessageDialog( parent, message, caption="CellProfiler Update Available", style=wx.YES_NO | wx.CENTRE | wx.ICON_INFORMATION, ) dlg.ShowDetailedText(f"Release Notes:\n{blurb}") dlg.ShowCheckBox("Check for updates on startup", checked=get_check_update_bool()) response = dlg.ShowModal() if response == wx.ID_YES: wx.LaunchDefaultBrowser("https://cellprofiler.org/releases") if not dlg.IsCheckBoxChecked(): set_check_update("Disabled") else: set_check_update(datetime.date.today().strftime("%Y%m%d"))
def create_progress_dialog(thread, title, msg, error, ok): """ Create a new progress Dialog with the given thread and messages passed for: Window title, Window message, Error message and ok message """ thread.start() dialog = wx.ProgressDialog(title, msg, maximum=1, style=wx.PD_AUTO_HIDE | wx.PD_CAN_ABORT) while thread.is_alive(): dialog.Pulse() if (dialog.WasCancelled() is True): thread.terminate() dialog = wx.RichMessageDialog(self, error, "Error", wx.ICON_ERROR) dialog.ShowModal() return else: dialog.Update(1) wx.MessageBox(ok, "OK", wx.ICON_INFORMATION)
def checkAndInstallUpdate(firstInstall: bool = False) -> None: """ this function checks if BEE has an update, if so, ask the user if he wants to update it """ # load current bee version beeVersion: str = config.load('beeVersion') logger.info(f'installed BEE version: {beeVersion}') if firstInstall is False: # bee isn't installed, can't update if beeVersion is None: return # check updates data = utilities.checkUpdate( beeRepoUrl, VersionInfo.parse(beeVersion if not firstInstall else '0.0.0')) logger.info(f'latest BEE version: {data.version}') if data.version is None: # no update available, can't update logger.info('no update available') return if not firstInstall: # show bee update available dialog dialog = wx.RichMessageDialog( parent=wx.GetTopLevelWindows()[0], message= f'BEE2.4 {data.version} is available for download, update now?\n{data.description}', caption='BEE update available!', style=wx.YES_NO | wx.YES_DEFAULT | wx.STAY_ON_TOP | wx.ICON_INFORMATION) choice = dialog.ShowModal() # if user says no, don't update if choice == wx.ID_NO: logger.debug('user cancelled install') return # user said yes logger.debug(f'updating from BEE {beeVersion} to BEE {data.version}!') config.dynConfig['beeUpdateUrl'] = data.url installBee()
def verifyGameFiles(self, evt: wx.CommandEvent): """ triggers the verify game cache dialog + event :param evt: placeholder """ if not config.load("showVerifyDialog"): # user really wants to verify the game files? dialog = wx.RichMessageDialog( parent=self, message='''This will remove EVERYTHING non stock from portal 2!\nclick yes ONLY if you are sure!''', caption='WARNING!', style=wx.YES_NO | wx.CENTRE | wx.ICON_WARNING | wx.STAY_ON_TOP | wx.NO_DEFAULT ) dialog.ShowDetailedText( "if you don't want this dialog to show check this checkbox, but be aware, this is here to protect you" ) dialog.ShowCheckBox("Don't show again") choice = dialog.ShowModal() if dialog.IsCheckBoxChecked(): config.save(False, 'showVerifyDialog') if choice == wx.ID_NO: return # yes he wants to print('YES')
def askForLangSelection(parent, tasks): msg = [_('No language selected for:')] missingLang = False for task in tasks: if not task.sub.lang: msg.append(_('subtitles: ') + task.sub.path) missingLang = True if not task.ref.lang: msg.append(_('references: ') + task.ref.path) missingLang = True if missingLang: msg += ['', descriptions.noLanguageSelectedQuestion] title = _('No language selected') flags = wx.YES_NO | wx.ICON_QUESTION with wx.RichMessageDialog(parent, '\n'.join(msg), title, flags) as dlg: dlg.ShowCheckBox(_('don\'t show this message again')) res = dlg.ShowModal() == wx.ID_YES if res and dlg.IsCheckBoxChecked(): settings().set(showLanguageNotSelectedPopup=False) settings().save() return res return True
def test_richmsgdlg1(self): dlg = wx.RichMessageDialog(None, 'Message', 'Caption') dlg.Destroy()
def load_config(application): """Read a yaml file into config dictionary""" # Read user YAML file into config.opt dictionary, and automatically create if absent (all false) try: with open(os.path.join(mode.exe_location, 'demo' + '_config.yaml'), 'r', encoding='utf8') as stream: _loaded = yaml.safe_load(stream) # Load in variables intended for import if available _keys = list(_loaded.keys()) globals()['opt'] = { x: _loaded[x] for x in set(cfg_user_import).intersection(_keys) } # If any user variables are missing if len(set(cfg_user_import).difference(_keys)) != 0: for undefined in set(cfg_user_import).difference(_keys): globals()['opt'][undefined] = False with open(os.path.join(mode.exe_location, 'demo' + '_config.yaml'), 'w', encoding='utf8') as stream: yaml.dump(globals()['opt'], stream, default_flow_style=False) # If all user variables or the file are missing except (AttributeError, FileNotFoundError): globals()['opt'] = {x: False for x in cfg_user_import} with open(os.path.join(mode.exe_location, 'demo' + '_config.yaml'), 'w', encoding='utf8') as stream: yaml.dump(globals()['opt'], stream, default_flow_style=False) # Read application YAML file into config.cfg dictionary, and prompt to create if absent try: with open(os.path.join(mode.exe_location, 'app_config.yaml'), 'r', encoding='utf8') as stream: _loaded = yaml.safe_load(stream) # Load in variables intended for import if available _keys = list(_loaded.keys()) _missing_config = list(set(cfg_app_import).difference(_keys)) globals()['cfg'] = { x: _loaded[x] for x in set(cfg_app_import).intersection(_keys) } except (AttributeError, FileNotFoundError): dlg = wx.RichMessageDialog( None, caption="Missing Config File", message= "The config file is missing or empty. Please generate one now, or cancel if " "you want to locate the file", style=wx.OK | wx.CANCEL | wx.ICON_WARNING) if dlg.ShowModal() == wx.ID_OK: call_config_dialog() _missing_config = [] else: exit() if len(_missing_config) != 0: # AND IS VALID dlg = wx.RichMessageDialog( None, caption="Missing Config Values", message= "Some variables are missing from the config file. Please update them now.", style=wx.OK | wx.ICON_WARNING) dlg.ShowModal() call_config_dialog() # Special handling for sql type if 'sql_type' not in globals()['cfg']: dlg = DialogConfigSQL() dlg.ShowModal() if globals()['cfg']['sql_type'] == "SQLite": # SQLite import sqlite3 globals()['sql_db'] = sqlite3 elif globals()['cfg']['sql_type'] == "PostgreSQL": # PostgreSQL import psycopg2 globals()['sql_db'] = psycopg2 else: raise Exception( "An invalid SQL database management system provided: " + globals()['cfg']['sql_type']) # Special handling for missing required variables # Special handling for missing optional variables print(globals()['opt'])
def test_richmsgdlg1(self): dlg = wx.RichMessageDialog(None, 'Message', 'Caption') wx.CallLater(250, dlg.EndModal, wx.ID_OK) dlg.ShowModal() dlg.Destroy()
def open_parts_tab(self, part_num, part_rev="0", opt_stay=False): """Open a new tab using the provided part number and revision Args: part_num (string): The part number to open as a new tab part_rev (string): The part revision to open as a new tab - default revision 0 opt_stay (bool): If true, do not change to newly opened tab - default change tabs """ # Open the database to quickly check if the part and revision exists conn = config.sql_db.connect(config.cfg["db_location"]) crsr = conn.cursor() crsr.execute( "SELECT EXISTS (SELECT 1 FROM Parts WHERE part_num=(?) AND part_rev=(?))", (part_num, part_rev)) _check = crsr.fetchone()[0] conn.close() # Check if the part and revision exists; if not inquire if you would like to add one if _check: # If there is not yet a tab for this part number then create one, otherwise redirect to the existing if part_num not in [_tab.part_num for _tab in self.open_tabs]: new_tab = TabPartInfo(self, part_num, part_rev) self.open_tabs.append(new_tab) self.AddPage(new_tab, part_num) # Handles whether to stay on current tab or move to newly opened tab if not opt_stay: self.SetSelection(self.GetPageCount() - 1) elif not opt_stay: self.SetSelection([pnl.part_num for pnl in self.open_tabs].index(part_num)) else: _dlg = wx.RichMessageDialog( self, caption="Part Not In System", message="This part is not currently added to the system.\n" "Do you want to add %s r%s to the database?" % (part_num, part_rev), style=wx.YES_NO | wx.NO_DEFAULT | wx.ICON_WARNING) # If the user selects that they want to add the part, then add the part if _dlg.ShowModal() == wx.ID_YES: conn = config.sql_db.connect(config.cfg["db_location"]) crsr = conn.cursor() crsr.execute( "INSERT INTO Parts (part_num, part_rev) VALUES ((?), (?));", (part_num, part_rev)) crsr.close() conn.commit() # If there is not yet a tab for this part number then create one, otherwise redirect to the existing if part_num not in [_tab.part_num for _tab in self.open_tabs]: new_tab = TabPartInfo(self, part_num, part_rev) self.open_tabs.append(new_tab) self.AddPage(new_tab, part_num) # Handles whether to stay on current tab or move to newly opened tab if not opt_stay: self.SetSelection(self.GetPageCount() - 1) elif not opt_stay: self.SetSelection([pnl.part_num for pnl in self.open_tabs ].index(part_num)) _dlg.Destroy()
def ShowDialog(self, message='Default Message'): dlg = wx.RichMessageDialog(self, f"{message}") dlg.ShowModal() # return value ignored as we have "Ok" only anyhow
config = json.load(fp) if config['__version__'] != __version__: raise ValueError('Config file has incompatible version') self.wfm.from_dict(config['waveforms']) for x, y in zip(self.channels_ui, config['channels']): x.from_dict(y) except (IOError, ValueError, KeyError) as e: logging.getLogger('OSCGUI').error( 'Failed to load config file: ' + repr(e)) if oscgui_config['Waveform']['realtime_update'] == 'yes': self.on_update(None) if __name__ == '__main__': app = wx.App() if oscgui_config['OSCGUI']['warning_on_startup'] == 'yes': dlg = wx.RichMessageDialog( None, 'Do not turn off the power on board before clicking the Disconnect ' 'button.\nOtherwise it will damage the uLED.', 'CAUTION', style=wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION) dlg.ShowCheckBox("Don't show again") dlg.ShowModal() if dlg.IsCheckBoxChecked(): oscgui_config['OSCGUI']['warning_on_startup'] = 'no' with open('config.ini', 'w') as fp: oscgui_config.write(fp) MainFrame().Show() sys.exit(app.MainLoop())
def test_richmsgdlg2(self): dlg = wx.RichMessageDialog(self.frame, 'Message', 'Caption') dlg.Destroy()
def on_start(self): """ File data redirecting . """ # check normalization data offset, if enable. if self.rdbx_norm.GetSelection() in [1, 2]: # PEAK or RMS if self.btn_analyzes.IsEnabled(): wx.MessageBox( _('Undetected volume values! use the ' '"Volumedetect" control button to analyze ' 'data on the audio volume.'), "Videomass", wx.ICON_INFORMATION) return self.time_seq = self.parent.time_seq dir_destin = self.parent.file_destin # used for file name log self.logname = 'Videomass_PresetsManager.log' ######## ------------ VALIDAZIONI: -------------- if array == []: self.parent.statusbar_msg(_("First select a profile in the list"), yellow) return if (array[2].strip() != self.txt_1cmd.GetValue().strip() or array[3].strip() != self.txt_2cmd.GetValue().strip()): if not self.txtcmdedited: msg = _("The selected profile command has been " "changed manually.\n" "Do you want to apply it " "during the conversion process?") dlg = wx.RichMessageDialog( self, msg, _("Videomass: Please confirm"), wx.ICON_QUESTION | wx.YES_NO, ) dlg.ShowCheckBox(_("Don't show this dialog again")) if dlg.ShowModal() == wx.ID_NO: if dlg.IsCheckBoxChecked(): # make sure we won't show it again the next time self.txtcmdedited = True return else: if dlg.IsCheckBoxChecked(): # make sure we won't show it again the next time self.txtcmdedited = True outext = '' if array[5] == 'copy' else array[5] extlst, outext = array[4], outext file_sources = supported_formats(extlst, self.file_src) checking = inspect(file_sources, dir_destin, outext) if not checking[0]: # missing files or user has changed his mind return (batch, file_sources, dir_destin, fname, bname, cntmax) = checking # batch: batch or single process # fname: filename, nome file senza ext. # bname: basename, nome file con ext. # cntmax: count items for batch proc. if array[3]: # has double pass self.two_Pass(file_sources, dir_destin, cntmax, outext) else: self.one_Pass(file_sources, dir_destin, cntmax, outext)
def on_YoutubeDL(self, event): """ Check the existence of youtube-dl based on the set attributes of the bootstrap, then open the text interface, otherwise it requires installation. """ if self.oS == 'Windows': msg_windows = (_( '- Requires: Microsoft Visual C++ 2010 ' 'Redistributable Package (x86)\n\nfor major ' 'information visit: <http://ytdl-org.github.io' '/youtube-dl/download.html>' )) if self.oS == 'Darwin': msg_windows = '' else: msg_windows = '' msg_error = _('{}\n\nyoutube-dl: no library or executable ' 'found .').format(self.PYLIB_YDL) msg_required = (_( 'An updated version of youtube-dl is required to download ' 'videos from YouTube.com and other video sites. Videomass ' 'can download an updated copy of youtube-dl locally.\n\n' '- Web site: <https://github.com/ytdl-org/youtube-dl/' 'releases>\n{}\n\n' '...Do you wish to continue?' )).format(msg_windows) msg_ready = (_( 'Successful! \n\n' 'Important: youtube-dl is very often updated, be sure ' 'to always use the latest version available. Use the ' 'dedicated functions on menu bar > Tools > youtube-dl.\n\n' 'Re-start is required. Do you want to close Videomass now?' )) msg_system_used = (_( 'Note: the youtube-dl executable previously downloaded ' 'with Videomass is no longer in use, since the one ' 'included in the system is now used.\n\n' 'Do you want to remove the one no longer in use?' )) if self.PYLIB_YDL is None: fydl = os.path.join(self.CACHEDIR, self.YOUTUBE_DL) if self.WARN_YDL == 'false': if not self.EXEC_YDL and os.path.isfile(fydl): if self.store_ydl_on_cache: dlg = wx.RichMessageDialog(self, msg_system_used, _("Please confirm"), wx.ICON_QUESTION | wx.YES_NO ) dlg.ShowCheckBox(_("Don't show this dialog again")) if dlg.ShowModal() == wx.ID_NO: if dlg.IsCheckBoxChecked(): # make sure we won't show it # again the next time self.store_ydl_on_cache = False else: os.remove(fydl) if dlg.IsCheckBoxChecked(): self.store_ydl_on_cache = False self.parent.switch_text_import(self, 'Youtube Downloader') return elif self.EXEC_YDL: if os.path.isfile(self.EXEC_YDL): self.parent.switch_text_import(self, 'Youtube Downloader') return else: if wx.MessageBox(msg_required, _("Please confirm"), wx.ICON_QUESTION | wx.YES_NO, self) == wx.NO: return latest = self.parent.ydl_latest(self, msgbox=False) if latest[1]: return else: upgrade = IO_tools.youtubedl_upgrade(latest[0], self.EXEC_YDL) if upgrade[1]: # failed wx.MessageBox("%s" % (upgrade[1]), "Videomass", wx.ICON_ERROR, self) return else: if wx.MessageBox(msg_ready, "Videomass", wx.ICON_QUESTION | wx.YES_NO, self) == wx.NO: return self.parent.on_Kill() return elif self.EXEC_YDL is False: wx.MessageBox(msg_error, 'Videomass', wx.ICON_ERROR) return
def messageBox(self, msg): dlg = wx.RichMessageDialog(self, message=msg, style=wx.OK | wx.CENTER) dlg.ShowModal()