How to create a CText Tk widget?

Hello all,

I know those two nice websites for informations on Ruby/Tk, but they are
not complete and it's really difficult to find documentation or samples
for Tk widgets on Ruby :
http://www.tutorialspoint.com/ruby/ruby_tk_guide.htm
http://www.tkdocs.com/

I want to try the CText widget, wich is part of tcllib package, but
can't find how to do it.

here is my last try from a Text sample I modified :

require 'tk'
require 'tkextlib/tcllib/ctext'

root = TkRoot.new do
  title "Window"
  minsize(320,200)
end

ctext = Tk::Tcllib::CText.new(root) do
  borderwidth 1
  font TkFont.new('arial 11 bold')
  pack('fill' => 'both', 'expand'=>true)
end
ctext.insert 'end', "test (hello)"

Tk.mainloop

and here is the error I got :

C:/Ruby193/lib/ruby/1.9.1/tk/package.rb:86:in `rescue in require':
TkPackage can't find package ctext (RuntimeError)
  from C:/Ruby193/lib/ruby/1.9.1/tk/package.rb:83:in `require'
  from C:/Ruby193/lib/ruby/1.9.1/tkextlib/tcllib/ctext.rb:14:in `<top
(required)>'
  from
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
  from
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
  from tk_test7.rbw:2:in `<main>'

forgot to mention, I'm on WindowsXP with the last version of
RubyInstaller (with Tk included) and devkit..

so, can someone give me a little help to start with CText or simply
point me to ruby Tk samples, different from the common ones...?
thanks.

Fred

···

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

Message-ID: <094f1bdd58cd8b82f14ecdc227b7ea66@ruby-forum.com>

and here is the error I got :

C:/Ruby193/lib/ruby/1.9.1/tk/package.rb:86:in `rescue in require':
TkPackage can't find package ctext (RuntimeError)
  from C:/Ruby193/lib/ruby/1.9.1/tk/package.rb:83:in `require'
  from C:/Ruby193/lib/ruby/1.9.1/tkextlib/tcllib/ctext.rb:14:in `<top
(required)>'
  from
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
  from
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
  from tk_test7.rbw:2:in `<main>'

forgot to mention, I'm on WindowsXP with the last version of
RubyInstaller (with Tk included) and devkit..

Probably, you don't have tcllib extension package for your
Tcl/Tk libraries which used by Ruby/Tk.
You'll be able to get the status list of extension packages by
"ruby <your-ruby-lib-path>/tkextlib/pkg_checker.rb".
(e.g."ruby C:/Ruby193/lib/ruby/1.9.1/tkextlib/pkg_checker.rb")

One of the easy ways to get tcllib/tklib package is
"download ActiveTcl-8.4 package".
Extension packages included ActiveTcl-8.4 are available for 8.5.
To add the packages to Ruby/Tk, please copy them to the library path of
Ruby/Tk or add the path of packages to Tk::AUTO_PATH.
For example, when the path of tcllib/tklib is
"/opt/ActiveTcl-8.4/lib/{tcllib1.9,tklib0.4}",
do
"Tk::AUTO_PATH.list <<= '/opt/ActiveTcl-8.4/lib/tcllib1.9';
Tk::AUTO_PATH.list <<= '/opt/ActiveTcl-8.4/lib/tklib0.4'"
or
"Tk::AUTO_PATH.list <<= '/opt/ActiveTcl-8.4/lib".

If you want to use the setting permanently,
please add the setting to "<your-ruby-lib-path>/tkextlib/setup.rb"
or "<your-ruby-lib-path>/tkextlib/tcllib/setup.rb".

···

From: "Fred L." <lists@ruby-forum.com>
Subject: how to create a CText Tk widget ?
Date: Tue, 10 Jul 2012 05:30:16 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology

Hello,
thanks a lot for your answer.

I have the Tk version installed with the RubyInstaller for Windows, so I
think I shouldn't have to install anything more. but you are right,
there seem to be a problem with the extension packages or the way they
are installed.
I tried pkg_checker.rb and got a lot of fail. (you can see an extract of
the result at the end of my post).

I'm gonna ask for more information about the Tk installation on the
RubyInstaller forum and what should be really included.

thanks again for your answer, I'll keep your infos about Tk::AUTO_PATH,
in case I switch to the ActiveTcl version..

short extract from the result :

rubyw "pkg_checker.rb"

Ruby/Tk extension library checker
( Note:: This check is very simple one. Shown status may be wrong. )

check directory :: C:/Ruby193/lib/ruby/1.9.1/tkextlib
$LOAD_PATH :: ["C:/Ruby193/lib/ruby/site_ruby/1.9.1",
"C:/Ruby193/lib/ruby/site_ruby/1.9.1/i386-msvcrt",
"C:/Ruby193/lib/ruby/site_ruby",
"C:/Ruby193/lib/ruby/vendor_ruby/1.9.1",
"C:/Ruby193/lib/ruby/vendor_ruby/1.9.1/i386-msvcrt",
"C:/Ruby193/lib/ruby/vendor_ruby", "C:/Ruby193/lib/ruby/1.9.1",
"C:/Ruby193/lib/ruby/1.9.1/i386-mingw32"]

*LACK : blt.rb : require->{} FAIL->[["BLT", :package]]
Ready : blt/barchart.rb : require->{}
Ready : blt/bitmap.rb : require->{}
Ready : blt/busy.rb : require->{}
Ready : blt/component.rb : require->{}
Ready : blt/container.rb : require->{}
Ready : blt/cutbuffer.rb : require->{}
Ready : blt/dragdrop.rb : require->{}

...

*LACK : bwidget.rb : require->{} FAIL->[["BWidget", :package]]
*LACK : bwidget/arrowbutton.rb : require->{}
FAIL->[["tkextlib/bwidget/button", :require_ruby_lib]]
Ready : bwidget/bitmap.rb : require->{}
Ready : bwidget/button.rb : require->{}
*LACK : bwidget/buttonbox.rb : require->{}
FAIL->[["tkextlib/bwidget/button", :require_ruby_lib]]
*LACK : bwidget/combobox.rb : require->{}
FAIL->[["tkextlib/bwidget/listbox", :require_ruby_lib],
["tkextlib/bwidget/spinbox", :require_ruby_lib]]
*LACK : bwidget/dialog.rb : require->{}
FAIL->[["tkextlib/bwidget/buttonbox", :require_ruby_lib]]
Ready : bwidget/dragsite.rb : require->{}
Ready : bwidget/dropsite.rb : require->{}
Ready : bwidget/dynamichelp.rb : require->{}

...

Ready : tcllib.rb : require->{}
*LACK : tcllib/autoscroll.rb : require->{} FAIL->[["autoscroll",
:package]]
*LACK : tcllib/calendar.rb : require->{} FAIL->[["widget::calendar",
:package]]
*LACK : tcllib/canvas_sqmap.rb : require->{}
FAIL->[["widget::canvas_sqmap", :package]]
*LACK : tcllib/canvas_zoom.rb : require->{}
FAIL->[["widget::canvas_zoom", :package]]
*LACK : tcllib/chatwidget.rb : require->{} FAIL->[["chatwidget",
:package]]
*LACK : tcllib/crosshair.rb : require->{} FAIL->[["crosshair",
:package]]
*LACK : tcllib/ctext.rb : require->{} FAIL->[["ctext", :package]]
*LACK : tcllib/cursor.rb : require->{} FAIL->[["cursor", :package]]

...

Ready : tile.rb : require->{"tile"=>"0.8.6"}
*LACK : tile/dialog.rb : require->{} FAIL->[["ttk::dialog", :package]]
Ready : tile/setup.rb : require->{}
Ready : tile/sizegrip.rb : require->{}
Ready : tile/style.rb : require->{}
Ready : tile/tbutton.rb : require->{}

...

···

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

I did several test with Ruby/tk samples and only the tk and tk/tile ones
are working, so you're certainly right.
will look to install the packages..
thanks again.
Fred

···

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

Message-ID: <95a16c8b7699fd2e2b5ca36220c8128d@ruby-forum.com>

I have the Tk version installed with the RubyInstaller for Windows, so I
think I shouldn't have to install anything more. but you are right,

I think that RubyInstaller includes standard Tcl/Tk libraries only.
If you want to use extension packages (e.g. tcllib/tklib),
you will have to install the packages.

···

From: "Fred L." <lists@ruby-forum.com>
Subject: Re: how to create a CText Tk widget ?
Date: Thu, 12 Jul 2012 03:32:11 +0900
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology