Windows RubyInstaller 1.8.7: Installing missing TCL/TK packages?

220 views
Skip to first unread message

Axel

unread,
Jan 27, 2012, 12:53:48 PM1/27/12
to RubyInstaller
Hi,

I already posted this question to comp.lang.ruby....

On a WindowsXP-laptop I've installed RubyInstaller 1.8.7-p357,
including
the integrated TCLTk-installation. Ruby version is 1.8.7 (2009-06-12
patchlevel 174) [i386-mingw32]. RubyTk works "out of the box" (thank
you!), but for using "vu", it seems that I need an additional TCL/TK
(not Ruby) package.

How can I install this?

I have _no_ original TCL/TK (like Active State) installed on this
laptop. For Active State I would probably use "teacup".

Background is, that I want to display measured data similar to an
oscilloscope. Data are coming in via ruby-serialport. On another
Windows computer where I have an older Ruby installation, which is
using
Active State's TCL/TK, this little application (seems to) works.

I already got this answer from Jon:
>> ... I don't work in Tcl/Tk, but I wonder if a reasonable hack for your
>> situation would be to embed the "vu" stuff into RubyInstaller's private
>> Tcl/Tk lib.
>
> I copied the vu stuff from an ActivTCL directory to .../lib/tcltk, but
> unfortunately this doesn't help.
>
>
>> Also wondering if you can move to 1.9.3 given 1.8.7 is
>> effectively EOL and all the good work (Windows performance/usability and
>> otherwise) is happening on 1.9.3 and 2.0.0.
>
> I can. Up to now, I hesitated using 1.9, because of the string encoding
> stuff, and because I'm quite happy with 1.8.7.
> Could RubyInstaller 1.9.3 help with my TK-Problem?
>
>
>> Why don't you post this question to our RubyInstaller ML and see if we
>> can come up with something creative?

Kind regards,
Axel

Jon

unread,
Jan 27, 2012, 3:20:04 PM1/27/12
to rubyin...@googlegroups.com


Is this what you're trying to get working?

http://wiki.tcl.tk/5823
http://sourceforge.net/projects/tktable/files/vu/2.1.0/

I just downloaded the `vu2.1.0-win32-x86.zip` package. The deps for `vu21.dll` are kernel32.dll, msvcrt.dll, gdi32.dll which are available on my Win7 SP1 32bit system and most likely available on your WinXP laptop.

I see this from the zip's `README.txt` so I still think the fix is to put the files in the right location under `<INSTALL_DIR>/lib`. Maybe everything needs to be extracted to the `<INSTALL_DIR>/lib/tcltk/vu-2.1.0` dir and it will be picked up by default?

BINARY DISTRIBUTIONS
====================

If this is a binary distribution, then the vu-<version> directory
just needs to be placed as a sibling directory next to $tk_library.
You can place it anywhere, as long as $auto_path has the name of
the directory.

This info re: $auto_path looks promising http://wiki.tcl.tk/1628

Looks like we just need to solve search path issues.

Jon

---
Fail fast. Fail often. Fail publicly. Learn. Adapt. Repeat.
http://thecodeshop.github.com | http://jonforums.github.com/
twitter: @jonforums

Axel

unread,
Jan 27, 2012, 4:23:08 PM1/27/12
to RubyInstaller
Jon,

> Is this what you're trying to get working?
>
>  http://wiki.tcl.tk/5823
>  http://sourceforge.net/projects/tktable/files/vu/2.1.0/

this really seems to be the solution! - I'm at home now, where I've
just another Ruby installation (older RubyInstaller + ActiveTCL
without VU). First, it didn't work. But when I placed the content of
`vu2.1.0-win32-x86.zip` into "...\TCL\lib"-dir, it worked!

On Monday, at the work's laptop, I'll put the files into the .../lib/
tcltk-directory of Ruby 1.8.7-p357 and see, if it works there too.
I'll post the outcome here.

I'm impressed, that you found this. Thank you!

Axel

Jon

unread,
Jan 28, 2012, 3:03:31 PM1/28/12
to rubyin...@googlegroups.com

Great! I'd like to see a snippet of your Ruby code to learn how you're
using the vu components with standard Tk components.

While it likely works fine, injecting 3rd party Tcl/Tk goodies into
RubyInstaller's private Tcl/Tk library is a bad idea for many reasons.
I prefer something like the following which mods Tcl's $auto_path to
point to a dir dedicated to Tcl/Tk addons. Better yet, let's figure
out how to set an AUTO_PATH environment var similar to how you might
use GEM_PATH, PYTHONPATH, etc.


# extract `vu2.1.0-win32-x86.zip` contents to `c:\devlibs\tcltk`

C:\Users\Jon\Documents>ripl
>> RUBY_DESCRIPTION
=> "ruby 1.9.3p0 (2011-11-08 revision 33661) [i386-mingw32]"
>> require 'tk'
=> true
>> Tk::AUTO_PATH.value += ' c:/devlibs/tcltk'
=> "C:/ruby193/lib/tcltk/tcl8.5 C:/ruby193/lib/tcltk C:/ruby193/lib
C:/ruby193/lib/tcltk/tk8.5 C:/ruby193/lib/tcltk/tk8.5/ttk
c:/devlibs/tcltk"
>> Tk.tk_call *%w{package require vu}
=> "2.1.0"

Axel

unread,
Jan 29, 2012, 3:05:43 AM1/29/12
to RubyInstaller

> I prefer something like the following which mods Tcl's $auto_path to
> point to a dir dedicated to Tcl/Tk addons.
> ...
> >> Tk::AUTO_PATH.value += ' c:/devlibs/tcltk'
> ...

I'll try this.


> Great! I'd like to see a snippet of your Ruby code to learn how you're
> using the vu components with standard Tk components.

You might have example usages in dir:
ruby\sample\tk\tkextlib\vu\oscilloscope.rb
ruby\sample\tk\tkextlib\vu\vu_demo.rb

They are online available for example here:
http://rxr.whitequark.org/mri/source/ext/tk/sample/tkextlib/vu/oscilloscope.rb?v=1.9.3
http://rxr.whitequark.org/mri/source/ext/tk/sample/tkextlib/vu/vu_demo.rb?v=1.9.3

That's how I try to use it:

require "serialport"
sp = SerialPort.new("COM1", 57600, 8)
sp.read_timeout = 64

########################## TK ###################
require 'tk'
require 'tkextlib/vu/charts'

xbm = File.join(File.dirname(File.expand_path(__FILE__)),
'm128_000.xbm')

sval = [ 11, 22, 33, 44, 55, 66, 77, 88, 99 ]

l0 = TkLabel.new(:width=>600, :height=>600,
:bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)

c0 = TkCanvas.new(:width=>500, :height=>500,
:insertwidth=>0, :highlightthickness=>0,
:selectborderwidth=>0, :borderwidth=>2,
:relief=>:ridge).place(:in=>l0, :relx=>0.5, :rely=>0.5,
:anchor=>:c)


# Line of the oscilloscope
st = Tk::Vu::TkcStripchart.new(c0, 3, 3, 500, 500,
:background=>"#b7c0d7", :fill=>'slategray3',
:jumpscroll=>1, :outline=>'black',
:scaleline=>'blue', :stripline=>'red',
:selected=>1, :values=>sval)

TkcText.create(c0, 40, 40,
:text=>Tk::TCL_PATCHLEVEL, :fill=>'cyan', :tags=>'text')

# Reading data from serial port
c_do = proc{
got = sp.gets

val = got[0 , 2].unpack("n*")[0] ; st[:values] = val
val = got[8 , 2].unpack("n*")[0] ; st[:values] = val
# ... and so on
}

c0.bind('1', c_do)

TkTimer.new(2, -1, c_do).start # ToDo: Better way?

Tk.root.bind('q', proc{exit})
Tk.mainloop
########################## END TK ###############
sp.close

Jon

unread,
Jan 29, 2012, 6:57:08 PM1/29/12
to RubyInstaller
> > I prefer something like the following which mods Tcl's $auto_path to
> > point to a dir dedicated to Tcl/Tk addons.
> > ...
> > >> Tk::AUTO_PATH.value += ' c:/devlibs/tcltk'
> > ...
>
> I'll try this.

Wouldn't you know it...those clever ruby-core devs hid the key info
from us in the doco ;)

https://github.com/ruby/ruby/blob/trunk/ext/tk/README.ActiveTcl#L44-46

I tried setting both the TCLLIBPATH env var and then this (without the
env var) and things seemed to work on 1.9.3.

Tk::AUTO_PATH.lappend 'c:/devlibs/tcltk'

They've integrated with `vu` via https://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tkextlib/vu.rb#L16-21

Haven't yet tried building/installing the `ruby-serialport` gem on
1.9.3 with the DevKit, but this looks good:

https://github.com/hparra/ruby-serialport/blob/master/ext/native/extconf.rb

I'm guessing this all just works on 1.9.3, but we'll soon see.

Jon

Axel

unread,
Jan 30, 2012, 3:20:08 AM1/30/12
to RubyInstaller
Jon, thank you a lot for all your help!

> Wouldn't you know it...those clever ruby-core devs hid the key info
> from us in the doco ;)
>
>  https://github.com/ruby/ruby/blob/trunk/ext/tk/README.ActiveTcl#L44-46

Interesting.


> I tried setting both the TCLLIBPATH env var and then this (without the
> env var) and things seemed to work on 1.9.3.
>
>   Tk::AUTO_PATH.lappend 'c:/devlibs/tcltk'

I can do more tests now;
my tests on WindowsXP & RubyInstaller 1.8.7-p357:

I took:
* vu2.1.0 from http://sourceforge.net/projects/tktable/files/vu/2.1.0/
* vu2.3 from ActiveTCL teapot-lib

1a) Putting vu2.1.0 into ruby/lib/tcltk
-> segmentation fault

1b) Putting vu2.3 into ruby/lib/tcltk
-> it works

2a) Putting vu2.3 into c:/Tcl/lib/
(trying both forward and back slashes)
-> "TKPackage can't find package vu"

2b) Putting vu2.3 into c:/Tcl/lib/
and adding
Tk::AUTO_PATH.lappend 'c:/Tcl/lib/'
-> "TKPackage can't find package vu"

2c) Putting vu2.3 into c:/Tcl/lib/
and setting env:
set TCLLIBPATH=c:/Tcl/lib
-> it works :))
(backslashes did not work)

2d) Putting vu2.3 into c:/Tcl/lib/
and adding to my rubyscript:
ENV['TCLLIBPATH'] = 'c:/Tcl/lib'
-> "TKPackage can't find package vu"

So I'll stay with 2c for now :))


> They've integrated with `vu` viahttps://github.com/ruby/ruby/blob/trunk/ext/tk/lib/tkextlib/vu.rb#L16-21

That's very good for me. :)


> Haven't yet tried building/installing the `ruby-serialport` gem on
> 1.9.3 with the DevKit, but this looks good:
>
>  https://github.com/hparra/ruby-serialport/blob/master/ext/native/extc...

On 1.8.7, ruby-serialport compiled fine with:
* having DevKit installed (thank you a lot for this!)
* gem sources -a http://gemcutter.org

Axel


Axel

unread,
Jan 31, 2012, 4:24:33 AM1/31/12
to RubyInstaller
All works good now. Thank you!

Axel
Reply all
Reply to author
Forward
0 new messages