# TK help

**URL:** <https://www.ruby-forum.com/t/tk-help/67153>\
**Category:** Ruby\
**Created:** [September 1, 2006, 2:43am UTC](https://www.ruby-forum.com/t/tk-help/67153 "2006-09-01T02:43:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [September 1, 2006, 2:43am UTC](https://www.ruby-forum.com/t/tk-help/67153/1 "2006-09-01T02:43:21Z")

</div>

Okay so I set up a greeting AI for my sceince projet, (cool right?) but  
I got a problem: when he ask for a new key word I can’t ‘un-pack’ the  
button so it’s always there then if it happens again :), get ready for  
this, it does it again! My fault in the code, but I don’t know what else  
to do, so here’s the code that I think needs the editing:  
submit = TkButton.new(text) {  
image submitbutton  
command {  
aa = grem.how\_are\_you(text\_awnser)  
ga.configure(“text”=\>aa)  
if aa.include?(“I don’t know what that means”)  
submit\_helpg = TkButton.new(text){text “New positive keyword”;  
command {add\_word(new\_word,“yes”)}}.pack(“side”=\>“bottom”)  
submit\_helpb = TkButton.new(text){text “New negative keyword”;  
command {add\_word(new\_word,“no”)}}.pack(“side”=\>“bottom”)  
helpme = TkEntry.new(text){ textvariable new\_word  
}.pack(“side”=\>“bottom”)  
end  
}  
}.pack

Thanks In Advance,  
Screen Name.

---

<div class="post-metadata">

**Author:** ![mohammad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e274bd/32.png) [@mohammad](https://www.ruby-forum.com/u/mohammad)\
**Post date:** [September 1, 2006, 4:13am UTC](https://www.ruby-forum.com/t/tk-help/67153/2 "2006-09-01T04:13:37Z")

</div>

I don’t know why you say you can’t unpack your button – it’s  
possible to both unpack and disable buttons, and then repack and re-  
enable them. Consider the following code:

`
require 'tk'
DEBUG = []
begin
root = TkRoot.new {title ‘Button Demo’}
```
unpack_button = TkButton.new(root) {
   text 'Unpack Me'
   command {unpack_button.unpack}
}
unpack_button.pack

disable_button = TkButton.new(root) {
   text 'Disable Me'
   command {disable_button.state = 'disable'}
}
disable_button.pack

reset_button = TkButton.new(root) {
   text 'Reset'
   command {
      unpack_button.pack('before'=>disable_button)
      disable_button.state = 'normal'
   }
}
reset_button.pack

# Set initial window geometry; i.e., size and placement.
win_w, win_h = 200, 100
# root.minsize(win_w, win_h)
win_lf = (root.winfo_screenwidth - win_w) / 2
root.geometry("#{win_w}x#{win_h}+#{win_lf}+50")

# Make Cmnd+Q work as expected. This is for OS X.
root.bind('Command-q') {Tk.root.destroy}

Tk.mainloop

```
ensure
puts DEBUG unless DEBUG.empty?
end
`

Regards, Morton
