LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Python Add Image (https://www.linuxquestions.org/questions/programming-9/python-add-image-114122/)

Gerardoj 11-09-2003 12:14 PM

Python Add Image
 
Hi, I would like some help to add an image to my button, this is my toolbar code: Python code:

Code:

self.toolbar = Frame(self.window)
       
        self.new = Button(self.toolbar, text="New", width=6, command=self.new, relief=RIDGE)
        self.new.pack(side=LEFT, padx=2, pady=2)

Thanks a lot.

runen 11-09-2003 03:41 PM

Look at http://www.nmt.edu/tcc/help/lang/python/tkinter.pdf - A tkinter reference (I assume that's what you're using).

I think you have to add a bitmap option in the creation of the button. Where the value of bitmap= is a bitmap, perhaps created by Canvas?? Look it up!

Gerardoj 11-09-2003 04:24 PM

Thanks for your reply, I added with

self.toolbar = Frame(self.window)
image=PhotoImage(file='/home/neo/Images/new.gif')

self.new = Button(self.toolbar,image=image,width=40, command=self.new, relief=RIDGE)
self.new.pack(side=LEFT, padx=2, pady=2)


self.toolbar.pack(side=TOP, fill=X)
self.window.mainloop()


All times are GMT -5. The time now is 04:17 PM.