editors/ConfTreeNodeEditor.py
branchpython3
changeset 3788 d5014da90054
parent 3765 88fe6fc9fd38
child 3795 223a91584172
equal deleted inserted replaced
3787:56ceda9889f8 3788:d5014da90054
   392                     ID=-1, bitmapname=element_infos["name"],
   392                     ID=-1, bitmapname=element_infos["name"],
   393                     name="%s_bitmap" % element_infos["name"], parent=self.ParamsEditor,
   393                     name="%s_bitmap" % element_infos["name"], parent=self.ParamsEditor,
   394                     pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
   394                     pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0)
   395                 boxsizer.Add(staticbitmap, border=5, flag=wx.RIGHT)
   395                 boxsizer.Add(staticbitmap, border=5, flag=wx.RIGHT)
   396 
   396 
       
   397                 label = element_infos["name"].replace('_', ' ')
   397                 statictext = wx.StaticText(self.ParamsEditor,
   398                 statictext = wx.StaticText(self.ParamsEditor,
   398                                            label="%s:" % _(element_infos["name"]))
   399                                            label="%s:" % _(label))
   399                 boxsizer.Add(statictext, border=5,
   400                 boxsizer.Add(statictext, border=5,
   400                                    flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)
   401                                    flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)
   401 
   402 
   402                 if isinstance(element_infos["type"], list):
   403                 if isinstance(element_infos["type"], list):
   403                     if isinstance(element_infos["value"], tuple):
   404                     if isinstance(element_infos["value"], tuple):
   426 
   427 
   427                         if element_infos["use"] == "optional":
   428                         if element_infos["use"] == "optional":
   428                             combobox.Append("")
   429                             combobox.Append("")
   429                         if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], tuple):
   430                         if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], tuple):
   430                             for choice, _xsdclass in element_infos["type"]:
   431                             for choice, _xsdclass in element_infos["type"]:
   431                                 combobox.Append(choice)
   432                                 combobox.Append(choice.replace('_',' '))
   432                             name = element_infos["name"]
   433                             name = element_infos["name"]
   433                             value = element_infos["value"]
   434                             value = element_infos["value"]
   434 
   435 
   435                             staticboxsizer = None
   436                             staticboxsizer = None
   436                             if element_infos["children"]:
   437                             if element_infos["children"]:
   447                                 combobox.Append(choice)
   448                                 combobox.Append(choice)
   448                             callback = self.GetChoiceCallBackFunction(combobox, element_path)
   449                             callback = self.GetChoiceCallBackFunction(combobox, element_path)
   449                         if element_infos["value"] is None:
   450                         if element_infos["value"] is None:
   450                             combobox.SetStringSelection("")
   451                             combobox.SetStringSelection("")
   451                         else:
   452                         else:
   452                             combobox.SetStringSelection(element_infos["value"])
   453                             combobox.SetStringSelection(
       
   454                                 element_infos["value"].replace('_',' '))
   453                         combobox.Bind(wx.EVT_COMBOBOX, callback, combobox)
   455                         combobox.Bind(wx.EVT_COMBOBOX, callback, combobox)
   454 
   456 
   455                 elif isinstance(element_infos["type"], dict):
   457                 elif isinstance(element_infos["type"], dict):
   456                     scmin = -(2**31)
   458                     scmin = -(2**31)
   457                     scmax = 2**31-1
   459                     scmax = 2**31-1
   579             event.Skip()
   581             event.Skip()
   580         return OnChoiceChanged
   582         return OnChoiceChanged
   581 
   583 
   582     def GetChoiceContentCallBackFunction(self, choicectrl, path):
   584     def GetChoiceContentCallBackFunction(self, choicectrl, path):
   583         def OnChoiceContentChanged(event):
   585         def OnChoiceContentChanged(event):
   584             self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection())
   586             self.SetConfNodeParamsAttribute(
       
   587                 path, choicectrl.GetStringSelection().replace(' ','_'))
   585             wx.CallAfter(self.RefreshConfNodeParamsSizer)
   588             wx.CallAfter(self.RefreshConfNodeParamsSizer)
   586             event.Skip()
   589             event.Skip()
   587         return OnChoiceContentChanged
   590         return OnChoiceContentChanged
   588 
   591 
   589     def GetTextCtrlCallBackFunction(self, textctrl, path, refresh=False):
   592     def GetTextCtrlCallBackFunction(self, textctrl, path, refresh=False):