tkinter icons as bytestrings, not files?
Peter Billam
peter at www.pjb.com.au
Mon Feb 23 23:56:12 EST 2009
Greetings,
As a newbie, starting with Python3, I'm working my way through Mark
Summerfield's tkinter examples. In the toolbar, there's lines like:
for image, command in (
('images/filenew.gif', self.fileNew),
('images/fileopen.gif', self.fileOpen),
('images/filesave.gif', self.fileSave),
('images/editadd.gif', self.editAdd),
('images/editedit.gif', self.editEdit),
('images/editdelete.gif', self.editDelete),):
image = os.path.join(os.path.dirname(__file__), image)
image = tkinter.PhotoImage(file=image)
self.toolbar_images.append(image)
button = tkinter.Button(toolbar, image=image, command=command)
button.grid(row=0, column=len(self.toolbar_images) -1)
which are always failing because the icons are in the wrong place
and I can't help but wonder if I can put all these little images
in the application itself, either as b'whatever' or uuencoded or
in svg etc, and then invoke some suitable variation of the
image = tkinter.PhotoImage(file=image)
or of the
button = tkinter.Button(toolbar, image=image, command=command)
command ? (I did try help('tkinter.PhotoImage') but didn't spot a
magic key (unless it's "data=something, format=something")) ...
Regards, Peter
--
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html
More information about the Python-list
mailing list