Commit b2a5f0244545dd08beab9e74e89db55cfe78253b
1 parent
aab0bb21
Exists in
master
and in
68 other branches
STL: Removed prints / commented language combo build
Showing
1 changed file
with
16 additions
and
6 deletions
Show diff stats
invesalius/gui/language_dialog.py
@@ -39,26 +39,36 @@ class LanguageDialog(wx.Dialog): | @@ -39,26 +39,36 @@ class LanguageDialog(wx.Dialog): | ||
39 | 39 | ||
40 | def __init_combobox_bitmap__(self): | 40 | def __init_combobox_bitmap__(self): |
41 | """Initialize combobox bitmap""" | 41 | """Initialize combobox bitmap""" |
42 | - | 42 | + |
43 | + # Retrieve locales dictionary | ||
43 | dict_locales = i18n.GetLocales() | 44 | dict_locales = i18n.GetLocales() |
44 | - | 45 | + |
46 | + # Retrieve locales names and sort them | ||
45 | self.locales = dict_locales.values() | 47 | self.locales = dict_locales.values() |
46 | self.locales.sort() | 48 | self.locales.sort() |
47 | 49 | ||
48 | - print "-------------------" | ||
49 | - print self.locales | 50 | + # Retrieve locales keys (eg: pt_BR for Portuguese(Brazilian)) |
50 | self.locales_key = [dict_locales.get_key(value)[0] for value in self.locales] | 51 | self.locales_key = [dict_locales.get_key(value)[0] for value in self.locales] |
51 | - print self.locales_key | 52 | + |
53 | + # Find out OS locale | ||
52 | self.os_locale = i18n.GetLocaleOS() | 54 | self.os_locale = i18n.GetLocaleOS() |
53 | 55 | ||
56 | + # FIXME: In future we shall be using all locales using 5 | ||
57 | + # characters... until then, we use only 2: | ||
54 | os_lang = self.os_locale[0:2] | 58 | os_lang = self.os_locale[0:2] |
59 | + | ||
60 | + # Default selection will be English | ||
55 | selection = self.locales_key.index('en') | 61 | selection = self.locales_key.index('en') |
56 | - | 62 | + |
63 | + # Create bitmap combo | ||
57 | self.bitmapCmb = bitmapCmb = wx.combo.BitmapComboBox(self, style=wx.CB_READONLY) | 64 | self.bitmapCmb = bitmapCmb = wx.combo.BitmapComboBox(self, style=wx.CB_READONLY) |
58 | for key in self.locales_key: | 65 | for key in self.locales_key: |
66 | + # Based on composed flag filename, get bitmap | ||
59 | filepath = os.path.join(ICON_DIR, "%s.bmp"%(key)) | 67 | filepath = os.path.join(ICON_DIR, "%s.bmp"%(key)) |
60 | bmp = wx.Bitmap(filepath, wx.BITMAP_TYPE_BMP) | 68 | bmp = wx.Bitmap(filepath, wx.BITMAP_TYPE_BMP) |
69 | + # Add bitmap and info to Combo | ||
61 | bitmapCmb.Append(dict_locales[key], bmp, key) | 70 | bitmapCmb.Append(dict_locales[key], bmp, key) |
71 | + # Set default combo item if available on the list | ||
62 | if key.startswith(os_lang): | 72 | if key.startswith(os_lang): |
63 | selection = self.locales_key.index(key) | 73 | selection = self.locales_key.index(key) |
64 | bitmapCmb.SetSelection(selection) | 74 | bitmapCmb.SetSelection(selection) |