tkextlib and Unicode

A

Axel

Hello!

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).

Kind regards, ---------------- Axel <><
 
H

Hidetoshi NAGAI

From: "Axel" <[email protected]>
Subject: tkextlib and Unicode
Date: Sun, 3 Jul 2005 19:10:45 +0900
Message-ID: said:
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'm very sorry. That is a bug on converting from an array of
UTF-8 strings to a Tcl's list string. I'll fix the bug later.

To avoid the problem temporarily, for example, replace the following
 
H

Hidetoshi NAGAI

From: Hidetoshi NAGAI <[email protected]>
Subject: Re: tkextlib and Unicode
Date: Sun, 3 Jul 2005 22:43:21 +0900
Message-ID: said:
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.
 
H

Hidetoshi NAGAI

From: Hidetoshi NAGAI <[email protected]>
Subject: Re: tkextlib and Unicode
Date: Sun, 3 Jul 2005 23:17:13 +0900
Message-ID: said:
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, ... ]))".
 
A

Axel

Hello, Nagai-san!

You are right, adding

$KCODE = 'u'

before requiring Tk also fixes the problem. Thank you very much!
 

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
474,262
Messages
2,571,044
Members
48,769
Latest member
Clifft

Latest Threads

Top