我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用wx.ART_FILE_OPEN。
def InitUI(self,config=None): artprovider = wx.ArtProvider() toolbar = self.CreateToolBar(style=wx.TB_TEXT|wx.TB_HORZ_LAYOUT) toolOpen = toolbar.AddTool(wx.ID_ANY, 'Open', artprovider.GetBitmap(wx.ART_FILE_OPEN,client=wx.ART_TOOLBAR),"Open an i3 config file") toolSave = toolbar.AddTool(wx.ID_ANY, 'Save', artprovider.GetBitmap(wx.ART_FILE_SAVE,client=wx.ART_TOOLBAR),"Save the current settings to the open file") toolApply = toolbar.AddTool(wx.ID_ANY, 'Apply', artprovider.GetBitmap(wx.ART_TICK_MARK,client=wx.ART_TOOLBAR),"Apply the changes without changing file") toolUpdateLocal = toolbar.AddTool(wx.ID_ANY, 'Save to config', artprovider.GetBitmap(wx.ART_FILE_SAVE_AS,client=wx.ART_TOOLBAR),"Save the current colour scheme into your current config") toolSnippet = toolbar.AddTool(wx.ID_ANY, 'Create colour snippet', artprovider.GetBitmap(wx.ART_NEW,client=wx.ART_TOOLBAR),"Save the current colour scheme as a standalone colour file you can send to others") toolVariable = toolbar.AddTool(wx.ID_ANY, 'Create colour variable', artprovider.GetBitmap(wx.ART_PLUS,client=wx.ART_TOOLBAR),"Create a new colour variable") toolbar.AddStretchableSpace() toolQuit = toolbar.AddTool(wx.ID_ANY, 'Quit', artprovider.GetBitmap(wx.ART_QUIT,client=wx.ART_TOOLBAR),"Quit the program") self.Bind(wx.EVT_TOOL, self.OnQuit,toolQuit) self.Bind(wx.EVT_TOOL, self.OnOpen,toolOpen) self.Bind(wx.EVT_TOOL, self.OnApply,toolApply) self.Bind(wx.EVT_TOOL, self.OnSave,toolSave) self.Bind(wx.EVT_TOOL, self.OnUpdateLocal,toolUpdateLocal) self.Bind(wx.EVT_TOOL, self.OnCreateSnippet,toolSnippet) self.Bind(wx.EVT_TOOL, self.OnCreateVariable,toolVariable) self.scrolled = wx.lib.scrolledpanel.ScrolledPanel(self,-1) self.scrolled.SetupScrolling() self.scrolled.Show() self.Centre() self.Show(True) if config!=None: self.LoadConfig(config)
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 initToolbar(self): """ Initialize the toolbar """ self.toolbar = self.CreateToolBar() self.toolbar.SetToolBitmapSize((16,16)) open_ico = wx.ArtProvider.GetBitmap( wx.ART_FILE_OPEN, wx.ART_TOOLBAR, (16,16)) openTool = self.toolbar.AddSimpleTool(wx.ID_ANY, open_ico, "Open", "Open an Image Directory") self.Bind(wx.EVT_MENU, self.onOpenDirectory, openTool) self.toolbar.Realize()
def SetupToolBar(self): """Create the toolbar for common actions""" tb = self.CreateToolBar(self.TBFLAGS) tsize = (24, 24) tb.ToolBitmapSize = tsize open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize) tb.AddLabelTool(ID_OPEN, "Open", open_bmp, shortHelp="Open", longHelp="Open a (c)Profile trace file") tb.AddSeparator() # self.Bind(wx.EVT_TOOL, self.OnOpenFile, id=ID_OPEN) self.rootViewTool = tb.AddLabelTool( ID_ROOT_VIEW, _("Root View"), wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR, tsize), shortHelp=_("Display the root of the current view tree (home view)") ) self.rootViewTool = tb.AddLabelTool( ID_BACK_VIEW, _("Back"), wx.ArtProvider.GetBitmap(wx.ART_GO_BACK, wx.ART_TOOLBAR, tsize), shortHelp=_("Back to the previously activated node in the call tree") ) self.upViewTool = tb.AddLabelTool( ID_UP_VIEW, _("Up"), wx.ArtProvider.GetBitmap(wx.ART_GO_UP, wx.ART_TOOLBAR, tsize), shortHelp=_("Go one level up the call tree (highest-percentage parent)") ) tb.AddSeparator() # TODO: figure out why the control is sizing the label incorrectly on Linux self.percentageViewTool = wx.CheckBox(tb, -1, _("Percent ")) self.percentageViewTool.SetToolTip(wx.ToolTip( _("Toggle display of percentages in list views"))) tb.AddControl(self.percentageViewTool) wx.EVT_CHECKBOX(self.percentageViewTool, self.percentageViewTool.GetId(), self.OnPercentageView) self.packageViewTool = wx.CheckBox(tb, -1, _("File View ")) self.packageViewTool.SetToolTip(wx.ToolTip( _("Switch between call-hierarchy and package/module/function hierarchy"))) tb.AddControl(self.packageViewTool) wx.EVT_CHECKBOX(self.packageViewTool, self.packageViewTool.GetId(), self.OnPackageView) tb.Realize()