Пример #1
0
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Toolbars',
                size=(300, 200))
        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour('White')
        statusBar = self.CreateStatusBar()
        toolbar = self.CreateToolBar()
        toolbar.AddSimpleTool(wx.NewId(), images.getNewBitmap(),
                "New", "Long help for 'New'")
        toolbar.Realize()
        menuBar = wx.MenuBar()
        menu1 = wx.Menu()
        menuBar.Append(menu1, "&File")
        menu2 = wx.Menu()
        menu2.Append(wx.NewId(), "&Copy", "Copy in status bar")
        menu2.Append(wx.NewId(), "C&ut", "")
        menu2.Append(wx.NewId(), "Paste", "")
        menu2.AppendSeparator()
        menu2.Append(wx.NewId(), "&Options...", "Display Options")
        menuBar.Append(menu2, "&Edit")

        menu3 = wx.Menu()
        shell = menu3.Append(-1, "&Python shell",
                             "Open Python shell frame")
        filling = menu3.Append(-1, "&Namespace viewer",
                               "Open namespace viewer frame")
        menuBar.Append(menu3, "&Debug")
        self.Bind(wx.EVT_MENU, self.OnShell, shell)
        self.Bind(wx.EVT_MENU, self.OnFilling, filling)

        self.SetMenuBar(menuBar)
Пример #2
0
    def __init__(self, parent, id, title):
        print "Frame __init__"
        print wx.ID_LOWEST, wx.ID_HIGHEST
        wx.Frame.__init__(self, parent, id, title, size=(300, 100))

        # added close button
        panel = wx.Panel(self)
        statusBar = self.CreateStatusBar()
        toolBar = self.CreateToolBar()
        toolBar.AddSimpleTool(wx.NewId(), images.getNewBitmap(), "New", "Long helo for 'New'")
        toolBar.Realize()
        menuBar = wx.MenuBar()
        menu1 = wx.Menu()
        menuBar.Append(menu1, "File")
        menu2 = wx.Menu()
        menu2.Append(wx.NewId(), "Copy", "copy in the status bar")
        menu2.Append(wx.NewId(), "Cut", "cut")
        menu2.AppendSeparator()
        menu2.Append(wx.NewId(), "Options...", "Display Options")
        menuBar.Append(menu2, "E&dit")
        self.SetMenuBar(menuBar)

        button = wx.Button(panel, label="close", pos=(125, 10), size=(50, 50))
        self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
Пример #3
0
 def __init__(self, parent, id):
     wx.Frame.__init__(self, parent, id, 'Toolbars', size=(300, 300))
     panel = wx.Panel(self)
     #Play with background colour
     panel.SetBackgroundColour('White')
     statusBar = self.CreateStatusBar()
     toolbar = self.CreateToolBar()
     #?? How does this work. What does it do. Can't I just insert an image
     #Adding a tool to the toolbar
     #Arguments = (Id, a bitmap, short help text, long help text)
     toolbar.AddSimpleTool(wx.NewId(), images.getNewBitmap(), "New",
                           "Long help for 'New'")
     #US spellings URGH
     toolbar.Realize()
     menuBar = wx.MenuBar()
     menu1 = wx.Menu()
     menuBar.Append(menu1, "&File")
     menu2 = wx.Menu()
     menu2.Append(wx.NewId(), "&Copy", "Copy in status bar")
     menu2.Append(wx.NewId(), "C&ut", "")
     menu2.Append(wx.NewId(), "Paste", "")
     menu2.AppendSeparator()
     menu2.Append(wx.NewId(), "&Options...", "Display Options")
     menuBar.Append(menu2, "&Edit")
     self.SetMenuBar(menuBar)
Пример #4
0
 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(),
                           images.getNewBitmap(),
                           "New",
                           "Long help for 'New'")
     toolbar.Realize()
     self.SetMenuBar(build_menu_bar())
Пример #5
0
 def __init__(self, parent):
     wx.Frame.__init__(self, parent, -1,"CHARTS", size=(1000,600), pos=(50,50))
     self.parent = parent
     self.embed = False
     self.grid = parent.grid
     self.CreateStatusBar()
     #self.SetStatusText('SalStat Statistics')
     self.chartObject = ChartObject()
     NewIcon = images.getNewBitmap()
     OpenIcon = images.getOpenBitmap()
     SaveIcon = images.getSaveBitmap()
     PrintIcon = images.getPrintBitmap()
     EmbedIcon = images.getPrintBitmap()
     toolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER| \
                                 wx.TB_3DBUTTONS | wx.TB_TEXT)
     #ToolNew = wx.ToolBarToolBase(toolBar)
     #toolBar.AddTool(10, NewIcon,"New")
     toolBar.AddLabelTool(10, "New", wx.Bitmap("icons/IconNew.png"), shortHelp="Create a new chart")
     toolBar.AddLabelTool(20, "Open", wx.Bitmap("icons/IconOpen.png"), shortHelp="Open a data file")
     toolBar.AddLabelTool(30, "Save", wx.Bitmap("icons/IconSave.png"), shortHelp="Save these data to file")
     toolBar.AddLabelTool(50, "Print", wx.Bitmap("icons/IconPrint.png"), shortHelp="Print this sheet")
     toolBar.AddLabelTool(70, "Embed", wx.Bitmap("icons/IconEmbed.png"), shortHelp="Embed this chart with the rest of your results")
     """
     toolBar.AddSimpleTool(10, NewIcon,"New")
     toolBar.AddSimpleTool(20, OpenIcon,"Open")
     toolBar.AddSimpleTool(30, SaveIcon,"Save")
     toolBar.AddSimpleTool(50, PrintIcon,"Print")
     toolBar.AddSimpleTool(70, EmbedIcon, "Embed")
     """
     toolBar.SetToolBitmapSize((24,24))
     toolBar.Realize()
     self.SetToolBar(toolBar)
     self.charthtml = """<!DOCTYPE html>\n<html>\n<head>\n<script src="html/jquery/1.8.2/jquery.min.js"></script>\n\t\t<script src="html/highcharts/3.0.7/highcharts.js"></script>\n\t\t<script src="html/bootstrap/2.3.1/bootstrap.min.js"></script>\n\t\t<link href="html/bootstrap/2.3.1/bootstrap-combined.min.css" rel="stylesheet" media="screen">\n\t\t<script src="html/highcharts/3.0.7/exporting.js"></script>\n\t\t<script src="html/js/themes/gray.js"></script></script>\n\t<style>\n\t\tbody { font-family: helvectica, arial, \'lucida sans\'; }\n\t</style>\n</head>\n<body>\n"""
     self.webview = html2lib.WebView
     self.preview = self.webview.New(self) #, size=(100,100))
     self.preview.SetSize
     self.control = ControlPanel(self, -1, self.chartObject, self.preview, self.grid)
     # Windows crash not before here...
     if self.grid:
         self.variables = VarPanel(self, -1, self.grid, self.chartObject)
     else:
         self.variables = VarPanel(self, -1, None, self.chartObject)
     # ...but IS before here!
     self.box = wx.BoxSizer(wx.HORIZONTAL)
     self.box.Add(self.variables, 0, wx.EXPAND)
     self.box.Add(self.preview, 1, wx.EXPAND)
     self.box.Add(self.control, 0, wx.EXPAND)
     self.SetAutoLayout(True)
     self.SetSizer(self.box)
     self.Layout()
     wx.EVT_TOOL(self, 70, self.EmbedChart)
Пример #6
0
    def __init__(self, parent, log):
        wx.Frame.__init__(
            self, parent, -1, 'Test ToolBar', wx.DefaultPosition, (500, 300)
            )

        self.log = log

        win = wx.Window(self, -1)
        win.SetBackgroundColour("WHITE")
        wx.StaticText(
            win, -1, "Drag the toolbar to float it,\n"  
            "Toggle the last tool to remove\nthe title.", (15,15)
            )

        tb = wx.lib.floatbar.FloatBar(self, -1)
        self.SetToolBar(tb)
        tb.SetFloatable(1)
        tb.SetTitle("Floating!")
        self.CreateStatusBar()

        tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)

        tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)

        tb.AddSeparator()
        tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)

        tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)

        tb.AddSeparator()

        tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap())
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60)

        tb.Realize()

        self.tb = tb
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
Пример #7
0
    def __init__(self, parent, log):
        wx.Frame.__init__(self, parent, -1, 'Test ToolBar', wx.DefaultPosition,
                          (500, 300))

        self.log = log

        win = wx.Window(self, -1)
        win.SetBackgroundColour("WHITE")
        wx.StaticText(
            win, -1, "Drag the toolbar to float it,\n"
            "Toggle the last tool to remove\nthe title.", (15, 15))

        tb = wx.lib.floatbar.FloatBar(self, -1)
        self.SetToolBar(tb)
        tb.SetFloatable(1)
        tb.SetTitle("Floating!")
        self.CreateStatusBar()

        tb.AddSimpleTool(10, images.getNewBitmap(), "New",
                         "Long help for 'New'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)

        tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)

        tb.AddSeparator()
        tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)

        tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)

        tb.AddSeparator()

        tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap())
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60)

        tb.Realize()

        self.tb = tb
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
Пример #8
0
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'ToolBars', size=(200, 300))
        panel = wx.Panel(self)
        panel.SetBackgroundColour('White')
        statusBar = self.CreateStatusBar()
        toolbar = self.CreateToolBar()
        toolbar.AddSimpleTool(wx.NewId(), images.getNewBitmap(), "New", "Loog help for New")
        toolbar.Realize()
        menuBar = wx.MenuBar()

        menu1 = wx.Menu()
        menuBar.Append(menu1, "File")
        menu2 = wx.Menu()

        menu2.Append(wx.NewId(), "Copy", "Copy in status bar")
        menu2.Append(wx.NewId(), "Cut", "")
        menuBar.Append(menu2, "Edit")
        self.SetMenuBar(menuBar)
Пример #9
0
 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(), images.getNewBitmap(), "New",
                           "Long help for 'New'")
     toolbar.Realize()
     menuBar = wx.MenuBar()
     menu1 = wx.Menu()
     menuBar.Append(menu1, "&File")
     menu2 = wx.Menu()
     menu2.Append(wx.NewId(), "&Copy", "Copy in status bar")
     menu2.Append(wx.NewId(), "C&ut", "")
     menu2.Append(wx.NewId(), "Paste", "")
     menu2.AppendSeparator()
     menu2.Append(wx.NewId(), "&Options...", "Display Options")
     menuBar.Append(menu2, "&Edit")
     self.SetMenuBar(menuBar)
Пример #10
0
 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(),images.getNewBitmap(),"New","Long help for 'New'")
     toolBar.Realize()
     menuBar = wx.MenuBar()
 
     menu1 = wx.Menu()
     menuBar.Append(menu1,'')
     menu2 = wx.Menu()
     menu2.Append(wx.NewId()," ","Copy in status bar")
     menu2.Append(wx.NewId(),"C","")
     menu2.Append(wx.NewId(),"Paste","")
     menuBar.AppendSeparator()
     menu2.Append(wx.NewId()," ","Display Options")
     menuBar.Append(menu2,' ')
     self.SetMenuBar(menuBar)
Пример #11
0
 def __init__(self):
     wx.MDIParentFrame.__init__(self, None, -1, "MDI Parent", 
             size=(600,400))
     
     menu = wx.Menu()
     menu.Append(5000, "&New Window")
     menu.Append(5001, "&Upload Traffic")
     menu.Append(5002, "E&xit")
     menubar = wx.MenuBar()
     menubar.Append(menu, "&File")
     self.SetMenuBar(menubar)
     self.Bind(wx.EVT_MENU, self.OnNewWindow, id=5000)
     self.Bind(wx.EVT_MENU, self.OnExit, id=5002)
     
     # Status bar and Tool bar
     statusBar = self.CreateStatusBar()
     toolbar = self.CreateToolBar()
     toolbar.AddSimpleTool(wx.NewId(), images.getNewBitmap(),
             "New", "Long help for 'New'")
     toolbar.Realize()
Пример #12
0
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Toolbars',
                size=(300,200))
        panel = wx.Panel(self,-1)
        panel.SetBackgroundColour('White')

        statusBar = self.CreateStatusBar()
        toolbar = self.CreateToolBar()
        #?? Are these standardised for use. If so how use.
        toolbar.AddSimpleTool(wx.NewId(), images.getNewBitmap(),
                "New", "Long help for 'New'")
        #Mostly UK spelling, this is one US one
        toolbar.Realize()

        #This is a fake menu, it contains nothing but the title on the menubar
        menuBar = wx.MenuBar()
        menu1 = wx.Menu()
        menuBar.Append(menu1, "&File")
        #This is a filled out menu
        menu2 = wx.Menu()
        menu2.Append(wx.NewId(), "&Copy", "Copy in Status Bar")
        menu2.Append(wx.NewId(), "C&ut", "Don't run with scissors")
        menu2.Append(wx.NewId(), "Paste", "No Alt option for this one")
        #i can't spell separator
        menu2.AppendSeparator()
        menu2.Append(wx.NewId(), "&Options...", "Display Options")
        menuBar.Append(menu2, "&Edit")
        #There should normally be a load of bindings here for the menu items

        #new debug menu
        menu3 = wx.Menu()
        shell = menu3.Append(-1, "&wxPython shell", "Open wxPython shell frame")
        filling = menu3.Append(-1, "&Namespace viewer",
                "Open Namespace Viewer frame")
        menuBar.Append(menu3, "&Debug")
        #bindings have missed from previous menus
        self.Bind(wx.EVT_MENU, self.OnShell, shell)
        self.Bind(wx.EVT_MENU, self.OnFilling, filling)

        #Finished the menubar
        self.SetMenuBar(menuBar)
Пример #13
0
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Toolbars', size=(300, 200))
        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour('White')

        statusBar = self.CreateStatusBar()
        toolbar = self.CreateToolBar()
        #?? Are these standardised for use. If so how use.
        toolbar.AddSimpleTool(wx.NewId(), images.getNewBitmap(), "New",
                              "Long help for 'New'")
        #Mostly UK spelling, this is one US one
        toolbar.Realize()

        #This is a fake menu, it contains nothing but the title on the menubar
        menuBar = wx.MenuBar()
        menu1 = wx.Menu()
        menuBar.Append(menu1, "&File")
        #This is a filled out menu
        menu2 = wx.Menu()
        menu2.Append(wx.NewId(), "&Copy", "Copy in Status Bar")
        menu2.Append(wx.NewId(), "C&ut", "Don't run with scissors")
        menu2.Append(wx.NewId(), "Paste", "No Alt option for this one")
        #i can't spell separator
        menu2.AppendSeparator()
        menu2.Append(wx.NewId(), "&Options...", "Display Options")
        menuBar.Append(menu2, "&Edit")
        #There should normally be a load of bindings here for the menu items

        #new debug menu
        menu3 = wx.Menu()
        shell = menu3.Append(-1, "&wxPython shell",
                             "Open wxPython shell frame")
        filling = menu3.Append(-1, "&Namespace viewer",
                               "Open Namespace Viewer frame")
        menuBar.Append(menu3, "&Debug")
        #bindings have missed from previous menus
        self.Bind(wx.EVT_MENU, self.OnShell, shell)
        self.Bind(wx.EVT_MENU, self.OnFilling, filling)

        #Finished the menubar
        self.SetMenuBar(menuBar)
Пример #14
0
    def __init__(self,parent,title,size):
        wx.Frame.__init__(self,parent,-1,title,size = size)
        self.SetBackgroundColour('white')
        
        #布局 size
        self.width = self.Size.width
        self.height = self.Size.height
        self.up = self.Size.height/25*24
        #self.down = self.Size.height/3
        self.left = self.Size.width/4
        self.right = self.Size.width/4*3
        
        #上下结构
        self.spltUD = wx.SplitterWindow(self,size = size,style=
	wx.SP_3DBORDER)
        
        self.winUp = wx.Window(self.spltUD,-1,(0,0),(self.width,self.up))
        self.winUp.SetBackgroundColour('red')

        #self.winDown = wx.Window(self.spltUD,-1,(0,self.up),(self.width,self.down))
        #self.winDown.SetBackgroundColour('black')
        
#        self.spltUD.SplitHorizontally(self.winUp,self.winDown,-5)

        #左右结构
        self.spltLF = wx.SplitterWindow(self.winUp,size = (self.width,self.up))

        self.winLeft = wx.Window(self.spltLF,-1,(0,0),(self.left,self.up))
        self.winLeft.SetBackgroundColour('White')
        
        self.winRight = wx.Window(self.spltLF,-1,(0,self.left),(self.right,self.up))
        self.winRight.SetBackgroundColour('green')
        
        self.spltLF.SplitVertically(self.winLeft,self.winRight,-10)

	panel = wx.Panel(self,-1)
	panel.SetBackgroundColour("White")
	statusBar = self.CreateStatusBar()
	toolbar  = self.CreateToolBar()
	toolbar.AddSimpleTool(wx.NewId(),images.getNewBitmap(),"New","xxxx")
	toolbar.Realize()


        # Create an image list
        il = wx.ImageList(16,16)

        # Get some standard images from the art provider and add them
        # to the image list
        self.fldridx = il.Add(
            wx.ArtProvider.GetBitmap(wx.ART_FOLDER,
                    wx.ART_OTHER, (16,16)))
        self.fldropenidx = il.Add(
            wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN,
                    wx.ART_OTHER, (16,16)))
        self.fileidx = il.Add(
            wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE,
                    wx.ART_OTHER, (16,16)))


	self.tree = wx.TreeCtrl(self.winLeft,id = -1,pos=(0,0),size=self.winLeft.Size) 
	self.tree.AssignImageList(il)
	root = self.tree.AddRoot("数据仓库研发部")
	self.tree.SetItemImage(root, self.fldridx,
                               wx.TreeItemIcon_Normal)
        self.tree.SetItemImage(root, self.fldropenidx,
                               wx.TreeItemIcon_Expanded)

        self.AddTreeNodes(root, data.tree)
        self.tree.Expand(root)


        #事件绑定
        self.Bind(wx.EVT_SIZE,self.OnSize)
Пример #15
0
    def __init__(self, parent, log):
        wx.Frame.__init__(self, parent, -1, 'Test ToolBar', size=(500, 300))
        self.log = log
        self.timer = None
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        wx.Window(self, -1).SetBackgroundColour(wx.NamedColour("WHITE"))

        # Use the wxFrame internals to create the toolbar and associate it all
        # in one tidy method call.
        tb = self.CreateToolBar(wx.TB_HORIZONTAL
                                | wx.NO_BORDER
                                | wx.TB_FLAT
                                | wx.TB_TEXT)

        # Here's a 'simple' toolbar example, and how to bind it using SetToolBar()
        #tb = wx.ToolBarSimple(self, -1, wx.DefaultPosition, wx.DefaultSize,
        #               wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT)
        #self.SetToolBar(tb)
        # But we're doing it a different way here.

        log.write("Default toolbar tool size: %s\n" % tb.GetToolBitmapSize())

        self.CreateStatusBar()

        tb.AddSimpleTool(10, images.getNewBitmap(), "New",
                         "Long help for 'New'")
        #tb.AddLabelTool(10, "New", images.getNewBitmap(), shortHelp="New", longHelp="Long help for 'New'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)

        tb.AddSimpleTool(20, images.getOpenBitmap(), "Open",
                         "Long help for 'Open'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)

        tb.AddSeparator()
        tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy",
                         "Long help for 'Copy'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)

        tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste",
                         "Long help for 'Paste'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)

        tb.AddSeparator()

        tool = tb.AddCheckTool(50,
                               images.getTog1Bitmap(),
                               shortHelp="Toggle this")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=50)

        ##         tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap(),
        ##                         shortHelp="Toggle with 2 bitmaps")
        ##         self.Bind(EVT_TOOL, self.OnToolClick, id=60)

        self.Bind(wx.EVT_TOOL_ENTER, self.OnToolEnter)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick)  # Match all
        self.Bind(wx.EVT_TIMER, self.OnClearSB)

        tb.AddSeparator()
        cbID = wx.NewId()

        tb.AddControl(
            wx.ComboBox(tb,
                        cbID,
                        "",
                        choices=["", "This", "is a", "wxComboBox"],
                        size=(150, -1),
                        style=wx.CB_DROPDOWN))

        self.Bind(wx.EVT_COMBOBOX, self.OnCombo, id=cbID)
        tb.AddControl(wx.TextCtrl(tb, -1, "Toolbar controls!!",
                                  size=(150, -1)))

        # Final thing to do for a toolbar is call the Realize() method. This
        # causes it to render (more or less, that is).
        tb.Realize()
Пример #16
0
    def __init__(self, parent, log):
        wx.Frame.__init__(self, parent, -1, 'Test ToolBar', size=(500, 300))
        self.log = log
        self.timer = None
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

        wx.Window(self, -1).SetBackgroundColour(wx.NamedColour("WHITE"))

        # Use the wxFrame internals to create the toolbar and associate it all
        # in one tidy method call.
        tb = self.CreateToolBar( wx.TB_HORIZONTAL
                                 | wx.NO_BORDER
                                 | wx.TB_FLAT
                                 | wx.TB_TEXT
                                 )

        # Here's a 'simple' toolbar example, and how to bind it using SetToolBar()
        #tb = wx.ToolBarSimple(self, -1, wx.DefaultPosition, wx.DefaultSize,
        #               wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT)
        #self.SetToolBar(tb)
        # But we're doing it a different way here.

        log.write("Default toolbar tool size: %s\n" % tb.GetToolBitmapSize())

        self.CreateStatusBar()

        tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
        #tb.AddLabelTool(10, "New", images.getNewBitmap(), shortHelp="New", longHelp="Long help for 'New'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)

        tb.AddSimpleTool(20, images.getOpenBitmap(), "Open", "Long help for 'Open'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)

        tb.AddSeparator()
        tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy", "Long help for 'Copy'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)

        tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste", "Long help for 'Paste'")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)

        tb.AddSeparator()

        tool = tb.AddCheckTool(50, images.getTog1Bitmap(),
                               shortHelp="Toggle this")
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=50)

##         tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap(),
##                         shortHelp="Toggle with 2 bitmaps")
##         self.Bind(EVT_TOOL, self.OnToolClick, id=60)

        self.Bind(wx.EVT_TOOL_ENTER, self.OnToolEnter)
        self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick) # Match all
        self.Bind(wx.EVT_TIMER, self.OnClearSB)

        tb.AddSeparator()
        cbID = wx.NewId()

        tb.AddControl(
            wx.ComboBox(
                tb, cbID, "", choices=["", "This", "is a", "wxComboBox"],
                size=(150,-1), style=wx.CB_DROPDOWN
                ))
                
        self.Bind(wx.EVT_COMBOBOX, self.OnCombo, id=cbID)
        tb.AddControl(wx.TextCtrl(tb, -1, "Toolbar controls!!", size=(150, -1)))

        # Final thing to do for a toolbar is call the Realize() method. This
        # causes it to render (more or less, that is).
        tb.Realize()