controls/LibraryPanel.py
branchwxPython4
changeset 3303 0ffb41625592
parent 2456 7373e3048167
child 3750 f62625418bff
equal deleted inserted replaced
3302:c89fc366bebd 3303:0ffb41625592
    75         # This protects from fail to start when no children[0] available (possible for wxPython 3.0)
    75         # This protects from fail to start when no children[0] available (possible for wxPython 3.0)
    76         if self.SearchCtrl.GetChildren():
    76         if self.SearchCtrl.GetChildren():
    77             search_textctrl = self.SearchCtrl.GetChildren()[0]
    77             search_textctrl = self.SearchCtrl.GetChildren()[0]
    78             search_textctrl.Bind(wx.EVT_CHAR, self.OnKeyDown)
    78             search_textctrl.Bind(wx.EVT_CHAR, self.OnKeyDown)
    79 
    79 
    80         main_sizer.AddWindow(self.SearchCtrl, flag=wx.GROW)
    80         main_sizer.Add(self.SearchCtrl, flag=wx.GROW)
    81 
    81 
    82         # Add Splitter window for tree and block comment to main sizer
    82         # Add Splitter window for tree and block comment to main sizer
    83         splitter_window = wx.SplitterWindow(self)
    83         splitter_window = wx.SplitterWindow(self)
    84         splitter_window.SetSashGravity(1.0)
    84         splitter_window.SetSashGravity(1.0)
    85         main_sizer.AddWindow(splitter_window, flag=wx.GROW)
    85         main_sizer.Add(splitter_window, flag=wx.GROW)
    86 
    86 
    87         # Add TreeCtrl for functions and function blocks library in splitter
    87         # Add TreeCtrl for functions and function blocks library in splitter
    88         # window
    88         # window
    89         self.Tree = wx.TreeCtrl(splitter_window,
    89         self.Tree = wx.TreeCtrl(splitter_window,
    90                                 size=wx.Size(0, 0),
    90                                 size=wx.Size(0, 0),
   214                         category_item, root_cookie = \
   214                         category_item, root_cookie = \
   215                             self.Tree.GetNextChild(root, root_cookie)
   215                             self.Tree.GetNextChild(root, root_cookie)
   216 
   216 
   217                 # Set data associated to tree item (only save that item is a
   217                 # Set data associated to tree item (only save that item is a
   218                 # category)
   218                 # category)
   219                 self.Tree.SetPyData(category_item, {"type": CATEGORY})
   219                 self.Tree.SetItemData(category_item, {"type": CATEGORY})
   220 
   220 
   221                 # Iterate over functions and function blocks defined in library
   221                 # Iterate over functions and function blocks defined in library
   222                 # category add a tree item to category tree item for each of
   222                 # category add a tree item to category tree item for each of
   223                 # them
   223                 # them
   224 
   224 
   251                                              in blocktype["inputs"]]),
   251                                              in blocktype["inputs"]]),
   252                         "extension":  (len(blocktype["inputs"])
   252                         "extension":  (len(blocktype["inputs"])
   253                                        if blocktype["extensible"] else None),
   253                                        if blocktype["extensible"] else None),
   254                         "comment":    _(comment) + blocktype.get("usage", "")
   254                         "comment":    _(comment) + blocktype.get("usage", "")
   255                     }
   255                     }
   256                     self.Tree.SetPyData(blocktype_item, block_data)
   256                     self.Tree.SetItemData(blocktype_item, block_data)
   257 
   257 
   258                     # Select block tree item in tree if it corresponds to
   258                     # Select block tree item in tree if it corresponds to
   259                     # previously selected one
   259                     # previously selected one
   260                     if selected_infos == (blocktype["name"],
   260                     if selected_infos == (blocktype["name"],
   261                                           blocktype["inputs"]):
   261                                           blocktype["inputs"]):