Using additional widget in Ruby

M

Markus Liebelt

Hello everybody!

Is it possible to install an additional widget written in Tcl/Tk and using
that widget in ruby without the change of any libraries? That should be
possible, because when copying that file to some place where Tcl will find
it, it is possible to start it without changing any library files or
compiling anything (Tcl is a scripting language, isn't it)?

The task I want to do is to install Bryan Douglas Oakley combobox and
using it in Ruby.

http://www.purl.org/net/oakley/tcl/combobox/index.html

By the side, has anyone a description how the integration of Tcl/Tk in
ruby is done? I don't get it at the moment, and it looks sometimes as
magic what is going on. If anyone has an explanation what is going on, I
could read that and don't ask silly questions in this newsgroup.

Bye
Markus
 
H

Hidetoshi NAGAI

Hi,

From: "Markus Liebelt" <[email protected]>
Subject: Using additional widget in Ruby
Date: Sat, 8 Jan 2005 01:51:28 +0900
Message-ID: said:
Is it possible to install an additional widget written in Tcl/Tk and using
that widget in ruby without the change of any libraries?

Yes, of course.
Please see tktree.rb and tktree.tcl included in the Ruby source archive.
You can find them ext/tk/sample directory. Probably, they exist at the
samples folder of the one-click-ruby-installer.
tktree.tcl is a widget written in pure Tcl/Tk.
tktree.rb is a wrapper of the tktree widget.
The task I want to do is to install Bryan Douglas Oakley combobox and
using it in Ruby.

If your Tcl/Tk can load the library, you can use it on your Ruby/Tk.
However, you may have to add the library path to Tk::AUTO_PATH or
Tk::pACKAGE_PATH or Tk::LIBRARY_PATH.
To create and control the widget class, please use Tk.tk_call.

Ruby/Tk can call all functions of Tcl/Tk, and can load Tcl/Tk scripts.
Even if Tcl/Tk's functions aren't wrapped by Ruby's classes or methods,
they can be called by Tk.tk_call (or TkCore::INTERP._invoke).

Tk.tk_call does NOT use Tcl/Tk's command line parser for the reason of
parsing overhead.
It uses Tcl_GetCommandInfo() function to search Tcl/Tk's commands.
Therefore, in rare cases, Ruby/Tk fails to autoload Tcl/Tk libraries.
When you have such troubles, please use Tk.ip_eval method to call the
Tcl/Tk command. The methods passes the argument string to Tcl/Tk's
command line parser.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top