From 45009953d1af86799889668583ac4868eb9b4cbe Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Sun, 10 Dec 2017 18:23:53 +0200 Subject: [PATCH] Avoid 'KeyError' exception during options reset Use the TwoWayOrderedDict.get(...) method in order to update the language combobox and return 'en_US' as the default language in case the given key value is not in the LOCALE_NAMES dict. Fixes: c4b012d2c83104a119faaf36c6890b681b423aad Related to: #244 --- youtube_dl_gui/optionsframe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl_gui/optionsframe.py b/youtube_dl_gui/optionsframe.py index 7401119..9ce999f 100644 --- a/youtube_dl_gui/optionsframe.py +++ b/youtube_dl_gui/optionsframe.py @@ -429,7 +429,7 @@ class GeneralTab(TabPanel): self.sudo_textctrl.Enable(self.shutdown_checkbox.GetValue()) def load_options(self): - self.language_combobox.SetValue(self.LOCALE_NAMES[self.opt_manager.options["locale_name"]]) + self.language_combobox.SetValue(self.LOCALE_NAMES.get(self.opt_manager.options["locale_name"], "en_US")) self.filename_format_combobox.SetValue(OUTPUT_FORMATS[self.opt_manager.options["output_format"]]) self.filename_custom_format.SetValue(self.opt_manager.options["output_template"]) self.filename_ascii_checkbox.SetValue(self.opt_manager.options["restrict_filenames"])