def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ style = self.get_style() factory = self.factory if (len(factory.filter) > 0) or (factory.filter_name != ""): style |= wx.DIRCTRL_SHOW_FILTERS self.control = wx.GenericDirCtrl(parent, style=style) self._tree = tree = self.control.GetTreeCtrl() id = tree.GetId() wx.EVT_TREE_SEL_CHANGED(tree, id, self.update_object) wx.EVT_TREE_ITEM_ACTIVATED(tree, id, self._on_dclick) wx.EVT_TREE_ITEM_GETTOOLTIP(tree, id, self._on_tooltip) self.filter = factory.filter self.sync_value(factory.filter_name, "filter", "from", is_list=True) self.sync_value(factory.reload_name, "reload", "from") self.sync_value(factory.dclick_name, "dclick", "to") self.set_tooltip()
def __init__(self, parent, editor, autoexpand=True): self.initmixin() wx.Panel.__init__(self, parent, -1) self.parent = parent self.editor = editor self.autoexpand = autoexpand self.activeflag = False self.sizer = ui.VBox(namebinding='widget').create(self).auto_layout() self.btnRefresh = FlatButtons.FlatBitmapButton( self, -1, common.getpngimage('images/classbrowserrefresh.gif')) self.sizer.add(self.btnRefresh).bind('click', self.OnRefresh) self.imagelist = wx.ImageList(16, 16) #add share image list self.imagefilenames = [] self.imageids = {} self.callplugin('add_images', self.imagefilenames) for name, imagefile in self.imagefilenames: self.add_image(name, imagefile) style = wx.TR_SINGLE | wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS | wx.TR_TWIST_BUTTONS if wx.Platform == '__WXMSW__': style = style | wx.TR_ROW_LINES elif wx.Platform == '__WXGTK__': style = style | wx.TR_NO_LINES self.tree = wx.TreeCtrl(self, -1, style=style) self.tree.AssignImageList(self.imagelist) self.sizer.add(self.tree, proportion=1, flag=wx.EXPAND) self.root = self.tree.AddRoot('OutlineBrowser') self.nodes = {} self.ID = 1 # wx.EVT_TREE_SEL_CHANGING(self.tree, self.tree.GetId(), self.OnChanging) # wx.EVT_TREE_SEL_CHANGED(self.tree, self.tree.GetId(), self.OnChanged) # wx.EVT_TREE_BEGIN_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnBeginChangeLabel) # wx.EVT_TREE_END_LABEL_EDIT(self.tree, self.tree.GetId(), self.OnChangeLabel) wx.EVT_TREE_ITEM_ACTIVATED(self.tree, self.tree.GetId(), self.OnChanged) # wx.EVT_TREE_ITEM_RIGHT_CLICK(self.tree, self.tree.GetId(), self.OnRClick) # wx.EVT_RIGHT_UP(self.tree, self.OnRClick) wx.EVT_TREE_DELETE_ITEM(self.tree, self.tree.GetId(), self.OnDeleteItem) # wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick) # wx.EVT_TREE_ITEM_EXPANDING(self.tree, self.tree.GetId(), self.OnExpanding) wx.EVT_LEFT_DOWN(self.tree, self.OnLeftDown) wx.EVT_TREE_ITEM_GETTOOLTIP(self.tree, self.tree.GetId(), self.OnGetToolTip) wx.EVT_LEFT_DCLICK(self.tree, self.OnDoubleClick) self.tooltip_func = None #add init process self.callplugin('init', self) # self.SetSizer(self.sizer) # self.SetAutoLayout(True) self.sizer.auto_fit(0) self.popmenus = None