def LoadPlugins(self): """Update and load the data for the plugin list control.""" # Set up the plugins for each plugin entry point of dicompyler for n, plugin in enumerate(self.plugins): # Skip plugin if it doesn't contain the required dictionary # or actually is a proper Python module p = plugin['plugin'] if not hasattr(p, 'pluginProperties'): continue props = p.pluginProperties() root = self.userroot if (plugin['location'] == 'base'): root = self.baseroot else: root = self.userroot i = self.tcPlugins.AppendItem(root, props['name'], 1) if (p.__name__ in self.pluginsDisabled): self.tcPlugins.SetItemImage(i, 2) self.tcPlugins.SetItemTextColour(i, wx.Colour(169, 169, 169)) self.tcPlugins.SetPyData(i, n) self.tcPlugins.SelectItem(i) self.tcPlugins.ExpandAll() wx.EVT_TREE_ITEM_COLLAPSING(self, XRCID('tcPlugins'), self.OnExpandCollapseTree) wx.EVT_TREE_ITEM_EXPANDING(self, XRCID('tcPlugins'), self.OnExpandCollapseTree)
def __build(self): """ Construct the GUI. """ sizer = wx.BoxSizer(wx.HORIZONTAL) nb = self.notebook = wx.Notebook(self, -1) sizer.Add(nb, 1, wx.EXPAND) #self.htmlWindow = wx.HtmlWindow(nb, -1) self.text = wx.TextCtrl(nb, -1, style=wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_LINEWRAP | wx.TE_RICH) nb.AddPage(self.text, "General") self.tree = wx.TreeCtrl(nb, -1, style=wx.TR_NO_BUTTONS | wx.TR_SINGLE) nb.AddPage(self.tree, "Certification path") # # Force the tree to stay open. # wx.EVT_TREE_ITEM_COLLAPSING(self, self.tree.GetId(), lambda event: event.Veto()) wx.EVT_TREE_ITEM_ACTIVATED(self, self.tree.GetId(), self.OnTreeItemActivated) self.SetSizer(sizer) self.SetAutoLayout(1) self.Fit()
def __init__(self, parent, image_size=(16, 16), **traits): """ Creates a new tree viewer. 'parent' is the toolkit-specific control that is the tree's parent. 'image_size' is a tuple in the form (int width, int height) that specifies the size of the label images (if any) displayed in the tree. """ # Base class constructor. super(TreeViewer, self).__init__(**traits) # Create the toolkit-specific control. self.control = tree = wx.TreeCtrl(parent, -1, style=self._get_style()) # Get our actual Id. wxid = tree.GetId() # Wire up the wx tree events. wx.EVT_CHAR(tree, self._on_char) wx.EVT_LEFT_DOWN(tree, self._on_left_down) wx.EVT_RIGHT_DOWN(tree, self._on_right_down) wx.EVT_TREE_ITEM_ACTIVATED(tree, wxid, self._on_tree_item_activated) wx.EVT_TREE_ITEM_COLLAPSED(tree, wxid, self._on_tree_item_collapsed) wx.EVT_TREE_ITEM_COLLAPSING(tree, wxid, self._on_tree_item_collapsing) wx.EVT_TREE_ITEM_EXPANDED(tree, wxid, self._on_tree_item_expanded) wx.EVT_TREE_ITEM_EXPANDING(tree, wxid, self._on_tree_item_expanding) wx.EVT_TREE_BEGIN_LABEL_EDIT(tree, wxid, self._on_tree_begin_label_edit) wx.EVT_TREE_END_LABEL_EDIT(tree, wxid, self._on_tree_end_label_edit) wx.EVT_TREE_BEGIN_DRAG(tree, wxid, self._on_tree_begin_drag) wx.EVT_TREE_SEL_CHANGED(tree, wxid, self._on_tree_sel_changed) # The image list is a wxPython-ism that caches all images used in the # control. self._image_list = ImageList(image_size[0], image_size[1]) if self.show_images: tree.AssignImageList(self._image_list) # Mapping from element to wx tree item Ids. self._element_to_id_map = {} # Add the root item. if self.input is not None: self._add_element(None, self.input) return
def __init__(self, parent, image_size=(16, 16), **traits): """ Creates a new tree. 'parent' is the toolkit-specific control that is the tree's parent. 'image_size' is a tuple in the form (int width, int height) that specifies the size of the images (if required) displayed in the tree. """ # Base class constructors. super(Tree, self).__init__(**traits) # Get our wx Id. wxid = wx.NewId() # Create the toolkit-specific control. self.control = tree = _Tree(self, parent, wxid, style=self._get_style()) # Wire up the wx tree events. wx.EVT_CHAR(tree, self._on_char) wx.EVT_LEFT_DOWN(tree, self._on_left_down) # fixme: This is not technically correct as context menus etc should # appear on a right up (or right click). Unfortunately, if we # change this to 'EVT_RIGHT_UP' wx does not fire the event unless the # right mouse button is double clicked 8^() Sad, but true! wx.EVT_RIGHT_DOWN(tree, self._on_right_down) # fixme: This is not technically correct as we would really like to use # 'EVT_TREE_ITEM_ACTIVATED'. Unfortunately, (in 2.6 at least), it # throws an exception when the 'Enter' key is pressed as the wx tree # item Id in the event seems to be invalid. It also seems to cause # any child frames that my be created in response to the event to # appear *behind* the parent window, which is, errrr, not great ;^) wx.EVT_LEFT_DCLICK(tree, self._on_tree_item_activated) #wx.EVT_TREE_ITEM_ACTIVATED(tree, wxid, self._on_tree_item_activated) wx.EVT_TREE_ITEM_COLLAPSING(tree, wxid, self._on_tree_item_collapsing) wx.EVT_TREE_ITEM_COLLAPSED(tree, wxid, self._on_tree_item_collapsed) wx.EVT_TREE_ITEM_EXPANDING(tree, wxid, self._on_tree_item_expanding) wx.EVT_TREE_ITEM_EXPANDED(tree, wxid, self._on_tree_item_expanded) wx.EVT_TREE_BEGIN_LABEL_EDIT(tree, wxid, self._on_tree_begin_label_edit) wx.EVT_TREE_END_LABEL_EDIT(tree, wxid, self._on_tree_end_label_edit) wx.EVT_TREE_BEGIN_DRAG(tree, wxid, self._on_tree_begin_drag) wx.EVT_TREE_SEL_CHANGED(tree, wxid, self._on_tree_sel_changed) wx.EVT_TREE_DELETE_ITEM(tree, wxid, self._on_tree_delete_item) # Enable the tree as a drag and drop target. self.control.SetDropTarget(PythonDropTarget(self)) # The image list is a wxPython-ism that caches all images used in the # control. self._image_list = ImageList(image_size[0], image_size[1]) if self.show_images: tree.AssignImageList(self._image_list) # Mapping from node to wx tree item Ids. self._node_to_id_map = {} # Add the root node. if self.root is not None: self._add_root_node(self.root) # Listen for changes to the model. self._add_model_listeners(self.model) return
def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, pos=wx.DefaultPosition, size=(800, 600)) self.selected = None self.Centre(wx.BOTH) splitter = wx.SplitterWindow(self, -1, style=wx.SP_NOBORDER | wx.NO_3D) splitter2 = wx.SplitterWindow(splitter, -1, style=wx.SP_3D | wx.NO_3D) def EmptyHandler(evt): pass wx.EVT_ERASE_BACKGROUND(splitter, EmptyHandler) wx.EVT_ERASE_BACKGROUND(splitter2, EmptyHandler) tID = wx.NewId() self.tree = wx.TreeCtrl(splitter, tID, style=wx.TR_NO_BUTTONS) wx.EVT_TREE_ITEM_EXPANDING(self.tree, tID, self.OnExpand) wx.EVT_TREE_ITEM_COLLAPSING(self.tree, tID, self.OnExpand) wx.EVT_TREE_SEL_CHANGED(self.tree, tID, self.OnForumSelected) panel = wx.Panel(splitter2, -1, style=wx.SP_NOBORDER | wx.NO_3D) tID = wx.NewId() self.list = wx.ListCtrl(panel, tID, style=wx.LC_REPORT | wx.LC_SINGLE_SEL) self.list.InsertColumn(0, "") self.list.InsertColumn(1, "Date") self.list.InsertColumn(2, "Sender") self.list.InsertColumn(3, "Subject") wx.EVT_LIST_ITEM_SELECTED(self.list, tID, self.OnMessageSelected) self.list.SetColumnWidth(0, 20) #self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE) self.list.SetColumnWidth(2, 190) self.list.SetColumnWidth(3, 295) btnBox = wx.BoxSizer(wx.HORIZONTAL) self.newSubject = wx.Button(panel, -1, _("&New subject")) self.reply = wx.Button(panel, -1, _("&Reply")) self.readAll = wx.Button(panel, -1, _("Read &all")) self.delete = wx.Button(panel, -1, _("&Delete")) self.deleteAll = wx.Button(panel, -1, _("D&elete all")) btnBox.Add(self.newSubject, 1, wx.EXPAND) btnBox.Add(self.reply, 1, wx.EXPAND) btnBox.Add(self.readAll, 1, wx.EXPAND) btnBox.Add(self.delete, 1, wx.EXPAND) btnBox.Add(self.deleteAll, 1, wx.EXPAND) accel = wx.AcceleratorTable([ (wx.ACCEL_ALT, ord('N'), self.newSubject.GetId()), (wx.ACCEL_ALT, ord('R'), self.reply.GetId()), (wx.ACCEL_ALT, ord('A'), self.readAll.GetId()), (wx.ACCEL_ALT, ord('D'), self.delete.GetId()), (wx.ACCEL_ALT, ord('E'), self.deleteAll.GetId()), ]) panel.SetAcceleratorTable(accel) wx.EVT_BUTTON(self.newSubject, self.newSubject.GetId(), self.OnNewSubject) wx.EVT_BUTTON(self.reply, self.reply.GetId(), self.OnReply) wx.EVT_BUTTON(self.readAll, self.readAll.GetId(), self.OnReadAll) wx.EVT_BUTTON(self.delete, self.delete.GetId(), self.OnDelete) wx.EVT_BUTTON(self.deleteAll, self.deleteAll.GetId(), self.OnDeleteAll) self.newSubject.Disable() self.reply.Disable() self.readAll.Disable() self.delete.Disable() self.deleteAll.Disable() box = wx.BoxSizer(wx.VERTICAL) box.Add(self.list, 1, wx.EXPAND) box.Add(btnBox, 0, wx.EXPAND) panel.SetSizer(box) panel.SetAutoLayout(True) self.message = wx.TextCtrl(splitter2, -1, "", style=wx.TE_MULTILINE | wx.NO_3D | wx.TE_READONLY) splitter2.SplitHorizontally(panel, self.message) splitter.SplitVertically(self.tree, splitter2, 180) splitter.SetMinimumPaneSize(20) splitter2.SetMinimumPaneSize(20) box.Fit(panel) self.finddata = wx.FindReplaceData() self.findidx = 0 wx.EVT_COMMAND_FIND(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_NEXT(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_REPLACE(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_REPLACE_ALL(self, -1, self.OnFind) wx.EVT_COMMAND_FIND_CLOSE(self, -1, self.OnFindClose) menuBar = wx.MenuBar() menu = wx.Menu() menu.Append(MENU_FIND, _("&Find\tCtrl+F")) menu.Append(MENU_FIND_NEXT, _("&Find next\tF3")) menu.AppendSeparator() menu.Append(MENU_REFRESH, _("&Refresh\tCtrl+R")) menu.AppendSeparator() menu.Append(MENU_EXIT, _("E&xit\tAlt+X")) menuBar.Append(menu, _("&File")) self.SetMenuBar(menuBar) wx.EVT_MENU(self, MENU_EXIT, self.OnQuitMenu) wx.EVT_MENU(self, MENU_REFRESH, self.OnRefreshMenu) wx.EVT_MENU(self, MENU_FIND, self.OnFindMenu) wx.EVT_MENU(self, MENU_FIND_NEXT, self.OnFindNext) wx.EVT_UPDATE_UI(self, MENU_FIND, self.OnUpdateMenuUI) wx.EVT_UPDATE_UI(self, MENU_FIND_NEXT, self.OnUpdateMenuUI) self.CreateStatusBar(1, wx.ST_SIZEGRIP) self.selectedItem = None self.showFind = True self.createTree()