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--
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--