compatible image type

G

gordon

hi
in my application a file selection by user returns a pathname string
like F:/images/png/my.png or F:/docs/text/somedoc.txt ....etc.
I can get the extension using
extn=string.split(os.path.basename(pathname),'.' )[1]

then later on i want to create a Photoimage using

ImageTk.PhotoImage(file=pathname) and display it on a canvas.

the extn can be anything ..even zip or bat ,doc whatever depending on
user selection...I want to put someway to raise an error message to
the user if he selects a file with extension not of a compatible image
type for PhotoImage.How should i do this? should i check 'extn' to a
list of compatible image type extensions(something like
[''jpg','jpeg','png','gif'...] ) or is there a better way?

gordon
 
M

Marc 'BlackJack' Rintsch

then later on i want to create a Photoimage using

ImageTk.PhotoImage(file=pathname) and display it on a canvas.

the extn can be anything ..even zip or bat ,doc whatever depending on
user selection...I want to put someway to raise an error message to
the user if he selects a file with extension not of a compatible image
type for PhotoImage.How should i do this? should i check 'extn' to a
list of compatible image type extensions(something like
[''jpg','jpeg','png','gif'...] ) or is there a better way?

Just catch the exception raised by `PhotoImage` if a non compatible file
was selected!?

Ciao,
Marc 'BlackJack' Rintsch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top