Error in trying to locate bitmaps files

Robert Cragie rcc at nospamthanks_jennic.com
Wed May 10 07:08:53 EDT 2000


I think this is more to do with trying to run a Tkinter app. in IDLE which
is itself a Tkinter app. (note: I tried full path name, and setting cwd with
os.chdir() - neither worked.)

If you run this from the command line (with the correct environment vars.
set), then it runs fine. It also runs OK from PythonWin. I'd suggest you
change IDE if you want to run any of the examples in John Grayson's book.

Robert

Fanny Yeung <fannyy at idmail.com> wrote in message
news:JsuQ4.23396$H7.1386826 at brie.direct.ca...
| Hi,
| It is me again with similar problem but this time is coming from
PhotoImage
| can not find the file (lumber.gif). I try full path and even put @ before
it
| but it still can't create the image. Any idea.
|
|
| from Tkinter import *
|
| root = Tk()
| .........
| photo=PhotoImage(file='lumber.gif')
| text.image_create(END, image=photo)
| text.insert(END, 'I dare you to click on this\n', 'bite')
| text.pack(side=LEFT)
| scroll.pack(side=RIGHT, fill=Y)
|
| root.mainloop()
|
|
|
| Traceback (innermost last):
|   File "E:\PROGRA~1\Python\Tools\idle\ScriptBinding.py", line 131, in
| run_module_event
|     execfile(filename, mod.__dict__)
|   File "E:\Program Files\Python\Tkinter
| Programming\Examples\chapter04\text.py", line 23, in ?
|     photo=PhotoImage(file='lumber.gif')
|   File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1874, in
| __init__
|     apply(Image.__init__, (self, 'photo', name, cnf, master), kw)
|   File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1839, in
| __init__
|     self.tk.call(('image', 'create', imgtype, name,) + options)
| TclError: can't invoke "image" command:  application has been destroyed
|
| Thanks again.
|
| Mak
|
| Fanny Yeung <fannyy at idmail.com> wrote in message
| news:7P5Q4.21796$H7.1348779 at brie.direct.ca...
| > Hi Robert,
| > I hardcode the full path and it is working now.
| > Thank for your help.
| >
| > Mak
| > Robert Cragie <rcc at nospamthanks_jennic.com> wrote in message
| > news:newscache$dbpztf$hqb$1 at jenpc07.jennic.co.uk...
| > > The syntax of 'bitmap=@<filename>' goes straight to Tk, therefore
| > appending
| > > to sys.path won't make any difference . A snippet from the Tk help
file
| > says
| > > this:
| > >
| > > <snippet>
| > > @fileName
| > >
| > > FileName must be the name of a file containing a bitmap description in
| the
| > > standard X11 or X10 format
| > > </snippet>
| > >
| > > Unfortunately, that doesn't help me much either; maybe some other kind
| > soul
| > > can help.
| > >
| > > If you specify the full path for the file it works, e.g. on my machine
| > >
| > > Label(f2,bitmap='@C:\\Program
| > >
| Files\\Python\\src\\Grayson\\examples\\chapter04\\bitmaps\\woman',text="My
| > > second label in tk",relief=RAISED).pack(side=LEFT, padx=5)
| > >
| > > works OK. That's why the example works - the pathname is valid
relative
| to
| > > where the application is run.
| > >
| > > A word of warning - if you're trying to enter things interactively in
| > IDLE,
| > > you can get unstuck with Tkinter apps. as IDLE is written using
Tkinter
| as
| > > well. The most notable thing is NOT to call the mainloop() method in
| IDLE.
| > > Also, I have found some problems with some of the examples if you are
| > using
| > > Python Megawidgets 0.8.3 - there are some subtle differences between
0.8
| > and
| > > 0.8.3.
| > >
| > > Robert
| > >
| > > Fanny Yeung <fannyy at idmail.com> wrote in message
| > > news:e6RP4.21542$H7.1329941 at brie.direct.ca...
| > > | Hi everyone,
| > > |
| > > | I am new in python and just bough "python and tkinter programming"
BY
| > John
| > > | Grayson. As I go thru some example, I run into the following error
| when
| > it
| > > | try to create a label.
| > > |
| > > | >>> Label(f2,bitmap='@bitmaps/woman',text="My second label in
| > > | tk",relief=RAISED).pack(side=LEFT, padx=5)
| > > | Traceback (innermost last):
| > > |   File "<pyshell#34>", line 1, in ?
| > > |     Label(f2,bitmap='@bitmaps/woman',text="My second label in
| > > | tk",relief=RAISED).pack(side=LEFT, padx=5)
| > > |   File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1410,
in
| > > | __init__
| > > |     Widget.__init__(self, master, 'label', cnf, kw)
| > > |   File "E:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1084,
in
| > > | __init__
| > > |     self.tk.call(
| > > | TclError: error reading bitmap file "bitmaps\woman"
| > > |
| > > | I have python 1.5 and Tcl 8 installed in my NT machine. I think is
| > related
| > > | to configuration but I just don't have any idea on how to trace this
| > > | problem.
| > > |
| > > | Thanks in advance.
| > > |
| > > | Mak
| > > |
| > > |
| > >
| > >
| >
| >
|
|





More information about the Python-list mailing list