I am using the wiki tutorial to try to learn wxruby. I have programmed
the
windows interface many times. The first two samples ran fine, but now
I am
on the icon frame and need a little help. I am aware that I could
replace
the offending path with a hard coded one, but do not want to do that.
I have 50 years programming experience but no experience with ruby or
other
modern scripting languages.
The code found near the bottom of
http://wxruby.rubyforge.org/wiki/wiki.pl?Frames_(Part_1)
is copied below.
My current OS is
Windows XP
service pack 3
version 2002
AMD processor
2.50 gig of ram.
When I run the RubyMine debugger I get the following error.
Uncaught exception: Icon file does not exist: ./icons/wxwin.ico
If I search my machine I find the file at
C:\Ruby192\lib\ruby\gems\1.9.1\gems\wxruby-ruby19-2.0.1-x86-mingw32\samples\bigdemo\icons
How do I change the line highlighted in red below so that ruby will
find
this file?
---------------------------------Code
require “rubygems”
require “wx”
ID_ICON = 1000
class IconFrame < Wx::Frame
def initialize
super(nil, -1, “Changing Icons!”, Wx::DEFAULT_POSITION,
Wx::Size.new(225,150))
panel = Wx::Panel.new(self, -1)
iconNames = [“wxwin”, “mondrian”, “ogl”, “smiley”]
icons = Wx::RadioBox.new(panel, ID_ICON, “&Icons”,
Wx::Point.new(20,5),
Wx::DEFAULT_SIZE, iconNames, 1,
Wx::RA_SPECIFY_COLS)
evt_radiobox(ID_ICON) {|event| on_change_icon(event)}
if Wx::PLATFORM == “WXMSW”
Wx::Icon.new(“./icons/wxwin.ico”, Wx::BITMAP_TYPE_ICO)
else
Wx::Icon.new(“./icons/wxwin16x16.xpm”, Wx::BITMAP_TYPE_XPM)
end
show(true) #true is the default value, so it may be left off
end
def on_change_icon(event)
if Wx::RUBY_PLATFORM == "WXMSW"
case event.get_int #(get_int is deprecated)
when 0
set_icon(Wx::Icon.new("./icons/wxwin.ico"))
when 1
set_icon(Wx::Icon.new("./icons/mondrian.ico"))
when 2
set_icon(Wx::Icon.new("./icons/ogl.ico"))
when 3
set_icon(Wx::Icon.new("./icons/smiley.ico"))
end
else
case event.get_int
when 0
set_icon(Wx::Icon.new("./icons/wxwin16x16.xpm"))
when 1
set_icon(Wx::Icon.new("./icons/mondrian.xpm"))
when 2
set_icon(Wx::Icon.new("./icons/ogl.xpm"))
when 3
set_icon(Wx::Icon.new("./icons/smiley.xpm"))
end
end
end
end
class MinimalApp < Wx::App
def on_init
IconFrame.new
end
end
MinimalApp.new.main_loop
----------------------end of
code------------------------------------------------
–
Ann M.
[email protected]