[wxPython-users] add a toolbar to a frame
C M
cmpython at gmail.com
Tue Jul 31 19:21:28 PDT 2007
On 7/31/07, yadin Bocuma Rivas <conra2004 at yahoo.com> wrote:
>
> hi everery one
> I Need help on getting examles of how to create a toolbar with images
> 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!
> what is it with the IMAGES? do i have to create them, load them...? or
> they come with python like in Matlab
> thank you.
Below find your code a little modified. What I did here was make it grab an
image for a tool from some sample_image.gif
that you put on your desktop to get you started. You also had frame.show(1)
when it should be frame.Show(). You can
read more about wx.Image at
http://www.wxpython.org/docs/api/wx.Image-class.html
So, this seems to work now:
#--------------------------------------------------------------------------=
---------
import wx
#modules =3D{} (this just lets it run with Boa)
class MainWindow(wx.Frame):
def __init__(self,parent,id,title):
self.dirname=3D''
wx.Frame.__init__(self,parent,wx.ID_ANY, title,
wx.DefaultPosition, wx.Size(320,410))
##############_______________________ADDING A
TOOLBAR___________________######################
toolbar =3D wx.ToolBar(self, -1, style=3Dwx.TB_HORIZONTAL |
wx.NO_BORDER)
toolbar.DoAddTool(bitmap=3Dwx.Bitmap(u'C:/Documents and
Settings/user/Desktop/sample_image.gif',
wx.BITMAP_TYPE_JPEG), bmpDisabled=3Dwx.NullBitmap,
id=3D-1, kind=3Dwx.ITEM_NORMAL, label=3D'tool',
longHelp=3D'', shortHelp=3D'john')
toolbar.Realize()
app =3D wx.PySimpleApp()
frame =3D MainWindow(None, -1, " dipole antenna ")
frame.Show()
frame.SetBackgroundColour('light grey')
app.MainLoop()
#-------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200707=
31/ed79986f/attachment.htm
More information about the wxpython-users
mailing list