how to add a toolbar to a Frame using wxpython

yadin conra2004 at yahoo.com
Tue Jul 31 09:24:18 EDT 2007


hi
please am learning wxpython and I Need help on getting examles of how
to create a toolbar with images
that is add a toolbar to a Frame using wxpython
using wxpython on a windows pc
how can i add a toolbar to a GUI
all sample codes i could find contain errors.
i did the following but it is wrong!
my biggest trouble seems to be with the IMAGES? do i have to create
them, load them...? or they come with python like in Matlab
thank you.

import wx

from pylab import*

class MainWindow(wx.Frame):
        def __init__(self,parent,id,title):
            self.dirname=''
            wx.Frame.__init__(self,parent,wx.ID_ANY,
title,wx.DefaultPosition, wx.Size(320,410))

            ##############_______________________ADDING A
TOOLBAR___________________######################

            toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL |
wx.NO_BORDER)
            toolbar.AddSimpleTool(1, wx.Image('stock_new.png',
wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'New', '')
            toolbar.Realize()
            Frame.Add(toolbar, 0, border=5)

app = wx.PySimpleApp()
frame = MainWindow(None, -1, " dipole antenna ")
frame.show(1)
frame.SetBackgroundColour('light grey')
app.MainLoop()




More information about the Python-list mailing list