tk image problem

C

Charles Hixson

--------------010303010904080009000109
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

When I attempt to read in xpm files created by the Gimp, I get
"/usr/lib/ruby/1.8/tk.rb:2020:in `__invoke': couldn't recognize data in
image file " errors. If it's a gif file, the program works without at
hitch.

It's just a simple test I threw together because I wanted to convert
another program from Gtk to Tk (so it would run on a stock Mac), but I
guess it's a somewhat decent example, so here goes:
(The image files would make this altogether too long, but they open in
the Gimp, in Konqueror, and in Mozilla without a hitch....Well, Mozilla
didn't handle it internally, but referred to an application called
display, which I'd never encountered before...but it was "sort of"
without a hitch. Apparently Mozilla doesn't recognize XPM files. And
the same was true of Konqueror, which really surprised me. But KView
and Kuickshow opened it without complaint.)

Does anyone have any ideas what's going on here?




--------------010303010904080009000109
Content-Type: text/plain;
name="test6.rb~"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="test6.rb~"

require "tk"

# widget demo directory
cur_dir = File.dirname($0)
dat_dir = [cur_dir, "..", "data"].join(File::SEPARATOR)
top = TkRoot.new {title "Label and Entry Window"}

$setTopBackFlag = false
def setTopBack(t, b, image1, image2)
nxtColor = sprintf("\#%06x", rand(0xffff))
puts "nxtColor = #{nxtColor}"
$setTopBackFlag = !$setTopBackFlag
btnImage = $setTopBackFlag ? image1 : image2
t.configure("background"=>"#{nxtColor}")
b.configure("image"=>btnImage)
end

# add the label
lb1 = TkLabel.new(top) do
text "Hello World"
background "yellow"
foreground "blue"
place("relx"=>0.0, "rely"=>0.0)
end # lb1

# add the entry
e1 = TkEntry.new(top) do
background "red"
foreground "blue"
place("relx"=>0.5, "rely"=>0.93)
end # e1

# add a button
image1Fil = [dat_dir, "n3d.gif"].join(File::SEPARATOR)
image2Fil = [dat_dir, "n4d.gif"].join(File::SEPARATOR)
image1 = TkPhotoImage.new {file image1Fil}
image2 = TkPhotoImage.new {file image2Fil}
#image_w = TkPhotoImage.new
b1 = TkButton.new(top) do
text "submit"
image image1
command lambda{setTopBack(top, b1, image1, image2)}
place("relx"=>0.1, "rely"=>0.5)
end

Tk.mainloop

--------------010303010904080009000109--
 
H

Hidetoshi NAGAI

From: Charles Hixson <[email protected]>
Subject: tk image problem
Date: Wed, 1 Jun 2005 10:41:50 +0900
Message-ID: said:
When I attempt to read in xpm files created by the Gimp, I get
"/usr/lib/ruby/1.8/tk.rb:2020:in `__invoke': couldn't recognize data in
image file " errors. If it's a gif file, the program works without at
hitch.

man n photo ;-)
Standard Tk library supports PPM/PGM/GIF on photo images.
If you want to treat XPM on Ruby/Tk, please use Tcl/Tk's Img extension.
It adds supports for BMP/JPEG/PNG/XBM/XPM and so on.
 
C

Charles Hixson

Hidetoshi said:
From: Charles Hixson <[email protected]>
Subject: tk image problem
Date: Wed, 1 Jun 2005 10:41:50 +0900


man n photo ;-)
Standard Tk library supports PPM/PGM/GIF on photo images.
If you want to treat XPM on Ruby/Tk, please use Tcl/Tk's Img extension.
It adds supports for BMP/JPEG/PNG/XBM/XPM and so on.
That sounds like you know the right answer...but I don't understand it.
Can you point to any documentation of Tcl/Tk's Img extension? Google
produced some links, but they seem to be implying that this won't work
on a vanilla installation. (I'm not really certain, as they were really
talking about something else...but that's what it sounded like.) If
this is correct, then I guess I must convert all of my images to gif
files. (This isn't horrendous, but I prefer that the images be
something I can look at with a text editor.)
 
H

Hidetoshi NAGAI

From: Charles Hixson <[email protected]>
Subject: Re: tk image problem
Date: Thu, 2 Jun 2005 06:42:25 +0900
Message-ID: said:
That sounds like you know the right answer...but I don't understand it.
Can you point to any documentation of Tcl/Tk's Img extension? Google
produced some links, but they seem to be implying that this won't work
on a vanilla installation.

Official page of Img ext is <http://sourceforge.net/projects/tkimg>.
README file of Img extension says "Not done yet" on Mac.
---< from README file >------------
PLATFORMS
tested:
Linux 2.0.30 (gcc, egcs)
IRIX 6.2 (cc, 32 bits only)
ULTRIX 4.1 (cc, gcc, egcs)
ULTRIX 4.4 (cc 3.0)
HP-UX-9 (cc, gcc, egcs)
HP-UX-10.2 (gcc, egcs)
SunOS-4.1.2 (cc)
Solaris 2.5 (gcc, egcs)
FreeBSD 2.2 (gcc, egcs)
Windows 95/98/NT(gcc-2.95/MS Visual C++ 4.2/5.0/6.0)

Not done yet:
Mac ) someone interested
VMS ) to try??????

Other machines and OS's should work too.
-----------------------------------
However, source archive of Img ext includes "imgMacProject.sit.hqx"
and "pkgIndex.mac".
Although I don't know about Mac, I think that it possibly work on Mac.

# If about Tcl/Tk Aqua <http://tcltkaqua.sourceforge.net/>, its binary
# distribution includes Img ext.

I'm sorry that I cannot show enough information.
 
C

Charles Hixson

Hidetoshi said:
From: Charles Hixson <[email protected]>
Subject: Re: tk image problem
Date: Thu, 2 Jun 2005 06:42:25 +0900


Official page of Img ext is <http://sourceforge.net/projects/tkimg>.
README file of Img extension says "Not done yet" on Mac.
---< from README file >------------
PLATFORMS
tested:
Linux 2.0.30 (gcc, egcs)
IRIX 6.2 (cc, 32 bits only)
ULTRIX 4.1 (cc, gcc, egcs)
ULTRIX 4.4 (cc 3.0)
HP-UX-9 (cc, gcc, egcs)
HP-UX-10.2 (gcc, egcs)
SunOS-4.1.2 (cc)
Solaris 2.5 (gcc, egcs)
FreeBSD 2.2 (gcc, egcs)
Windows 95/98/NT(gcc-2.95/MS Visual C++ 4.2/5.0/6.0)

Not done yet:
Mac ) someone interested
VMS ) to try??????

Other machines and OS's should work too.
-----------------------------------
However, source archive of Img ext includes "imgMacProject.sit.hqx"
and "pkgIndex.mac".
Although I don't know about Mac, I think that it possibly work on Mac.

# If about Tcl/Tk Aqua <http://tcltkaqua.sourceforge.net/>, its binary
# distribution includes Img ext.

I'm sorry that I cannot show enough information.
No real problem. Gifs will work fine, I just prefer xpms.
 

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,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top