Skip to content

Commit af25803

Browse files
committed
Added a command line option to workaround the wxWidget locale issue
- The automatic mechanism fails (broken and broken again!) - Related to #493
1 parent ba161f6 commit af25803

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

kicost/__main__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ def main_real():
237237
# action='store_true',
238238
# help='Run KiCost on terminal using the parameters in the GUI memory, all passed parameters from'
239239
# ' terminal take priority.')
240+
parser.add_argument('--force_en_us',
241+
action='store_true',
242+
help='Workaround for broken wxWidgets locale on some Windows systems.')
240243
parser.add_argument('--setup',
241244
action='store_true',
242245
help='Run KiCost integration (with KiCad and OS) configuration script.')
@@ -316,13 +319,13 @@ def main_real():
316319
if args.gui:
317320
if not GUI_ENABLED:
318321
kicost_gui_notdependences()
319-
kicost_gui([os.path.abspath(fileName) for fileName in args.gui])
322+
kicost_gui(args.force_en_us, [os.path.abspath(fileName) for fileName in args.gui])
320323
sys.exit(0)
321324

322325
if args.input is None:
323326
if not GUI_ENABLED:
324327
kicost_gui_notdependences()
325-
kicost_gui() # Use the user gui if no input is given.
328+
kicost_gui(args.force_en_us) # Use the user gui if no input is given.
326329
sys.exit(0)
327330
else:
328331
# Match the EDA tool formats with the input files.

kicost/kicost_gui.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,25 +1158,20 @@ def close(self):
11581158
pass
11591159

11601160

1161-
def kicost_gui(files=None):
1161+
def kicost_gui(force_en_us=False, files=None):
11621162
''' @brief Load the graphical interface.
11631163
@param String file file names or list.
11641164
(it will be used for plugin implementation on future KiCad6-Eeschema).
11651165
'''
11661166
app = wx.App(redirect=False)
1167-
loc = wx.Locale(wx.LANGUAGE_DEFAULT)
1168-
locale_retry = False
1167+
loc = wx.Locale(wx.LANGUAGE_DEFAULT if not force_en_us else wx.LANGUAGE_ENGLISH_US)
11691168
if not loc.IsOk():
1170-
logger.warning(W_LOCFAIL+"Failed to set the default locale")
1171-
locale_retry = True
1169+
if not force_en_us:
1170+
logger.warning(W_LOCFAIL+"Failed to set the default locale, try using `--force_en_us`")
1171+
else:
1172+
logger.warning(W_LOCFAIL+"`--force_en_us` doesn't seem to help")
11721173
elif not loc.GetLocale() and not loc.GetName():
1173-
logger.warning(W_LOCFAIL+"Unsupported locale")
1174-
locale_retry = True
1175-
if locale_retry:
1176-
loc = wx.Locale(wx.LANGUAGE_ENGLISH_US)
1177-
logger.warning(W_LOCFAIL+"Trying with US english locale")
1178-
if not loc.IsOk():
1179-
logger.warning(W_LOCFAIL+"Failed to set the en_US locale")
1174+
logger.warning(W_LOCFAIL+"Unsupported locale"+(", try using `--force_en_us`" if not force_en_us else ""))
11801175
else:
11811176
logger.debug('wxWidgets locale {} ({}) system: {}'.format(loc.GetLocale(), loc.GetName(), locale.getlocale()))
11821177
frame = formKiCost(None)

0 commit comments

Comments
 (0)