Bitmaps On Buttons ?

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Tue Mar 15 04:27:00 EST 2005


PGMoscatt wrote:
> I am slowly progressing with my python app.
> 
> I have got to the point where I would like to place images onto my buttons. 
> I use Tkinter as my GUI libary.
> 
> The following is how I understand I place an image onto a button - but I am
> not having much success with it all.
> 
> Any ideas ?
> 
> Pete
> 
> b=Button(ToolBar,padx=1,pady=1,width=2,height=1,command=callquit,)
> b.bitmap="@button_cancel.xbm"
> b.place(x=0,y=0)
> 

put the bitmap= inside the construction of the button widget like so:

b = Button(ToolBar, padx=1, pady=1, width=2, height=1, command=callquit,
     bitmap="@button_cancel.xbm")

BTW  You shouldn't need to set the height and width - the button will
take it's size from the bitmap

BTW2  I notice you are using place geometry manager you may get a 
'better' behaved GUI with the pack or grid geometry manager, it will
resize much better as widgets are pack'ed or grid'ed relative to each other

for more help you could try:

http://www.pythonware.com/library/tkinter/introduction/

or the Wiki that has links to other sources of help (including the
Tkinter mailing list

http://tkinter.unpythonic.net/wiki/FrontPage

Cheers
Martin







More information about the Python-list mailing list