Tcltk-ext help, I can't read japanese

Hi,

does anyone know how to use tcltk-ext. I want to use the mclistbox extension for tcl but am unable to understand the japanese documentation. I have tcltk-ext installed but I am haveing problems useing it for this extension.

Cheers
Nigel

Hi,

···

From: Nigel Wilkinson nigel.w@berlin.de
Subject: tcltk-ext help, I can’t read japanese
Date: Mon, 21 Oct 2002 00:46:39 +0900
Message-ID: 20021020164413.684d1839.nigel.w@berlin.de

does anyone know how to use tcltk-ext. I want to use the mclistbox
extension for tcl but am unable to understand the japanese documentation.
I have tcltk-ext installed but I am haveing problems useing it for this
extension.

Here is an English document which was witten by a tcltk-ext user.
He couldn’t understand the [ -b base_info [-g] ] option.
But if your extension can be loaded dynamically,
you don’t need the option.

If cannot be loaded, please ask me.

==========================================
tcltk-ext is a Ruby code wrapper generator for Tcl/Tk extensions.

Installation

To install tcltk-ext, you must copy
tcltkextlib.rb, tcltkext.rb, and tkext.rb to Ruby’s library path,
e.g., to lib/ruby/site-ruby/1.6/

Files with names starting with ‘test’ are sample scripts that exercise
these library files.

mk_tkextlib.rb is the actual wrapper generator.

Two generated wrapper files are included:

  • a Tix.rb wrapper for the Tix widget set
  • a Blt.rb wrapper for the BLT scientific graphics library

Usage

mk_tkextlib.rb [-v] [-b base_info [-g]] [-p pkg_name]
-v verbose flag
-b base_info -g ???
-p pkg_name the name of the Tcl/Tk extension package

The generator

  1. reads a file pkg_name.def provided by the user,
  2. loads the Tcl/Tk extension ‘pkg_name’
    as specified in the pkg_name.def file,
  3. identifies the commands created by this extension,
  4. tests them, and generates corresponding wrapper code
    in pkg_name.rb and pkg_name.inf

The pkg_name.def file defines two arrays,
$pre_load_lib and $ext_lib_info.

Entries for both arrays have the same format, namely arrays specifying

  • the tcl package name,
  • the path to the tcl extension dynamic link library
  • the path to the tcl extension library

mk_tkextlib.rb will load the entries in $pre_load_lib
prior to the entries in $ext_lib. Wrapper code will be generated
only for $ext_lib commands.

Tix example

We assume the directory and file structure of the Tcl/Tk installation to be
Tcl
. bin
. . wish83 (executable)
. . . tix818311.dll (Tix dynamic link library)
. . . itk32.dll (Itk dynamic link library)
. lib
. . tcl8.3
. . tk8.3
. . itcl3.2
. . itk3.2
. . tix8.1
. . . pkgIndex.tcl (Tix package initialization file)

The following Tix.def file
$pre_load_lib = [
[‘Itk’, ‘/Tcl/bin/itk32.dll’, [‘/Tcl/lib/itk3.2’]],
nil
]

$ext_lib_info = [
[‘Tix’, ‘/Tcl/bin/tix818311.dll’, [‘/Tcl/lib/tix8.1’]],
nil
]

will cause the wrapper generator to preload the Itk extension,
then load the Tix extension and produce a ruby wrapper for Tix.
The resulting files Tix.rb and Tix.inf should be placed in the
Ruby library path.
The command required to produce these files is
mk_tkextlib.rb -p Tix

If your Tcl/Tk can do dynamic-loading,
probably you don’t need -b option.

To use the provided wrappers for Tix and Blt, please make sure
that the versions of your library agree with the versions
specified in the .def files.

If they agree, modify the paths in Tix.inf and Blt.inf
to reflect your intallation, and copy Tix.inf, Tix.rb,
Blt.inf and Blt.rb to your Ruby library path.

For other Tcl/Tk extensions, you should only need to write
a corresponding .def file and run mk_tkextlib.rb.


Tix ruby code example

The following code is a transcription of the Tix sample code ‘Notebook.tcl’.
It makes use of the Tix.rb wrapper generated as described above.

require ‘Tix’

TkOption.add(‘TixControlentry.width’, 10)
TkOption.add(‘TixControllabel.width’, 18)
TkOption.add(‘TixControllabel.anchor’, ‘e’)

TkRoot.new.background ‘gray’

-----------------------------

create a notebook with two panes

nb = TixNoteBook.new(nil, ‘ipadx’=>6, ‘ipady’=>6)
nb.subwidget(‘nbframe’, ‘configure’, ‘backpagecolor’=>‘gray’)
nb.add(‘hard_disk’, ‘label’=>‘Hard Disk’, ‘underline’=>0)
nb.add(‘network’, ‘label’=>‘Network’, ‘underline’=>0)
nb.pack(‘expand’=>true, ‘fill’=>‘both’, ‘padx’=>5, ‘pady’=>5, ‘side’=>‘top’)

-----------------------------

populate the ‘hard_disk’ pane

sw = nb.subwidget(‘hard_disk’)
f_nb = TkFrame.new(nb).pack(‘side’=>‘left’, ‘padx’=>2, ‘pady’=>2,
‘fill’=>‘both’, ‘expand’=>true, ‘in’=>sw)
a = TixControl.new(f_nb, ‘value’=>12, ‘label’=>'Access Time: ')
w = TixControl.new(f_nb, ‘value’=>400, ‘label’=>'Write Throughput: ')
r = TixControl.new(f_nb, ‘value’=>400, ‘label’=>'Read Throughput: ')
c = TixControl.new(f_nb, ‘value’=>1021, ‘label’=>'Capacity: ')
Tk.pack(a, w, r, c, ‘side’=>‘top’, ‘padx’=>20, ‘pady’=>2)

f_common = TkFrame.new(nb).pack(‘side’=>‘right’, ‘padx’=>2, ‘pady’=>2,
‘fill’=>‘y’, ‘in’=>sw)
TkButton.new(f_common, ‘text’=>‘OK’, ‘width’=>6,
‘command’=>‘exit’).pack(‘side’=>‘top’, ‘padx’=>2, ‘pady’=>2)
TkButton.new(f_common, ‘text’=>‘Cancel’, ‘width’=>6,
‘command’=>‘exit’).pack(‘side’=>‘top’, ‘padx’=>2, ‘pady’=>2)

-----------------------------

populate the ‘network’ pane

sw = nb.subwidget(‘network’)
f_nb = TkFrame.new(nb).pack(‘side’=>‘left’, ‘padx’=>2, ‘pady’=>2,
‘fill’=>‘both’, ‘expand’=>true, ‘in’=>sw)
a = TixControl.new(f_nb, ‘value’=>12, ‘label’=>'Access Time: ')
w = TixControl.new(f_nb, ‘value’=>400, ‘label’=>'Write Throughput: ')
r = TixControl.new(f_nb, ‘value’=>400, ‘label’=>'Read Throughput: ')
c = TixControl.new(f_nb, ‘value’=>1021, ‘label’=>'Capacity: ')
u = TixControl.new(f_nb, ‘value’=>10, ‘label’=>'Users: ')
Tk.pack(a, w, r, c, ‘side’=>‘top’, ‘padx’=>20, ‘pady’=>2)

f_common = TkFrame.new(nb).pack(‘side’=>‘right’, ‘padx’=>2, ‘pady’=>2,
‘fill’=>‘y’, ‘in’=>sw)
TkButton.new(f_common, ‘text’=>‘OK’, ‘width’=>6,
‘command’=>‘exit’).pack(‘side’=>‘top’, ‘padx’=>2, ‘pady’=>2)
TkButton.new(f_common, ‘text’=>‘Cancel’, ‘width’=>6,
‘command’=>‘exit’).pack(‘side’=>‘top’, ‘padx’=>2, ‘pady’=>2)

-----------------------------

run the Tk event loop

Tk.mainloop
=========================================

BTW, if your Ruby/Tk can load the target package by TkPackage.require,
you can use the wrapper library without tkext.rb and package_name.def.
If headlines of the wrapper library is

require ‘tkext’

module Tix
extend Tix

load Tck/Tk ext-package library

load ‘Tix.inf’
EXTLIB_INFO.each{|lib| Tk.setup_libs(lib) if lib} if EXTLIB_INFO

please rewrite to

#require ‘tkext’
require ‘tk’

module Tix
extend Tix

load Tck/Tk ext-package library

#load ‘Tix.inf’
#EXTLIB_INFO.each{|lib| Tk.setup_libs(lib) if lib} if EXTLIB_INFO
TkPackage.requir(‘Tix’)


Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)