The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Add Image
Discuss Add Image in the Python Programming forum on Dev Shed. Add Image Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 9th, 2003, 12:12 AM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
|
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.
|

November 9th, 2003, 02:44 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
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.
__________________
programming language development: www.netytan.com – Hula
|

November 9th, 2003, 12:43 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
|
Thanks, I change it for self.toolbar = Frame(self.window).
but how can I add a simple icon to the button, Thanks again
|

November 9th, 2003, 12:47 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
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
|

November 9th, 2003, 04:00 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
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()
|

November 9th, 2003, 07:51 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Location: Somewhere over the Rainbow
Posts: 128
Time spent in forums: 3 h 54 m 28 sec
Reputation Power: 10
|
|
|
Thanks to all, I fixed, now is working fine.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|