Hi, In order to use PNG files with RubyTk I need to import the 'tkimg' library (or so I'm told). However, every time I do so, I get an error message and it fails to import. In IRB I get the following: > require 'tk' => true > require 'tkextlib/tile' => true > require 'tkextlib/tkimg' RuntimeError: TkPackage can't find package Img from C:/Ruby193/lib/ruby/1.9.1/tk/package.rb:86:in `rescue in require' from C:/Ruby193/lib/ruby/1.9.1/tk/package.rb:83:in `require' from C:/Ruby193/lib/ruby/1.9.1/tkextlib/tkimg.rb:16:in `<top (required)>' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from (irb):4 from C:/Ruby193/bin/irb:12:in `<main>' I've looked inside the tkextlib folder and poked around with the tkimg.rb and within the tkimg folder with no success. I'm currently using ruby 1.9.3p429 via the windows ruby installer (http://rubyinstaller.org/downloads/) I've tried the newest 2.0 (both x86 and x64 versions) as well with no luck. I've also installed the Active Tcl (even though I don't think it's necessary) Anyone know how to fix this?
on 2013-06-06 01:27
on 2013-06-06 04:27
Hi, From: Ryan Braun <firstname.lastname@example.org> Subject: RubyTk - tkimg fails to import? Date: Thu, 6 Jun 2013 08:27:20 +0900 Message-ID: <email@example.com> >> require 'tkextlib/tkimg' > RuntimeError: TkPackage can't find package Img It means that Ruby/Tk cannot find *Tcl/Tk's* Img extension package. Each library under "tkextlib/" requires to install each extension package of Tcl/Tk. # "tile" library is an exception from those. # Originaly, "tile" is not a standard library. # But now (Tcl/Tk8.4 or later), "tile" is one of the standard libraries. Probably, you use Tcl/Tk libraries included in a RubyInstaller. Those has standard libraries only. Please install the "Img" extension library to your Tcl/Tk installed by the RubyInstaller, or use ActiveTcl-8.4 (or ActiveTcl-8.5 which overwrites ActiveTcl-8.4 to use extensions on ActiveTcl-8.4) on your Ruby/Tk. You can check supported extensions on your Ruby/Tk by "ruby C:/Ruby193/lib/ruby/1.9.1/tkextlib/pkg_checker.rb". If pkg_checker.rb reports "FAIL" by "[name, :package]" for an extension, it means that your Tcl/Tk libraries cannot find the "name" extension. # "Fail to require an extension package" is one of the FAQs of Ruby/Tk. ;-)
on 2013-06-06 20:32
Hey, Thanks for the response. Did not expect to get a response from the guy who wrote the extensions lol. And yes, I used the WindowsRubyInstaller that came with Tk bindings. However, it says it's using version 8.5.12 >> require 'tk' => true >> p = Tk::TK_PATCHLEVEL "8.5.12" In any case, I understand what you are trying to say, but how do I actually go about "installing" the extension? The WindowsRubyInstaller only creates a tk and tkextlib folder which already have the tkimg.rb and tkimg folders. I'm guessing I have to add tkimg to the tcltklib.so file? I've installed ActiveTcL-8.5 but it doesn't not do anything. I've tried replacing tcltklib.so with one that includes extra extensions (found it one some website). It seems to work (no errors) however I still could not get any PNG images to appear: I stopped getting error messages and no instant crashes, however the picture would never load. Thanks again for the response... Been researching this for the past few days with little success.
on 2013-06-06 21:31
Hi, From: Ryan Braun <firstname.lastname@example.org> Subject: Re: RubyTk - tkimg fails to import? Date: Fri, 7 Jun 2013 03:32:31 +0900 Message-ID: <email@example.com> > And yes, I used the WindowsRubyInstaller that came with Tk bindings. > However, it says it's using version 8.5.12 In this case, it is not important. Please see "c:\Ruby193\lib\tcltk" folder. Probably, you can find Tcl/Tk libraries which installed by RubyInstaller. Those are pure Tcl/Tk. Ruby/Tk links the Tcl/Tk interpreter. To use a Tcl/Tk extension library, the Tcl/Tk interpreter must be able to load the extension. For example, "tkextlib/tkimg.rb" is a wrapper to control "Img" extention. So, to use it, the Tcl/Tk interpreter linked to Ruby must be able to load the extension. The Tcl/Tk interpreter installed by RubyInstaller checks "c:\Ruby193\lib\tcltk" folder as a library search path. Then, you must put Tcl/Tk extension libraries, which you want use on Ruby/Tk, under the folder. Please see "c:\Ruby193\lib\tcltk" folder, again. You'll be able to find core (standard) tcl and tk libraries, and standard extensions (DDE and register access) for Windows. And you will not be able to find Img extention. > I've installed ActiveTcL-8.5 but it doesn't not do anything. If you find Img extension ("Img1.x" folder) at "c:\Tcl\lib", please copy it to "c:\Ruby193\lib\tcltk". Unfortunately, if you don't have "Img1.x", please get it from ActiveTcl-8.4. The extension libraries included in ActiveTcl-8.4 (not included ActiveTcl-8.5) are comaptible with ActiveTcl-8.5. # If you want to use other extionsions, you can add them by same way. Or, remove tcl85.dll and tk85.dll from "c:\Ruby193\bin". Then, your ruby will use the Tcl/Tk libraries on ActiveTcl.
on 2013-06-07 08:22
Hey, I copied the "Img1.x" folder to "ruby2.0.0/lib/tcltk" and then ran the pkg_checker.rb and it recognized the tkimg extension. Just fiddles with it and I can say that it works 100% Thank you so much for the help. I copied the "Img188.8.131.52" folder (from C:/Tcl/lib) into my "tcltk" folder (Ruby2.0.0/lib/tcltk"). I haven't tried the other method but it might be easier to just install ActiveTcl and delete the dll's so that Ruby defaults to the ActiveTcl installation (has a lot of extensions).