M
Mathew Cucuzella
I'm writing a Ruby/Tk program where I want a TkEntry field with a
state of "readonly" so a user can copy/paste from it, but not modify
it. Unfortunately this prevents me from programatically changing it,
which I want to do. Is there a better way to accomplish that?
Sample code: TkEntry does not display "hi" after button click.
<code>
require 'tk'
top = TkRoot.new
entry = TkEntry.new(top) {state "readonly";grid('row'=>0, 'column'=>0)}
TkButton.new(top) {text 'Convert'; grid('row'=>1, 'column'=>0);
# the "entry" field update fails, as documented
command proc {entry.value = "hi"}
}
Tk.mainloop
## Environment
# Ubuntu 10.4
# 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010
# i686 GNU/Linux
# ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
# libtcltk-ruby
# libtcltk-ruby1.8
</code>
Thanks,
Mathew Cucuzella
state of "readonly" so a user can copy/paste from it, but not modify
it. Unfortunately this prevents me from programatically changing it,
which I want to do. Is there a better way to accomplish that?
Sample code: TkEntry does not display "hi" after button click.
<code>
require 'tk'
top = TkRoot.new
entry = TkEntry.new(top) {state "readonly";grid('row'=>0, 'column'=>0)}
TkButton.new(top) {text 'Convert'; grid('row'=>1, 'column'=>0);
# the "entry" field update fails, as documented
command proc {entry.value = "hi"}
}
Tk.mainloop
## Environment
# Ubuntu 10.4
# 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010
# i686 GNU/Linux
# ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
# libtcltk-ruby
# libtcltk-ruby1.8
</code>
Thanks,
Mathew Cucuzella