tkEntry with a { character

I’ve tried to boil this down to be as meaningful as possible. I’m
guessing this is a Tk issue, but since I’m using Ruby (1.8.0) I thought
I’d start here.

Type any English text character into the entry box, and the target proc
sees the character as typed (e.g. type an a and it sees an “a”, type a b
and it sees the field contains “ab”).

The exception is the “{” (left brace). Type one in and the entry box has
one “{”, but The TkVariable @myText displays it as empty (the TkComm
object sees that as an escaped character “{” ). Type a second left
brace and the entry field has 2 braces and the TkVariable @myText still
extracts an empty string.

Type a 3rd brace and now the @myText.to_s gives back 1 brace (all right
of the first 2?).

Thanks for any insight.

Mac

require ‘tk’;

def puts_KeyChar(tkcommObj);
puts ‘key release - ’ + tkcommObj.char() + ’ -’;
puts ‘entry variable - ’ + @myText.to_s + ’ -’;
end

myWindowRoot = TkRoot.new {title ‘Tk Test’};
@myText = TkVariable.new(’’);

myEntry = TkEntry.new(myWindowRoot);
myEntry.textvariable(@myText);

myEntry.pack(‘side’=>‘top’);
myEntry.bind(‘Any-KeyRelease’,proc {|tkcommObj| puts_KeyChar(tkcommObj)});

Tk.mainloop;

— Mac webrg.ruby-talk.com@Panscend.com wrote:

one “{”, but The TkVariable @myText displays it as empty (the TkComm
object sees that as an escaped character “{” ). Type a second left

Use:

{{

as opposed to:

{

– Thomas Adam

···

=====
“The Linux Weekend Mechanic” – http://linuxgazette.net
“TAG Editor” – http://linuxgazette.net

“ We’ll just save up your sins, Thomas, and punish
you for all of them at once when you get better. The
experience will probably kill you. :)”

– Benjamin A. Okopnik (Linux Gazette Technical Editor)


BT Yahoo! Broadband - Free modem offer, sign up online today and save £80 http://btyahoo.yahoo.co.uk