Xilinx / XilinxTclStore

Xilinx Tcl Store
349 stars 187 forks source link

[question] tk_tunnel define proc inside rexec #753

Open Nabav opened 2 years ago

Nabav commented 2 years ago

This is a question about Tcl scope using Tk commands over tk_tunnel.

I want to have a push running a proc.

rexec {
  proc onClick {} {
    global selected
    if {$selected==true} {
      wm title . checkbutton
    } else {
      wm title . ""
    }
  }
  puts "Starting GUI..."
  tk::toplevel .window
  tk::frame .window.fr
  pack .window.fr -fill both -expand 1
  tk::text .window.fr.tx -width 20 -height 1
  tk::button .window.fr.pb -text "Hi" -width 10 -height 1 -command onClick
  tk::checkbutton .window.fr.cb -text "Show title" -command onClick \
    -onvalue true -offvalue false -variable selected
  .window.fr.cb select
  place .window.fr.cb -x 50 -y 50
  place .window.fr.tx -x 50 -y 80
  place .window.fr.pb -x 50 -y 10
  wm title .window "My Tool"
  wm geometry .window 350x250+300+300
}

I want to run the callback procedure when some widget is clicked.

Please help me with managing the scope. Thanks.