我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用wx.ART_OTHER。
def LoadIconList(self): isz = (16, 16) self.tree_fs.icon_list = wx.ImageList(*isz) folder = wx.Icon( 'icons/ic_folder_black_18dp.png', wx.BITMAP_TYPE_PNG, isz[0], isz[1], ) folder_open = wx.Icon( 'icons/ic_folder_open_black_18dp.png', wx.BITMAP_TYPE_PNG, isz[0], isz[1], ) self.tree_fs.icon_fldridx = self.tree_fs.icon_list.AddIcon(folder) self.tree_fs.icon_fldropenidx = self.tree_fs.icon_list.AddIcon(folder_open) self.tree_fs.icon_fileidx = self.tree_fs.icon_list.AddIcon(wx.ArtProvider.GetIcon(wx.ART_NORMAL_FILE, wx.ART_OTHER, isz)) self.tree_fs.SetImageList(self.tree_fs.icon_list)
def __init__(self, parent): wx.Frame.__init__(self, parent, -1, "CustomTreeCtrl Demo") # Create a CustomTreeCtrl instance custom_tree = CT.CustomTreeCtrl(self, agwStyle=wx.TR_DEFAULT_STYLE) # Add a root node to it root = custom_tree.AddRoot("The Root Item") # Create an image list to add icons next to an item il = wx.ImageList(16, 16) fldridx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16, 16))) fldropenidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_OTHER, (16, 16))) fileidx = il.Add(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, (16, 16))) custom_tree.SetImageList(il) custom_tree.SetItemImage(root, fldridx, wx.TreeItemIcon_Normal) custom_tree.SetItemImage(root, fldropenidx, wx.TreeItemIcon_Expanded) list = [ 'http://app.finance.china.com.cn/forex', 'http://app.finance.china.com.cn/report/list.php', 'http://app.finance.china.com.cn/stock/bill'] for x in list: child = custom_tree.AppendItem(root, "Item %s" % x) custom_tree.SetItemImage(child, fldridx, wx.TreeItemIcon_Normal) custom_tree.SetItemImage(child, fldropenidx, wx.TreeItemIcon_Expanded) for y in list: last = custom_tree.AppendItem(child, "item-%s-%s" % (x,y)) custom_tree.SetItemImage(last, fldridx, wx.TreeItemIcon_Normal) custom_tree.SetItemImage(last, fldropenidx, wx.TreeItemIcon_Expanded) for z in list: item = custom_tree.AppendItem(last, "item %s-%s-%s" % (x,y,z)) custom_tree.SetItemImage(item, fileidx, wx.TreeItemIcon_Normal) custom_tree.Expand(root) # our normal wxApp-derived class, as usual
def _SetBitmaps(self): self.bmp_folder = wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, (16, 16)) self.bmp_norm_file = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, (16, 16)) self.icons = { 'Folder': self.bmp_folder, 'File': self.bmp_norm_file }
def __init__(self, controller_uid): UIViewBase.__init__(self, controller_uid) UIM = UIManager() controller = UIM.get(self._controller_uid) parent_controller_uid = UIM._getparentuid(self._controller_uid) parent_controller = UIM.get(parent_controller_uid) wx.TreeCtrl.__init__(self, parent_controller.view, -1, wx.Point(0, 0), wx.Size(200, 250), wx.TR_DEFAULT_STYLE | wx.NO_BORDER) self._rootid = self.AddRoot(wx.EmptyString) self._set_project_name() self.SetItemData(self._rootid, (controller._PSEUDOROOTUID, None)) self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.on_rightclick) ''' imglist = wx.ImageList(16, 16, True, 2) imglist.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16,16))) tree.AssignImageList(imglist) items.append(tree.AppendItem(root, "Item 1", 0)) ''' parent_controller.view._mgr.AddPane(self, wx.aui.AuiPaneInfo().Name("tree"). Caption("Object Manager").Left().Layer(1).Position(1). PinButton(True).MinimizeButton(True). CloseButton(False).MaximizeButton(True) ) parent_controller.view._mgr.Update() self.Bind(wx.EVT_TREE_BEGIN_DRAG, self._on_begin_drag)