Tk on Windows and Mac OS X 10.6

Is it possible to install Ruby Tk bindings on Windows with
RubyInstaller, and on Mac OS X 10.6, without recompiling Ruby? I've
seen a few sites that explain how to recompile Ruby on each platform
to use Tk, but so far it looks like that's the only way.

Eric Christopherson wrote:

Is it possible to install Ruby Tk bindings on Windows with
RubyInstaller, and on Mac OS X 10.6, without recompiling Ruby?

I'm not sure about MaxOSX, but for Windows:

  http://wiki.github.com/rdp/ruby_tutorials_core/tk

The "Availability" section says you just have to install ActiveState's
package and everything will work fine.

···

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

There is a project which could make use of Tk with ruby much easier :
    GitHub - manveru/ffi-tk: FFI bindings to the Tk GUI toolkit
It use ffi, so there is no specific binding to compile. You just need
to have the tcl/tk lib available.

  gem install ffi-tk

I'm not sure if this project is already usable, but it could be
**the**
solution for using Tk with Ruby?
It would be great if ffi-tk was afficialy supported by the ruby core.

-- Maurice

···

On 16 fév, 22:33, Eric Christopherson <echristopher...@gmail.com> wrote:

Is it possible to install RubyTkbindings on Windows with
RubyInstaller, and on Mac OS X 10.6, without recompiling Ruby? I've
seen a few sites that explain how to recompile Ruby on each platform
to useTk, but so far it looks like that's the only way.

I did install ActiveTcl on Windows, but afterwards "require 'tk'"
didn't work. It seems that I don't even have the proper Ruby files to
"require". I also never told Ruby where my Tcl/Tk was installed.

···

On Tue, Feb 16, 2010 at 5:57 PM, Albert Schlef <albertschlef@gmail.com> wrote:

Eric Christopherson wrote:

Is it possible to install Ruby Tk bindings on Windows with
RubyInstaller, and on Mac OS X 10.6, without recompiling Ruby?

I'm not sure about MaxOSX, but for Windows:

http://wiki.github.com/rdp/ruby_tutorials_core/tk

The "Availability" section says you just have to install ActiveState's
package and everything will work fine.

I'm not sure about MaxOSX, but for Windows:

  http://wiki.github.com/rdp/ruby_tutorials_core/tk

The "Availability" section says you just have to install ActiveState's
package and everything will work fine.

I've updated the windows section
http://wiki.github.com/rdp/ruby_tutorials_core/tk#windows
with a bit more verbosity on which version has it preinstalled.
-r

···

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

Eric Christopherson wrote:

···

On Tue, Feb 16, 2010 at 5:57 PM, Albert Schlef <albertschlef@gmail.com> > wrote:

package and everything will work fine.

I did install ActiveTcl on Windows, but afterwards "require 'tk'"
didn't work. It seems that I don't even have the proper Ruby files to
"require". I also never told Ruby where my Tcl/Tk was installed.

I vaginally remember having this problem. After I installed
ActiveState's package ruby wasn't able to see Tk's DLL. I believe my
problem had gone after I restarted Windows. Perhaps the folder the DLL
is in is added to Windows' registry somewhere and Windows notes it only
after a restart. I know very little about Windows so this is only a
guess.
--
Posted via http://www.ruby-forum.com/\.

Albert Schlef wrote:

Eric Christopherson wrote:

package and everything will work fine.

I did install ActiveTcl on Windows, but afterwards "require 'tk'"
didn't work. It seems that I don't even have the proper Ruby files to
"require". I also never told Ruby where my Tcl/Tk was installed.

I vaginally remember having this problem.

Wow. I intended to write "vaguely". I had some misspelling ("vagually"),
so I just picked the first suggestion the speller gave me, it looked
like what I wanted. My sight isn't 6/6. Sorry :slight_smile:

···

On Tue, Feb 16, 2010 at 5:57 PM, Albert Schlef <albertschlef@gmail.com> >> wrote:

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

I just installed ActiveTcl, on my home machine this time, and I don't
see any Ruby-specific files in its directory hierarchy. After
rebooting, requiring 'tk' again yielded "LoadError: no such file to
load -- tk", so I think I may be out of luck.

···

On Tue, Feb 16, 2010 at 8:14 PM, Albert Schlef <albertschlef@gmail.com> wrote:

Eric Christopherson wrote:

On Tue, Feb 16, 2010 at 5:57 PM, Albert Schlef <albertschlef@gmail.com> >> wrote:

package and everything will work fine.

I did install ActiveTcl on Windows, but afterwards "require 'tk'"
didn't work. It seems that I don't even have the proper Ruby files to
"require". I also never told Ruby where my Tcl/Tk was installed.

I [vaguely] remember having this problem. After I installed
ActiveState's package ruby wasn't able to see Tk's DLL. I believe my
problem had gone after I restarted Windows. Perhaps the folder the DLL
is in is added to Windows' registry somewhere and Windows notes it only
after a restart. I know very little about Windows so this is only a
guess.

Eric Christopherson wrote:

I just installed ActiveTcl, on my home machine this time, and I don't
see any Ruby-specific files in its directory hierarchy. After
rebooting, requiring 'tk' again yielded "LoadError: no such file to
load -- tk", so I think I may be out of luck.

I've just switched to my Windows box and tried to install Ruby + Tk.

Like you, I've found out that Ruby (of RubyInstaller) doesn't come with
some ruby files necessary to talk with Tk. E.g., it should have a file
C:\Ruby\lib\ruby\1.8\tk.rb (and some more, including a DLL) but it
doesn't have them.

It seems like a change in recent RubyInstallers, because I remember
easily installing Ruby+Tk on Windows in the past.

I'll try to investigate this.

Hidetoshi NAGAI, are you there? Do you know anything about this?

···

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

Albert Schlef wrote:

Like you, I've found out that Ruby (of RubyInstaller) doesn't come with
some ruby files necessary to talk with Tk.

[...]

It seems like a change in recent RubyInstallers, because I remember
easily installing Ruby+Tk on Windows in the past.

It seems I've solved the mystery: "RubyInstaller" doesn't come with Tk
bindings, but Ruby's "One-Click Installer" does. So in the past it was
the latter I was using, not the former.

I'll shut up for a while and let more knowledgeable people than me join
this discussion.

···

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

Message-ID: <a34cd9fcc380dd4e3514bf66803d3837@ruby-forum.com>

It seems like a change in recent RubyInstallers, because I remember
easily installing Ruby+Tk on Windows in the past.

I'll try to investigate this.

Hidetoshi NAGAI, are you there? Do you know anything about this?

I don't know about recent RubyInstallers.

# A kind of troubles on OneClickRuby with ActiveTcl depends on
# the 'Path' environment variable which doesn't include bin (dll)
# folder of ActiveTcl.

I heard tcltklib doesn't work on MacRuby.
But I have no Mac box, and I don't know what kinds of trouble exist
on compiling or running on MacRuby.
So, at present, I cannot develop Ruby/Tk (tcltklib) on MacRuby.

For MacRuby (and JRuby), tk-ffi may be a kind of solutions.
I've thought about using FFI in the past.
And then, I didn't have good idea to treat properly (without C
functions) exceptions on callbacks without break Tcl's event queue.

BTW,
I know that there are many problems to install or distribute Ruby/Tk.
I have a plan to create tcltklib.so includeing a Tcl/Tk environment.
When using such kind of tcltklib.so, Ruby/Tk never load the Tcl/Tk
libraries on the local environment (it means, no need installed Tcl/Tk).
Although it may be a kind of advantage for some people, it loses the
function about easy update of Tcl/Tk libraries (includes using Tcl/Tk
extensions which are installed to local Tcl/Tk environment without
re-create tcltklib.so) working with Ruby/Tk.
Of course, we can make each version of tcltklib.so.

It is based on the idea of Tclkit (Starkit).
If I can, I may try also to write a VFS-like library accessing
directly Tcl's Mk4VFS from Ruby.
The library is used to create a monolitic executable file of Ruby/Tk
application on Windows and Linux (and so on?).
I know that it is a kind of "reinvention of the wheel".
However, I think, it's worth treating Ruby and Tcl/Tk files on one VFS.

···

From: Albert Schlef <albertschlef@gmail.com>
Subject: Re: Tk on Windows and Mac OS X 10.6
Date: Wed, 17 Feb 2010 15:14:28 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Hi,

don't know about MAC; that's what I know for Windows:

You need to have:

* TCL/TK installed (for example, from Active State)
* The _right_ compiled Ruby-TK-Files
* Your ENV-Variable "path" set to the right paths

The Ruby-TK-Files depend on:
* TK-Version (8.4, 8.5; 8.5 probably looks nicer)
* Ruby version
* Compiler, with which Ruby has been complied.

AFAIK, it is sufficient to get the right ruby-files from "somewhere"
and copy them to the
right dirs in the Ruby dir.

I think, Roger Pack recently provided at least two versions of Ruby-
files, but now I can find only one:
* http://github.com/rdp/tk_as_gem

Maybe, you can find links to more here:
* http://groups.google.com/group/rubyinstaller/topics

If you want to compile it yourself with mingw:
* comp.lang.ruby, 2009-12-18, "Ruby 1.8.7 + Tk8.5 with Windows-
RubyInstaller"

If you want to compile it with Microsoft compiler (IMHO, this has
disadvantages regarding other libraries!):
* www.tkdocs.com

Axel

I know that there are many problems to install or distribute Ruby/Tk.
I have a plan to create tcltklib.so includeing a Tcl/Tk environment.
When using such kind of tcltklib.so, Ruby/Tk never load the Tcl/Tk
libraries on the local environment (it means, no need installed Tcl/Tk).
Although it may be a kind of advantage for some people, it loses the
function about easy update of Tcl/Tk libraries (includes using Tcl/Tk
extensions which are installed to local Tcl/Tk environment without
re-create tcltklib.so) working with Ruby/Tk.

In advance, I was unhappy to need to install TCL (~ 23 MB), but
that was the only drawback. Installing ActiveTCL was without problems,
and as far as I understand, the licence is very permissive, even for
commercial use. And I was glad to _easily_ be able to install
additional TCL-libraries via "teacup", for example "plotchart", which
enables me to easily plot simple graphs from within Ruby without
having to deal with gnuplot.

For MRI-Ruby (mingw) despite installing ActiveTCL, I think, you
need only to copy precompiled Ruby/TK-binaries into the right dirs and
set the PATH-variable to the right paths. You need not to compile it
yourself. Can anybody confirm this?

And, from the licences, would it be allowed to freely distibute these
binaries?

If all this is right, I think, it could be easy to install Ruby/TK on
Windows-MRI-mingw-Ruby; IMHO, there are only few things needed:

- A site for uploading and downloading precompiled binaries of Ruby/TK
  (or gem?)
  (Again, from the licences, would it be allowed to freely distibute
  these binaries?)
- A clear statement which binary is for which Ruby-version and
  TCL/TK-version (important).
- A clear description of how the install the downloaded
  Ruby/TK-binaries "copy files to xyz" (installer? gem? Roger Pack did
  something like this...)
- A statement that it is a drawback that you have to install
  AcitveState, but that it is the _only_ drawback and that it takes
  ~23 MB, that it's easy to install, that the licence is permissive
  even for professional use (true?) and that it has the advantage of
  enabling you to install additional packages, for example for
  plotting
- A short description of how to install additional TCL/TK packages
  using "teacup"
- A clear description on how to set the PATH-variable (or do it with
  an installer script?)

If my assumptions are right, I think with the above list it would be
easy to install Ruby/TK on Windows-mingw-MRI-Ruby.

Axel

Message-ID: <20100218.084610.78704908.nagai@ai.kyutech.ac.jp>

I know that there are many problems to install or distribute Ruby/Tk.
I have a plan to create tcltklib.so includeing a Tcl/Tk environment.

Now, you can download test versions of such tcltklib.so
for Linux box from
<http://www.dumbo.ai.kyutech.ac.jp/~nagai/RubyTk/?Ruby%2FTk-Kit&gt;\.
(Sorry. It is a Japanese page.There are download links at mid of the page.)
Each of them includes Tcl/Tk8.4.18, Japanese encodings and tkImg extension.

One is for ruby 1.9.2dev (trunk), and another is for 1.8.8dev (ruby_1_8).
Please rename the downloaded file to tcltklib.so, and replace it
to the original one.

Any comments are welcome.

···

From: Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
Subject: Re: Tk on Windows and Mac OS X 10.6
Date: Thu, 18 Feb 2010 08:46:15 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Message-ID: <1191f673-a6e5-4379-8d95-9e012665be3e@q16g2000yqq.googlegroups.com>

In advance, I was unhappy to need to install TCL (~ 23 MB), but
that was the only drawback. Installing ActiveTCL was without problems,
and as far as I understand, the licence is very permissive, even for
commercial use. And I was glad to _easily_ be able to install
additional TCL-libraries via "teacup", for example "plotchart", which
enables me to easily plot simple graphs from within Ruby without
having to deal with gnuplot.

On your environment only or machines under your control, it's no problem.
As you say (me too), it is the best way to use Ruby (and Ruby/Tk).
However, if you must run your application on other environment
without proper version of Tcl/Tk, you may have some troubles.
I think that a monolithic tcltklib.so library is one of the solutions
to avoid such kind of troubles.
It doesn't replace current binary style of tcltklib.so on Ruby/Tk.
It is a new(?) binary style of tcltklib.so, which merges a Tcl/Tk
environment as a virtual file system.
When you load it on Ruby, you can use Ruby/Tk without installing Tcl/Tk.
It need not write files to the local disk excluding temporal DLL files
to load.

Probably, the tool will contain a base tcltklib.so library,
a work environment (a file tree), and commands for packing/unpacking.

# Maybe, I merge some codes to Ruby/Tk to support such feature.

When you want to use additional Tcl/Tk libraries,
you need copy the libraries to the work environment and pack it to
the "tcltklib.so" file.
To copy the libraries, you maybe able to use TEAcup.
And probably, you'll be able to test your application working with
the monolitic tcltklib.so by running it on the work environment.

# If it is available to pack Ruby binary and environment by similar
# way, we can get a single executable file include all environment.

And, from the licences, would it be allowed to freely distibute these
binaries?

Hmm..., I've not thought about the licenses.
Probably, it will depend on Tcl/Tk, Metakit, tclvfs, Tclkit (Starkit),
libraries packed with, and so on.

# I'm sorry, if my poor english cannot explain exactly.

···

From: Axel <a99.googlegroups.a99@dfgh.net>
Subject: Re: Tk on Windows and Mac OS X 10.6
Date: Thu, 18 Feb 2010 21:30:16 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

On your environment only or machines under your control, it's no problem.
As you say (me too), it is the best way to use Ruby (and Ruby/Tk).
However, if you must run your application on other environment
without proper version of Tcl/Tk, you may have some troubles.

That's true. Would OCRA solve this problem?

I think that a monolithic tcltklib.so library is one of the solutions
to avoid such kind of troubles.
...
# way, we can get a single executable file include all environment.

Sounds to me like a very good solution; but sounds like very difficult
and time-consuming, too.

> And, from the licences, would it be allowed to freely distibute these
> binaries?

I meant, for example, I've compiled Ruby/Tk with mingw, for a certain
version of Ruby and TK; would it be allowed to give these files to
everybody by download? Or, do you know, are there licence issues which
don't allow or restrict this?

Axel

Message-ID: <e349167a-2928-448f-b330-410a968db43d@g26g2000yqn.googlegroups.com>

That's true. Would OCRA solve this problem?

Maybe. My plan is not only one. It's one of the solutions.

> I think that a monolithic tcltklib.so library is one of the solutions
> to avoid such kind of troubles.
> ...
> # way, we can get a single executable file include all environment.

Sounds to me like a very good solution; but sounds like very difficult
and time-consuming, too.

Probably, not easy. But it will not so difficult as you think.
By using Tclkit and some experiments, I've already succeeded to make
a tcltklib.so merged a Tcl/Tk environment and create a TclTkIp object
with Tk (of course, the version of Tcl/Tk is the one of the merged) on
Ruby with the tcltklib.so.

> > And, from the licences, would it be allowed to freely distibute these
> > binaries?
I meant, for example, I've compiled Ruby/Tk with mingw, for a certain
version of Ruby and TK; would it be allowed to give these files to
everybody by download? Or, do you know, are there licence issues which
don't allow or restrict this?

Although I'm not well informed about licences, I think that you can
distribute the package or binary with the same restrict as the Tcl/Tk
package or binary created by Tclkit or Starkit.

···

From: Axel <a99.googlegroups.a99@dfgh.net>
Subject: Re: Tk on Windows and Mac OS X 10.6
Date: Fri, 19 Feb 2010 00:12:08 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Probably, not easy. But it will not so difficult as you think.
By using Tclkit and some experiments, I've already succeeded to make
a tcltklib.so merged a Tcl/Tk environment and create a TclTkIp object
with Tk (of course, the version of Tcl/Tk is the one of the merged) on
Ruby with the tcltklib.so.

Great!

Thank you for your efforts!

Axel

Great, if it is possible, it would be *the* definitive solution for Tk
with Ruby.

If you have a recipe on how to build this full Ruby/Tk distrib from
sources, I could test it on Macosx and some linux.
These source would be :
- ruby-1.9xxx
- tcltk-8.5xxx or tcltk-8.6xxx

My idea would be to create a stand alone ruby sumo distrib (rubylab ?)
with Ruby + Tk + Qt + FFI + some science selected extensions.
(This would be the last alternative before switching from Ruby to
Pihton :frowning: )

But as I'm not very clever in compilation, this will take some
time...

Cordialement,
-- Maurice

···

On Feb 18, 11:56 pm, Hidetoshi NAGAI <na...@ai.kyutech.ac.jp> wrote:

> > I think that a monolithic tcltklib.so library is one of the solutions
> > to avoid such kind of troubles.
> > ...

Probably, not easy. But it will not so difficult as you think.
By using Tclkit and some experiments, I've already succeeded to make
a tcltklib.so merged a Tcl/Tk environment and create a TclTkIp object
with Tk (of course, the version of Tcl/Tk is the one of the merged) on
Ruby with the tcltklib.so.

Maybe. My plan is not only one. It's one of the solutions.

> > I think that a monolithic tcltklib.so library is one of the solutions
> > to avoid such kind of troubles.
> > ...
> > # way, we can get a single executable file include all environment.

One more thought, on my feeling from what I read in this newsgroup
about Ruby/Tk on Windows:
_Until_ a very good solution is available, I think, it would be good
to have a clear description on how to install Ruby/Tk on Windows,
using for example ActiveTCL, and having binaries for download.
Something like Roger Pack provides, but even more.

Axel