tkEntry with a { character

M

Mac

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;
 

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
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top