I need to quickly decide if a medium-sized application can be converted
to Ruby. This application has a very sophisticated GUI and needs
extensive Unicode support. As far as I know, the only Ruby GUI library
that supports Unicode is Ruby/Tk. But ... I would also need to use at
least some of the Tk extensions. I'm on Windows XP with the OneClick
Ruby installer 1.8.2-15. I installed ActiveTcl as described in other
posts in this group and edited lib/ruby/1.8/tkextlib/setup.rb to
contain
Tk::AUTO_PATH.list <<= 'c:/tcl/lib'
so at least the BWidgets can be accessed.
Now I tried this code (sorry for mixing various coding stlyes - I was
in a hurry):
require 'tk'
require 'tkextlib/bwidget/combobox.rb'
root = TkRoot.new { title 'Test' }
cb = Tk::BWidget::ComboBox.new(root)
txt = Tk::UTF8_String('\u00E4\u03B1')
cb.configure('values', [txt])
cb.pack
t = TkText.new.pack
t.insert('end', txt);
t.pack
l = TkLabel.new(root) {
text txt
}
l.pack
Tk.mainloop
I get the correct "text" in the text area and the label. But the combo
box seems to show me the raw UTF-8 bytes. Any fix for that? I tried it
various versions of ActiveTcl (8.3, 8.4, 8.5), always with the same
result. But as Tk_VERSION is 8.3 on my system, it's possible that newer
extensions don't get used (as at least ActiveTcl 8.5 seems to install
multiple versions of its components).
To avoid the problem temporarily, for example, replace the following
(snip)
If you use 'UTF-8' and 'ASCII' strings only on your application,
please insert "$KCODE='u'" *BEFORE* "require 'tk'".
Probably, it'll be able to hide your problem also.
If you use 'UTF-8' and 'ASCII' strings only on your application,
please insert "$KCODE='u'" *BEFORE* "require 'tk'".
Probably, it'll be able to hide your problem also.
Then, probably, you don't need to edit your script to use
"Tk::UTF8_String(TkComm.array2tk_list([u_str1, u_str2, ... ]))".