|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
Add Image
Hi, I would like some help to add an image to my button, this is my toolbar 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. |
|
#2
|
||||
|
||||
|
Mmmmm.. does this work for you because i don't see how it could
![]() Self.toolbar should be self.toolbar (thats the main problem) and the wierd indentation is gonna make Python puke if you feed this too it ![]() Mark. |
|
#3
|
||||
|
||||
|
Thanks, I change it for self.toolbar = Frame(self.window).
but how can I add a simple icon to the button, Thanks again |
|
#4
|
||||
|
||||
|
Code:
from Tkinter import * root = Tk() myimage = PhotoImage(file='myimage.gif') button = Button(root, image=myimage) button.pack() root.mainloop()
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
|
#5
|
||||
|
||||
|
Thanks, I added the image in the toolbar, but now I have a problem, Im making a Text editor when I add self.root.mainloop() the text editor disappear, and when I remove it, the text editor appears and the image disappear. What could be the problem?
Code:
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()
|
|
#6
|
||||
|
||||
|
Thanks to all, I fixed, now is working fine.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Add Image |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|