Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2142 > unrolled thread

Tk and Tile with Tk8.5

Started byLászló Földes <foldes.laszlo2@gmail.com>
First post2011-04-01 19:45 -0500
Last post2011-04-05 15:37 -0500
Articles 10 — 3 participants

Back to article view | Back to comp.lang.ruby


Contents

  Tk and Tile with Tk8.5 László Földes <foldes.laszlo2@gmail.com> - 2011-04-01 19:45 -0500
    Re: Tk and Tile with Tk8.5 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> - 2011-04-01 22:39 -0500
      Re: Tk and Tile with Tk8.5 László Földes <foldes.laszlo2@gmail.com> - 2011-04-02 16:38 -0500
        Re: Tk and Tile with Tk8.5 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> - 2011-04-02 18:57 -0500
    Re: Tk and Tile with Tk8.5 Albert Schlef <albertschlef@gmail.com> - 2011-04-02 21:30 -0500
      Re: Tk and Tile with Tk8.5 László Földes <foldes.laszlo2@gmail.com> - 2011-04-03 15:52 -0500
        Re: Tk and Tile with Tk8.5 Albert Schlef <albertschlef@gmail.com> - 2011-04-04 07:57 -0500
          Re: Tk and Tile with Tk8.5 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> - 2011-04-04 17:16 -0500
            Re: Tk and Tile with Tk8.5 Albert Schlef <albertschlef@gmail.com> - 2011-04-05 09:13 -0500
              Re: Tk and Tile with Tk8.5 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> - 2011-04-05 15:37 -0500

#2142 — Tk and Tile with Tk8.5

FromLászló Földes <foldes.laszlo2@gmail.com>
Date2011-04-01 19:45 -0500
SubjectTk and Tile with Tk8.5
Message-ID<07a7e2ba2709d9e19d380257946e93e6@ruby-forum.com>
I want to use Ruby 1.9.1 (Ubuntu 10.10) with Tk8.5 Tile, but this samle
code:

require 'tk'
require 'tkextlib/tile'

root = TkRoot.new { title "Ex1" }

Tk::Tile::Button.new(root) {
  text "Ok"
  command proc { print "Hello, World!"; exit }
  pack('side'=>'left', 'padx'=>10, 'pady'=>10)
}

Tk.mainloop()

fails with:
$ ruby tk_test.rb
/usr/lib/ruby/1.9.1/tkextlib/tile.rb:46:in `rescue in <top (required)>':
undefined method `__cannot_find_tk_package_for_widget_set__' for
Tk:Module (NoMethodError)
  from /usr/lib/ruby/1.9.1/tkextlib/tile.rb:31:in `<top (required)>'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from <internal:lib/rubygems/custom_require>:29:in `require'
  from tk_test.rb:2:in `<main>'


Googleing for "__cannot_find_tk_package_for_widget_set__" is one of
those rare moments when Google gives back only 1 hit.
Am I doing something wrong? I'm not a source code compiler type, I
installed everything from aptitude (Ruby 1.9.1, Tk8.4, Tk8.5, Tcl8.4,
Tcl8.5)

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [next] | [standalone]


#2144

FromHidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Date2011-04-01 22:39 -0500
Message-ID<20110402.123737.74750971.nagai@ai.kyutech.ac.jp>
In reply to#2142
Hi, 

Thank you for your report.

From: László Földes <foldes.laszlo2@gmail.com>
Subject: Tk and Tile with Tk8.5
Date: Sat, 2 Apr 2011 09:45:24 +0900
Message-ID: <07a7e2ba2709d9e19d380257946e93e6@ruby-forum.com>
> I want to use Ruby 1.9.1 (Ubuntu 10.10) with Tk8.5 Tile, but this samle
> code:
   (snip)
> fails with:
> $ ruby tk_test.rb
> /usr/lib/ruby/1.9.1/tkextlib/tile.rb:46:in `rescue in <top (required)>':
> undefined method `__cannot_find_tk_package_for_widget_set__' for
> Tk:Module (NoMethodError)

I'm very sorry. It's a bug which should be fixed.
But it is not a primary problem for your trouble.
If tile extension is installed (or Tcl/Tk is 8.5 or later), 
Ruby/Tk doesn't use the bugged routine.

> Am I doing something wrong? I'm not a source code compiler type, I
> installed everything from aptitude (Ruby 1.9.1, Tk8.4, Tk8.5, Tcl8.4,
> Tcl8.5)

Probably, your ruby's tcltklib.so is linked with Tcl/Tk8.4.
Please check the result of 'ruby -r tk -e "p Tk::TK_PATCHLEVEL"'.
If it shows 8.4.x, your tcltklib.so uses libraries of Tcl/Tk8.4.

To fix it, please install tile extension for your Tcl/Tk8.4, 
or re-compile your ruby's tcltklib.so with Tcl/Tk8.5.
I'm not familiar with Ubuntu. So, I don't know which is better.
If igonore it, I recommend you to re-compile tcltklib.so, 
because Tcl/Tk8.5 is better than Tcl/Tk8.4.
-- 
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology

[toc] | [prev] | [next] | [standalone]


#2166

FromLászló Földes <foldes.laszlo2@gmail.com>
Date2011-04-02 16:38 -0500
Message-ID<3b1577c8d8c9ba00d570d173f5896515@ruby-forum.com>
In reply to#2144
> Please check the result of 'ruby -r tk -e "p Tk::TK_PATCHLEVEL"'.
> If it shows 8.4.x, your tcltklib.so uses libraries of Tcl/Tk8.4.
>
And indeed it is:
$ ruby -r tk -e "p Tk::TK_PATCHLEVEL"
"8.4.19"

> or re-compile your ruby's tcltklib.so with Tcl/Tk8.5.

Back to the "I'm not a source code compiler type", can you give me some 
hint, how to do this? (not the 'make install' entry, but can it be 
independently recompiled from source or only together with other files 
or I need to recompile the whole Ruby package. And most importantly, 
what are the parameters that make it link to Tk8.5?)

Thanks

I tried to replace tcltklib.so with your 
tcltklib.so-tk8.5.7-ruby192dev_20100313rev26900_i686-linux but that .so 
introduced other unsatisfied dependencies (like libstdc++.so.5)

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#2170

FromHidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Date2011-04-02 18:57 -0500
Message-ID<20110403.085726.74744345.nagai@ai.kyutech.ac.jp>
In reply to#2166
From: László Földes <foldes.laszlo2@gmail.com>
Subject: Re: Tk and Tile with Tk8.5
Date: Sun, 3 Apr 2011 06:38:47 +0900
Message-ID: <3b1577c8d8c9ba00d570d173f5896515@ruby-forum.com>
> > Please check the result of 'ruby -r tk -e "p Tk::TK_PATCHLEVEL"'.
> > If it shows 8.4.x, your tcltklib.so uses libraries of Tcl/Tk8.4.
> >
> And indeed it is:
> $ ruby -r tk -e "p Tk::TK_PATCHLEVEL"
> "8.4.19"

Are there tk-tile package for Tcl/Tk8.4 on Ubuntu 10.10 ?
If it exists, please try to install the package.

> > or re-compile your ruby's tcltklib.so with Tcl/Tk8.5.
> 
> Back to the "I'm not a source code compiler type", can you give me some 
> hint, how to do this? (not the 'make install' entry, but can it be 
> independently recompiled from source or only together with other files 
> or I need to recompile the whole Ruby package. And most importantly, 
> what are the parameters that make it link to Tk8.5?)

First of all, I'm not familiar with Debian packages.
So, I can't tell you how to create your own Ruby/Tk package with Tcl/Tk8.5.

In general, extconf.rb of tcltklib (<ruby-src-dir>/ext/tk/extconf.rb)
searches automatically the latest version of Tcl/Tk on the system.
If you are luky ;-), you'll be able to make a new ruby by 
"cd <ruby-src-dir>; ./configure; make". 
# Of course, it requires Tcl/Tk dev packages.

Please check the messages of make steps.
tcltklib's extconf.rb shows the status of searching Tcl/Tk libraries.
If it shows fail messages, you must give configure options.
Please see <ruby-src-dir/ext/tk/README.tcltklib. It describes
configure options to teach position of Tcl/Tk libs to extconf.rb.
Although there are many combinations of options to match several env, 
please try to give --with-tclConfig-file=<path of tclConfig.sh> and 
--with-tkConfig-file=<path of tkConfig.sh> at first.

If you have some trouble, please tell me the fail messages and the
position of your Tcl/Tk headers and libraries.

> I tried to replace tcltklib.so with your 
> tcltklib.so-tk8.5.7-ruby192dev_20100313rev26900_i686-linux but that .so 
> introduced other unsatisfied dependencies (like libstdc++.so.5)

Sorry. It was compiled on an old environment (gcc-3.3).
Even if it is available, I don't recommnd partial replace of package files.
It may break the package management system.
-- 
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology

[toc] | [prev] | [next] | [standalone]


#2174

FromAlbert Schlef <albertschlef@gmail.com>
Date2011-04-02 21:30 -0500
Message-ID<c764e2404317aaffc33a263308b40263@ruby-forum.com>
In reply to#2142
László Földes wrote in post #990509:
> I want to use Ruby 1.9.1 (Ubuntu 10.10) with Tk8.5 Tile, but this samle
> code:
> [...]
> I'm not a source code compiler type, I
> installed everything from aptitude (Ruby 1.9.1, Tk8.4, Tk8.5, Tcl8.4,
> Tcl8.5)

Hi!

I'm using Ubuntu 10.04.1, but it probably isn't different than yours.

You need install tile:

  $ sudo apt-get install tk-tile

Note that Ruby will still use the ugly Tk 8.4. If you want it to use Tk
8.5 (but you don't have to), follow these steps:

  http://drx.rubyforge.org/ubuntu-new-tk.html

BTW, your program works on my system: I tried it with both Tk 8.4 and Tk
8.5 (I have a script that toggles between them).

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#2217

FromLászló Földes <foldes.laszlo2@gmail.com>
Date2011-04-03 15:52 -0500
Message-ID<fa24aa47c77b093188147e2ac0fd3973@ruby-forum.com>
In reply to#2174
Albert Schlef wrote in post #990613:
>
>   http://drx.rubyforge.org/ubuntu-new-tk.html
>
> BTW, your program works on my system: I tried it with both Tk 8.4 and Tk
> 8.5 (I have a script that toggles between them).

Thanks, that solved it!

Just for curiosity, how do you toggle between the two? As I saw it the 
Tk version is compiled into the tcltklib.so.

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#2268

FromAlbert Schlef <albertschlef@gmail.com>
Date2011-04-04 07:57 -0500
Message-ID<9fc745ebe20dd2e019f14c70fe9da7c4@ruby-forum.com>
In reply to#2217
László Földes wrote in post #990721:
> Albert Schlef wrote in post #990613:
>>
>>   http://drx.rubyforge.org/ubuntu-new-tk.html
>>
>> BTW, your program works on my system: I tried it with both Tk 8.4 and Tk
>> 8.5 (I have a script that toggles between them).
>
> Thanks, that solved it! (although the solution at the link has some
> serious überbug, although not irreparable).

What's the "überbug"? Tell us, so that page (ubuntu-new-tk.html) could 
be fixed.

>
> Just for curiosity, how do you toggle between the two? As I saw it the
> Tk version is compiled into the tcltklib.so.

Right. I copy the 8.4 version into "tcltklib.so.84", and the 8.5 version 
into "tcltklib.so.85", and my script simply copies the desired version 
into "tcltklib.so". (To do this it uses the 'sudo' command because the 
/usr/lib/ruby/1.8/i486-linux/ directory is writable for root only.)

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#2284

FromHidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Date2011-04-04 17:16 -0500
Message-ID<20110405.071609.74742611.nagai@ai.kyutech.ac.jp>
In reply to#2268
From: Albert Schlef <albertschlef@gmail.com>
Subject: Re: Tk and Tile with Tk8.5
Date: Mon, 4 Apr 2011 21:57:34 +0900
Message-ID: <9fc745ebe20dd2e019f14c70fe9da7c4@ruby-forum.com>
> > Just for curiosity, how do you toggle between the two? As I saw it the
> > Tk version is compiled into the tcltklib.so.
> 
> Right. I copy the 8.4 version into "tcltklib.so.84", and the 8.5 version 
> into "tcltklib.so.85", and my script simply copies the desired version 
> into "tcltklib.so". (To do this it uses the 'sudo' command because the 
> /usr/lib/ruby/1.8/i486-linux/ directory is writable for root only.)

The following depend on an unofficial feature of ruby's dll loading.
At present, it will work. But I don't recomment it.

# I asked about the feature on ruby-dev ML. But I didn't discuss it.
# Because I didn't have enough time for discussion and I thought 
# that there are not many people who requires such feature.

In the following, <dll-dir> denotes ruby's dll directory
(.e.g /usr/lib/ruby/1.8/i486-linux).

(1) Copy the 8.4 version to <dll-dir>/tcltklib.8.4.so, and the 8.5
    version to <dll-dir>/tcltklib.8.5.so.
    Filenames must start by "tcltklib" + dot, and end by dot + "so".
    For example, "tcltklib.84.so" or "tcltklib.8.4.19.so" is OK, 
    but "tcltklib_84.so" or "tcltklib.so.84" is NG.

(2) Create loader script "tcltklib.rb" at ruby's library directory
    (.e.g /usr/lib/ruby/1.8).
    For example, 
    ----- tcltklib.rb -----------------------------------------
    ver = ENV['RUBYTK_VERSION']
    if ver && !ver.empty?
      require "tcltklib.#{ver}.so"
    else
      require "tcltklib.so"
    end
    -----------------------------------------------------------
    This exmaple selects the dll based on the environment variable.
    There are many way to decide the target dll.
    Please create your tcltklib.rb as you like.

(3) If you use tcltklib.rb at step (2), 
    $ RUBYTK_VERSION=8.4 ruby -r tk -e 'p Tk::TK_PATCHLEVEL'
    will use tcltklib.8.4.so (Tcl/Tk8.4 version), and
    $ RUBYTK_VERSION=8.5 ruby -r tk -e 'p Tk::TK_PATCHLEVEL'
    will use tcltklib.8.5.so (Tcl/Tk8.5 version)
-- 
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology

[toc] | [prev] | [next] | [standalone]


#2345

FromAlbert Schlef <albertschlef@gmail.com>
Date2011-04-05 09:13 -0500
Message-ID<556a229f4b3527c589df7da1a9695e2f@ruby-forum.com>
In reply to#2284
Hidetoshi NAGAI wrote in post #990904:
> The following depend on an unofficial feature of ruby's dll loading.
> At present, it will work. But I don't recomment it.
> [...]
> (2) Create loader script "tcltklib.rb" at ruby's library directory
>    (.e.g /usr/lib/ruby/1.8).
>    For example,
>    ----- tcltklib.rb -----------------------------------------
>    ver = ENV['RUBYTK_VERSION']
>    if ver && !ver.empty?
>      require "tcltklib.#{ver}.so"
>    else
>      require "tcltklib.so"
>    end

Hey, that's a nice trick. Thanks!

> The following depend on an unofficial feature of ruby's dll loading.
> At present, it will work. But I don't recomment it.

BTW, what's here isn't an official feature? I do "ri Kernel#require" and 
(I think) it describes everything needed to make this work: Ruby first 
looks for an .rb file (this enables us to inject our loader script), and 
then it's possible to explicitly load a .so (or .dll). So why isn't your 
trick future-proof?

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#2363

FromHidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Date2011-04-05 15:37 -0500
Message-ID<20110406.053728.74724230.nagai@ai.kyutech.ac.jp>
In reply to#2345
From: Albert Schlef <albertschlef@gmail.com>
Subject: Re: Tk and Tile with Tk8.5
Date: Tue, 5 Apr 2011 23:13:53 +0900
Message-ID: <556a229f4b3527c589df7da1a9695e2f@ruby-forum.com>
> > The following depend on an unofficial feature of ruby's dll loading.
> > At present, it will work. But I don't recomment it.
> 
> BTW, what's here isn't an official feature? I do "ri Kernel#require" and 
> (I think) it describes everything needed to make this work: Ruby first 
> looks for an .rb file (this enables us to inject our loader script), and 
> then it's possible to explicitly load a .so (or .dll). So why isn't your 
> trick future-proof?

It depends on "how to find an entry point function of a DLL".
Ruby's current DLL loader decides a name from a filename of DLL, 
that is, cuts a left most string from a DLL filename before first dot
and links it after a string "Init_".
So, for "tcltklib.so", "tcltklib.84.so", "tcltklib.8.5.9.so" and so
on, the loader calls a function "Init_tcltklib()".
But for "tcltklib_84.so" (and others), the loader tries and fails to
call a function "Init_tcltklib_84".
This is the reason of why a DLL filename is limitted on my trick.

The rule about "first dot" is NOT a specification of Ruby's DLL loader.
It may be changed in the future.
-- 
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web