installing Tk for Ruby on OS X

P

petermichaux

Hi,

I tried to run the one line script tk.rb

require 'tk'

and saw the following error

$ ruby tk.rb
/usr/local/lib/ruby/1.8/tk.rb:7:in `require': No such file to load --
tcltklib (LoadError)
from /usr/local/lib/ruby/1.8/tk.rb:7
from tk.rb:1:in `require'
from tk.rb:1

I don't know if it matters but I can run the following command without
error

$ tclsh
%

What do I do? Do I install tk as a gem?

Thanks,
Peter
 
T

Tsume

I found this site

http://tcltkaqua.sourceforge.net/

but I don't want to use tk that is specific to aqua. I want to make a
portable gui (Windows, Linux, OS X, ...)

I've not used TclTkAqua, but doesn't the Tk interface just wrap the
widgets around the native MacOSX widget set? So it would be okay to
create an application for Tk, and use it on other platforms.

Also, In other recent threads, you might want to check out

http://tktable.sourceforge.net/tile/
Latest Ruby 1.8.4 contains a method to wrap the Tk API to Tile widgets,
see the thread located at

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/180329
Skip ahead of the GTK/2 talk and read the Tk portion

Tsume
 
P

petermichaux

I'm having trouble using even this apparently easy to use tk aqua
binary. Arg. Shouldn't using Tk be extreamly easy in the Ruby world? Is
there a catch?
 
L

Logan Capaldo

I'm having trouble using even this apparently easy to use tk aqua
binary. Arg. Shouldn't using Tk be extreamly easy in the Ruby
world? Is
there a catch?

The catch is that the magic Aqua Tk works very well with the Apple
installed ruby. I don't know how hard it is to get it to work in a
self compiled ruby. The default tk with the source ruby distribution
wants an X server running and doesn't look native
 
G

G B-)

Hi,

I tried to run the one line script tk.rb

require 'tk'

and saw the following error

$ ruby tk.rb
/usr/local/lib/ruby/1.8/tk.rb:7:in `require': No such file to load --
tcltklib (LoadError)
from /usr/local/lib/ruby/1.8/tk.rb:7
from tk.rb:1:in `require'
from tk.rb:1
Obviously Ruby's Tk wrapper isn't finding the library.
Did you install Ruby on the Mac yourself?
Which version of Mac OS X have you?
I don't know if it matters but I can run the following command without
error

$ tclsh
%

What do I do? Do I install tk as a gem?
First try the Tcl shell with Tk built in, it's called 'wish'.

Paste this into wish (or put it in a file e.g. called 'hello', and
execute 'wish hello'):
button .b -text "Hello, world!" -command exit
pack .b

You should get a small window with a 'Hello, world" button.

On my Mac OS X 10.4, the pre-installed Ruby works with Tk (which is
also installed), so ...

Can you revert to the version that came pre-installed on the Mac
(/usr/bin/ruby) and try the little 'hello world' example? That will
tell you if you have the right pieces installed, and if Tk is able to
cooperate.

This may be good enough for now, but if not, the build method
recommended by the Ruby on Rails book is at:
http://tech.rufy.com/articles/2005/05/01/complete-fix-for-ruby-on-mac-os-x-10-4-tiger

I haven't tried that yet, but will will later today (I may need to use
different versions of Ruby for a project).

HTH GB-)
 

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,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top