fix problem if DataTypeEditor was imported before localization is
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 21 Sep 2017 15:02:36 +0300
changeset 1821 44a47d255d36
parent 1820 76f5eba31afd
child 1822 1d7bf584eb7f
fix problem if DataTypeEditor was imported before localization is
loaded

That doesn't affect systems with english locales.
editors/DataTypeEditor.py
--- a/editors/DataTypeEditor.py	Sat Sep 16 21:26:17 2017 +0300
+++ b/editors/DataTypeEditor.py	Thu Sep 21 15:02:36 2017 +0300
@@ -58,8 +58,6 @@
     return [_("Directly"), _("Subrange"), _("Enumerated"), _("Array"), _("Structure")]
 
 
-DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()])
-
 # -------------------------------------------------------------------------------
 #                            Structure Elements Table
 # -------------------------------------------------------------------------------
@@ -399,6 +397,8 @@
                                                "Up": self.StructureUpButton,
                                                "Down": self.StructureDownButton})
 
+        self.DATATYPE_TYPES_DICT = dict([(_(datatype), datatype) for datatype in GetDatatypeTypes()])
+
         def _AddStructureElement(new_row):
             self.StructureElementsTable.InsertRow(new_row, self.StructureElementDefaultValue.copy())
             self.RefreshTypeInfos()
@@ -684,7 +684,7 @@
         dialog.Destroy()
 
     def RefreshDisplayedInfos(self):
-        selected = DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()]
+        selected = self.DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()]
         if selected != self.CurrentPanel:
             if self.CurrentPanel == "Directly":
                 self.DirectlyPanel.Hide()
@@ -731,7 +731,7 @@
         self.SubrangeInitialValue.SetBounds(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue())
 
     def RefreshTypeInfos(self):
-        selected = DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()]
+        selected = self.DATATYPE_TYPES_DICT[self.DerivationType.GetStringSelection()]
         infos = {"type": selected}
         if selected == "Directly":
             infos["base_type"] = self.DirectlyBaseType.GetStringSelection()