wxpython编程之 toolbar(工具栏)

wxpython 工具栏的简单使用

#!/usr/bin/env python import wx from wx import BitmapFromImage, ImageFromStream from wx import EmptyIcon import cStringIO def getNewData(): return / '/x89PNG/r/n/x1a/n/x00/x00/x00/rIHDR/x00/x00/x00/x10/x00/x00/x00/x0f/x08/x06/ /x00/x00/x00/xedsO//x00/x00/x00/x04sBIT/x08/x08/x08/x08|/x08d/x88/x00/x00/ /x00YIDATx/x9c/xed/xd31/n@!/x0c/x03/xd0/xa4/xfe/xfb/xdfX/xe3/xf0/x97R/xa5(./ /x0ef/x13/xe45/xa2/x92Vp/x92/xcf//xd4/xaa/xb2/xcd/xb4/xc2/x14/x00/x00in/x90/ /x84ZUDl/xa9/xa7/xc3c/xcb-/x80/xfc/x87{d8B6=B/xdb/rfy/xc0/r/xc0/xf0/x0e/xfc/ /x1d/xaf/x84/xa7/xbf/xb1/x03/xe1,/x19&/x93/x9a/xd2/x97/x00/x00/x00/x00IEND/ /xaeB`/x82' def getNewImage(): stream = cStringIO.StringIO(getNewData()) return ImageFromStream(stream) def getNewBitmap(): return BitmapFromImage(getNewImage()) class ToolbarFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, 'Toolbars', size=(300, 200)) panel = wx.Panel(self) panel.SetBackgroundColour('White') statusBar = self.CreateStatusBar() toolbar = self.CreateToolBar() toolbar.AddSimpleTool(wx.NewId(), getNewBitmap(), "New", "Long help for 'New'") toolbar.Realize() def OnCloseMe(self, event): self.Close(True) def OnCloseWindow(self, event): self.Destroy() if __name__ == '__main__': app = wx.PySimpleApp() frame = ToolbarFrame(parent=None, id=-1) frame.Show() app.MainLoop()

 

你可能感兴趣的:(编程,Stream,Class,import,工具,wxPython)