From: michael libby Date: 2002-07-17T08:31:15+09:00 Subject: Re: TkText no -textvariable workaround? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 16 July 2002 10:15, Peter Hickman wrote: > The TkText widget however does not have this option, it makes little > sense to have text 'This is the text' so what you have is... [snipped examples] The reason is partly due to underlying Tk code and not something we could just fix in Ruby (at least that's my understanding and PH says as much below-- please correct if wrong). More importantly TkText's "value" is not just text! I don't see it mentioned elsewhere in the thread, so I thought I better point it out. TkText is a very powerful widget, including ability to insert pictures, use multiple fonts, colors, etc, and other properties that would be completely confounded by any attempt to tie the "value" to a string like TkLabel or TkEntry can do. TkText is almost misleading, maybe should be TkRichText. :) > The Perl/Tk pocket reference from O'Reilly is a usefull reference, if > somewhat terse. What you are seeing is more an artefact of Tk than Ruby. I have never been disappointed using man pages at http://www.tcl.tk or with the sample scripts in RAA. To Tom Sawyer's original problem, you'll have to bind to keystroke event or some other widget event to capture changes as they happen, if that is your intent. sample code to demonstrate: require 'tk' r = TkRoot.new t = TkText.new(r).pack a = "" t.bind('Key', proc{|x| a << x.keysym_num.chr }) r.bind('Button-1', proc{puts a}) Tk.mainloop Type into text block to generate a, press mouse button in text box to print. On my machine this generates errors on certain keystrokes, like Shift, because its keysym_num is out of range for chr -- however capital letters still work, just not smoothly. The proc{} could easily test for legal values -- and process things like delete or cursor movements, etc. - -michael - -- ______Michael_C_Libby__{_x_(at)_ichimunki_(dot)_com_}______ | my website: http://www.ichimunki.com/ | |____ public key at http://www.ichimunki.com/public.key ____| -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9NKqH4ClW9KMwqnMRAvy2AJ9ZW29Jvuh3i36KFjnh6xfla7JppgCcCzfB xSG6qt1z1/qUQa/guTwl0hw= =nx73 -----END PGP SIGNATURE-----