can any body help me to add icons to the toolbar, i know that we have to use PhotoImage class to add but i'm not able to see the image in the toolbar. here is the code which i wrote,

the following code is not an error, but im not getting the icon displayed.
please help me out.

from Tkinter import *

def callback():
   print "tool bar button."

p=PhotoImage("calculator")  #its icon which is same directory where the my .py exists

b=Button(tool,text="New", width=15, height=15,image=p, command=callback)
bb=Button(tool, width=6,text="Open", command=callback)

tool.pack(side=TOP, fill=X)


The PhotoImage class can only read GIF and PGM/PPM images from files. If you had an image file called calculator.gif in your working directory, you would use ...


Also add something like compound=TOP to your button() to let tk know where your image is in relation to your text.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.