From: Jean-Pierre Berard Date: 2002-09-08T23:52:54+09:00 Subject: Re: ruby entry widget does not display properly Matt Gushee wrote in news:20020906101958.GJ4604@swordfish: > On Fri, Sep 06, 2002 at 07:10:18PM +0900, Jean-Pierre Berard wrote: >> In win2k ruby does not seem to be able to display properly Tk entry >> widget entered >> in Unicode. >> I know already that ruby script written in utf-8 will display without >> any difficulties thanks to the command line option rubyw -Ku >> script.rbw but when one enters Unicode through the global IME in >> Japanese for example into an Tk entry widget one gets an ugly cursor >> obstructing most of the display and nothing else except a series of >> strings ????? >> >> When the equivalent is done under Tcl/Tk, the Japanese characters are >> displayed >> beautifully without any ugly showing up of the cursor! >> Any pointer is most welcome since I am new to ruby. > >> >> TkEntry.new { >> insertwidth 40 > > This is part of the problem. Instead of 'insertwidth', use 'width', > just as you would in Tk. The config options almost always have the > same names in Ruby/Tk as in Tcl/Tk ... it's just the syntax that's > different. > >> font 'Times 16 normal' > > Does your Times font include Japanese characters? I suppose it must, > since it worked with Tcl/Tk. But if you're not sure, try using a > different font that you know includes Japanese characters. > It is reassuring to know that the transcription of tk scripts into ruby will be just a matter of syntax! The failing of the Japanese characters to display must to a degree also be a matter of syntax since ruby can display utf-8 without a further a do even without invoking the font command. It is the input, which must need somehow a reset from its default. The script with the word "Japanese" written in utf-8 displays without any font support but when one writes in Japanese into the entry widget one gets only ???? # ruby -Ku script.rb require "tk" root = TkRoot.new() { title "Packing Example" } entry = TkEntry.new(root).pack("side"=>"top", "fill"=>"x") # entry.insert(0, "Entry on the top") entry.insert(0, "�-�������") Tk.mainloop