Tk on Windows and Mac OS X 10.6

  • Thread starter Eric Christopherson
  • Start date
E

Eric Christopherson

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.
 
E

Eric Christopherson

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

=A0http://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 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.
 
A

Albert Schlef

Eric said:
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.
 
A

Albert Schlef

Albert said:
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 :)
 
E

Eric Christopherson

Eric said:
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.

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.
 
A

Albert Schlef

Eric said:
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?
 
A

Albert Schlef

Albert said:
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.
 
A

Axel

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
 
M

mdiam

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.

There is a project which could make use of Tk with ruby much easier :
http://github.com/manveru/ffi-tk
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
 
H

Hidetoshi NAGAI

From: Albert Schlef <[email protected]>
Subject: Re: Tk on Windows and Mac OS X 10.6
Date: Wed, 17 Feb 2010 15:14:28 +0900
Message-ID: said:
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.
 
A

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
 
H

Hidetoshi NAGAI

From: Axel <[email protected]>
Subject: Re: Tk on Windows and Mac OS X 10.6
Date: Thu, 18 Feb 2010 21:30:16 +0900
Message-ID: said:
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.
 
A

Axel

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.


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
 
H

Hidetoshi NAGAI

From: Axel <[email protected]>
Subject: Re: Tk on Windows and Mac OS X 10.6
Date: Fri, 19 Feb 2010 00:12:08 +0900
Message-ID: said:
That's true. Would OCRA solve this problem?

Maybe. My plan is not only one. It's one of the solutions.
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.
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.
 
A

Axel

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
 
M

mdiam

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, 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 :-( )

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

Cordialement,
-- Maurice
 
S

saLOUt

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 :-( )

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

Cordialement,
-- Maurice

Didn't read everything. Just want to mention that there will be a Qt-
Ruby-Gem for Windows release very soon. For Linux there should be pre-
build packages available for most common distributions.

First adress for ruby + Qt/KDE: http://lists.kde.org/?l=kde-bindings

Robert
 
R

Roger Pack

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 :-( )

The only real cross platform distro I'm aware of is "rawr" for jruby.
If all you need is swing or the eclipse swt you're good to go (there's
examples of ruby wrapping the swt in the redcar project).
-r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top