Hi Anirban

Your code is slightly confused on this, so I'll give you a clean example.

#####################################################
#You don't really need a frame for this little example, but I'll keep it in
#the spirit of your code.
frame .f text .f.t
button .f.b1 -text "Submit" -command { submit_details }
button .f.b2 -text "Show last submit" -command {show_dialog}
pack .f.t
pack .f.b1
pack .f.b2
pack .f


proc submit_details {} {
   #global variables are available to all procs
    global textbox_contents
   #when getting from text, you need the start (0.0) and end (end) indexes
   set textbox_contents [.f.t get 0.0 end]
}

proc show_dialog {} {
   global textbox_contents
   tk_messageBox -message $textbox_contents
}

#Example end
##########################################################

Hope this helps to get you started. It is all quite easy once you get the hang of it ;). Please do check out the comp.lang.tcl newsgroup. This sort of thing is really of topic here.

Lawrence



Hi all,

I have a tcl text widget with some values in it that has been fetched from a 
sqlite backend.
I also have a button labelled Submit.
When I click the Submit button, I want to call a procedure which will fetch the 
value that is stored in the text widget and store it in a variable. What do I 
write in the procedure?

The procedure which I have written is given below, but it gives me errors while 
compiling.

The relative code is given below:

frame .f2 -width 250 -height 270
pack .f2
pack propagate .f2 0

button .f2.b1 -text "Submit" -command { submit_details } -font $fnt11b
place .f2.b1 -x 2 -y 240 -width 55 -height 20

proc submit_details {} {
puts "Submit"
set seln [.f2.t2 text]
set selcn "[.f2.t2 get $seln]"
puts $selcn
}

Thanking in advance for any help.
Anirban Sarkar








Reply via email to