editors/ConfTreeNodeEditor.py
changeset 3302 c89fc366bebd
parent 3291 7d0e7e4d88cd
child 3303 0ffb41625592
equal deleted inserted replaced
2744:577118ebd179 3302:c89fc366bebd
   383                 sizer.AddSizer(staticboxsizer, border=5, flag=flags)
   383                 sizer.AddSizer(staticboxsizer, border=5, flag=flags)
   384                 self.GenerateSizerElements(staticboxsizer,
   384                 self.GenerateSizerElements(staticboxsizer,
   385                                            element_infos["children"],
   385                                            element_infos["children"],
   386                                            element_path)
   386                                            element_path)
   387             else:
   387             else:
   388                 boxsizer = wx.FlexGridSizer(cols=3, rows=1)
   388                 boxsizer = wx.FlexGridSizer(cols=4, rows=1)
   389                 boxsizer.AddGrowableCol(1)
   389                 boxsizer.AddGrowableCol(1)
   390                 flags = (wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
   390                 flags = (wx.GROW | wx.BOTTOM | wx.LEFT | wx.RIGHT)
   391                 if first:
   391                 if first:
   392                     flags |= wx.TOP
   392                     flags |= wx.TOP
   393                 sizer.AddSizer(boxsizer, border=5, flag=flags)
   393                 sizer.AddSizer(boxsizer, border=5, flag=flags)
   470                                   self.GetTextCtrlCallBackFunction(spinctrl, element_path),
   470                                   self.GetTextCtrlCallBackFunction(spinctrl, element_path),
   471                                   spinctrl)
   471                                   spinctrl)
   472 
   472 
   473                 else:
   473                 else:
   474                     if element_infos["type"] == "boolean":
   474                     if element_infos["type"] == "boolean":
   475                         checkbox = wx.CheckBox(self.ParamsEditor, size=wx.Size(17, 25))
   475                         checkbox = wx.CheckBox(self.ParamsEditor)
   476                         boxsizer.AddWindow(checkbox)
   476                         boxsizer.AddWindow(checkbox, flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT)
   477                         if element_infos["value"] is not None:
   477                         if element_infos["value"] is not None:
   478                             checkbox.SetValue(element_infos["value"])
   478                             checkbox.SetValue(element_infos["value"])
   479                         checkbox.Bind(wx.EVT_CHECKBOX,
   479                         checkbox.Bind(wx.EVT_CHECKBOX,
   480                                       self.GetCheckBoxCallBackFunction(checkbox, element_path),
   480                                       self.GetCheckBoxCallBackFunction(checkbox, element_path),
   481                                       checkbox)
   481                                       checkbox)
   524                             textctrl.ChangeValue(str(element_infos["value"]))
   524                             textctrl.ChangeValue(str(element_infos["value"]))
   525                         callback = self.GetTextCtrlCallBackFunction(textctrl, element_path)
   525                         callback = self.GetTextCtrlCallBackFunction(textctrl, element_path)
   526                         textctrl.Bind(wx.EVT_TEXT_ENTER, callback)
   526                         textctrl.Bind(wx.EVT_TEXT_ENTER, callback)
   527                         textctrl.Bind(wx.EVT_TEXT, callback)
   527                         textctrl.Bind(wx.EVT_TEXT, callback)
   528                         textctrl.Bind(wx.EVT_KILL_FOCUS, callback)
   528                         textctrl.Bind(wx.EVT_KILL_FOCUS, callback)
       
   529 
       
   530                 if not isinstance(element_infos["type"], list) and element_infos["use"] == "optional":
       
   531                     bt = wx.BitmapButton(self.ParamsEditor, 
       
   532                         bitmap=wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, (16,16)),
       
   533                         style=wx.BORDER_NONE)
       
   534                     self.Bind(wx.EVT_BUTTON, 
       
   535                               self.GetResetFunction(element_path),
       
   536                               bt)
       
   537 
       
   538                     boxsizer.AddWindow(bt, border=5, flag=wx.ALIGN_CENTER_VERTICAL | wx.LEFT)
   529             first = False
   539             first = False
   530         sizer.Layout()
   540         sizer.Layout()
   531         self.RefreshScrollbars()
   541         self.RefreshScrollbars()
   532 
   542 
   533     def GetItemChannelChangedFunction(self, dir):
   543     def GetItemChannelChangedFunction(self, dir):
   588                 wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE, PAGETITLES)
   598                 wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE, PAGETITLES)
   589                 wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, self.GetTagName())
   599                 wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, self.GetTagName())
   590             event.Skip()
   600             event.Skip()
   591         return OnTextCtrlChanged
   601         return OnTextCtrlChanged
   592 
   602 
       
   603     def GetResetFunction(self, path):
       
   604         def OnResetBt(event):
       
   605             res = self.SetConfNodeParamsAttribute(path, None)
       
   606             wx.CallAfter(self.RefreshView)
       
   607             event.Skip()
       
   608         return OnResetBt
       
   609 
   593     def GetCheckBoxCallBackFunction(self, chkbx, path):
   610     def GetCheckBoxCallBackFunction(self, chkbx, path):
   594         def OnCheckBoxChanged(event):
   611         def OnCheckBoxChanged(event):
   595             res = self.SetConfNodeParamsAttribute(path, chkbx.IsChecked())
   612             res = self.SetConfNodeParamsAttribute(path, chkbx.IsChecked())
   596             chkbx.SetValue(res)
   613             chkbx.SetValue(res)
   597             event.Skip()
   614             event.Skip()