I''ve got wxruby (1.9.5) & rubyscript2exe (0.5.3) installed & I''m using Windows Vista. I''m trying to use rubyscript2exe to turn one of the wxruby sample programs into an .exe. The sample is in the controls folder & is called controls.rb. I use ''rubyscript2exe controls.rb --rubyscript2exe-verbose'' to "compile" it. But when I try to run it I get the following error: Bitmap file does not exist: C:\Users\Matthew\eee\eee.controls.exe.4\app/icons/list.xpm (ArgumentError) Do you have any ideas how I could solve this problem? -- matthew _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Matthew Webb wrote:> I''ve got wxruby (1.9.5) & rubyscript2exe (0.5.3) installed & I''m using > Windows Vista. > > I''m trying to use rubyscript2exe to turn one of the wxruby sample > programs into an .exe. > > The sample is in the controls folder & is called controls.rb. > > I use ''rubyscript2exe controls.rb --rubyscript2exe-verbose'' to > "compile" it. > > But when I try to run it I get the following error: > > Bitmap file does not exist: > C:\Users\Matthew\eee\eee.controls.exe.4\app/icons/list.xpm (ArgumentError)The problem is that the bitmap file isn''t included in the bundled-up package that rubyscript2exe creates and later unpacks when the .exe is run. The simple way is to manually tell rubyscript2exe to add the .xpm file to the bundle. To do this, add a constant to the beginning of the file with an array of files that should be included. RUBYSCRIPT2EXE.dlls = [ ''icons/list.xpm'', ... ] (Or it might be RUBYSCRIPT2EXE.libs = [...] I can''t remember and can''t test it right now. See http://www.erikveen.dds.nl/rubyscript2exe/#3.3.1 ) A more complex but perhaps better way for bigger apps is to build the .exe as normal, then distribute it and the icons packaged up as a zip, a tar, or using an installer like NSIS. Then, at runtime, test if the application is running from within rubyscript2exe, find out where it''s installed, and load image files from that location. Wx::ArtProvider can also help here. An example of this approach below - see the part where it sets WEFT_SHAREDIR http://weft-qda.rubyforge.org/svn/trunk/weft-qda/weft-qda.rb alex
Alex Fenton wrote:> Matthew Webb wrote: > >> I''ve got wxruby (1.9.5) & rubyscript2exe (0.5.3) installed & I''m using >> Windows Vista. >> >> I''m trying to use rubyscript2exe to turn one of the wxruby sample >> programs into an .exe. >> >> The sample is in the controls folder & is called controls.rb. >> >> I use ''rubyscript2exe controls.rb --rubyscript2exe-verbose'' to >> "compile" it. >> >> But when I try to run it I get the following error: >> >> Bitmap file does not exist: >> C:\Users\Matthew\eee\eee.controls.exe.4\app/icons/list.xpm (ArgumentError) >> > The problem is that the bitmap file isn''t included in the bundled-up > package that rubyscript2exe creates and later unpacks when the .exe is run. > > The simple way is to manually tell rubyscript2exe to add the .xpm file > to the bundle. To do this, add a constant to the beginning of the file > with an array of files that should be included. > > RUBYSCRIPT2EXE.dlls = [ ''icons/list.xpm'', ... ] > > (Or it might be RUBYSCRIPT2EXE.libs = [...] > I can''t remember and can''t test it right now. See > http://www.erikveen.dds.nl/rubyscript2exe/#3.3.1 ) > > A more complex but perhaps better way for bigger apps is to build the > .exe as normal, then distribute it and the icons packaged up as a zip, a > tar, or using an installer like NSIS. > > Then, at runtime, test if the application is running from within > rubyscript2exe, find out where it''s installed, and load image files from > that location. Wx::ArtProvider can also help here. An example of this > approach below - see the part where it sets WEFT_SHAREDIR > > http://weft-qda.rubyforge.org/svn/trunk/weft-qda/weft-qda.rb > > alex > > > > > > > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > >It would seem that the problem isn''t ''list.xpm'' not loading but ''mondrian.ico'' not loading. I''ve added the following two lines to the beginning of ''controls.rb''... require "rubyscript2exe" RUBYSCRIPT2EXE.bin = ["mondrian.ico"] When I run the .exe I get this error... Icon file does not exist: C:\Users\Matthew\eee\eee.controls.exe.2\app/mondrian.ico (ArgumentError) It''s really strange because ''mondrian.ico'' is in the same folder as ''Controls.rb'' so I''d expect it to be found. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080328/8e984c10/attachment.html
Matthew Webb wrote:> It would seem that the problem isn''t ''list.xpm'' not loading but > ''mondrian.ico'' not loading. > > I''ve added the following two lines to the beginning of ''controls.rb''... > > require "rubyscript2exe" > RUBYSCRIPT2EXE.bin = ["mondrian.ico"] > > When I run the .exe I get this error... > > Icon file does not exist: > C:\Users\Matthew\eee\eee.controls.exe.2\app/mondrian.ico (ArgumentError) > > It''s really strange because ''mondrian.ico'' is in the same folder as > ''Controls.rb'' so I''d expect it to be found.You''ve put it in the ''bin'' dir of the package, but controls.rb is in the ''app'' dir. controls.rb loads the icon file like this: Icon.new( File.join( File.dirname(__FILE__), "mondrian.ico"), Wx::BITMAP_TYPE_ICO ) i.e. relative to its position. So it looks in the app dir, doesn''t find it and gives the error you saw. You''ll either need to put the icon file somewhere different in the bundle, or change that code. You might find it helpful to unpack the bundle rubyscript2exe creates to see the directory structure. See the page for more details, but basically run it with the argument ---eee-justextract alex
Alex Fenton wrote:> Matthew Webb wrote: > >> It would seem that the problem isn''t ''list.xpm'' not loading but >> ''mondrian.ico'' not loading. >> >> I''ve added the following two lines to the beginning of ''controls.rb''... >> >> require "rubyscript2exe" >> RUBYSCRIPT2EXE.bin = ["mondrian.ico"] >> >> When I run the .exe I get this error... >> >> Icon file does not exist: >> C:\Users\Matthew\eee\eee.controls.exe.2\app/mondrian.ico (ArgumentError) >> >> It''s really strange because ''mondrian.ico'' is in the same folder as >> ''Controls.rb'' so I''d expect it to be found. >> > You''ve put it in the ''bin'' dir of the package, but controls.rb is in the > ''app'' dir. controls.rb loads the icon file like this: > > Icon.new( File.join( File.dirname(__FILE__), "mondrian.ico"), > Wx::BITMAP_TYPE_ICO ) > > i.e. relative to its position. So it looks in the app dir, doesn''t find > it and gives the error you saw. You''ll either need to put the icon file > somewhere different in the bundle, or change that code. > > You might find it helpful to unpack the bundle rubyscript2exe creates to > see the directory structure. See the page for more details, but > basically run it with the argument ---eee-justextract > > alex > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > >Okay I''ve finally managed to fix the problem I was having. I found the following thread regarding rubyscript2exe & image loading... http://objectmix.com/ruby/303278-re-rubyscript2exe-cannot-put-picture-project.html If I rename the controls.rb file to init.rb & then "compile" the entire controls Directory like... C:\Users\Matthew\Desktop>rubyscript2exe controls/ it works fine. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080328/53c59523/attachment.html
Matthew Webb wrote:> Bitmap file does not exist: > C:\Users\Matthew\eee\eee.controls.exe.4\app/icons/list.xpm > (ArgumentError) > > Do you have any ideas how I could solve this problem?The problem is that this script depends on an external file, which rubyscript2exe doesn''t include in the .exe (and therefore not in the eee temp folder). You''ll need to employ a little cleverness to include the resource with the executable. This page talks about including library files for another GUI framework in the .exe, and should be adaptable for including resource files: http://ruby-gnome2.sourceforge.jp/hiki.cgi?tips_rubyscript2exe> require ''rubyscript2exe'' > require ''fileutils'' > require ''pathname'' > > p0 = Pathname.new(RUBYSCRIPT2EXE.appdir) > root_runtime = p0.parent.to_s > begin > FileUtils.cp_r(''run_dep/.'', root_runtime) > rescue > end > > Those lines copy all the files & folders inside the > "run_dep" folder to the folder where rubyscript2exe will > extract your application. The begin/rescue is needed > because that fails when you run your application the first > time in rubyscript2exe, to create the .exe.You''ll of course need to modify the path referenced in the script such that it points to the temp location that the resource gets decompressed to. BTW, overall wxRuby works *beautifully* with rubyscript2exe, which is one of my favorite features about it. -Jay McGavren
Jay McGavren wrote:> Matthew Webb wrote: > >> Bitmap file does not exist: >> C:\Users\Matthew\eee\eee.controls.exe.4\app/icons/list.xpm >> (ArgumentError) >> >> Do you have any ideas how I could solve this problem? >> > > The problem is that this script depends on an external file, which > rubyscript2exe doesn''t include in the .exe (and therefore not in the > eee temp folder). You''ll need to employ a little cleverness to > include the resource with the executable. > > This page talks about including library files for another GUI > framework in the .exe, and should be adaptable for including resource > files: > > http://ruby-gnome2.sourceforge.jp/hiki.cgi?tips_rubyscript2exe > > >> require ''rubyscript2exe'' >> require ''fileutils'' >> require ''pathname'' >> >> p0 = Pathname.new(RUBYSCRIPT2EXE.appdir) >> root_runtime = p0.parent.to_s >> begin >> FileUtils.cp_r(''run_dep/.'', root_runtime) >> rescue >> end >> >> Those lines copy all the files & folders inside the >> "run_dep" folder to the folder where rubyscript2exe will >> extract your application. The begin/rescue is needed >> because that fails when you run your application the first >> time in rubyscript2exe, to create the .exe. >> > > You''ll of course need to modify the path referenced in the script such > that it points to the temp location that the resource gets > decompressed to. > > BTW, overall wxRuby works *beautifully* with rubyscript2exe, which is > one of my favorite features about it. > > -Jay McGavren > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users > > > >Thanks for the advice, I placed the following code at the start of the program... require ''rubyscript2exe'' require ''fileutils'' require ''pathname'' p0 = Pathname.new(RUBYSCRIPT2EXE.appdir) root_runtime = p0.parent.to_s begin FileUtils.cp_r(''run_dep/.'', root_runtime) rescue end I changed this line from... icon_file = File.join( File.dirname(__FILE__), "mondrian.png") to... icon_file = File.join( File.dirname(RUBYSCRIPT2EXE.appdir), "mondrian.png") Then I created a folder called ''run_dep'' where the script was located & I placed the icons in that folder. The script was "compiled" with ''rubyscript2exe minimal.rb --rubyscript2exe-rubyw'' When I executed it the icons loaded & the program worked. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080329/597e2409/attachment.html