Hello all:
I want to have a right mouse click when I click on a dialog box, but I don't known why my code can not work.
Would anyone help me, please.
Thanks
rgds
stewang
I want to have a right mouse click when I click on a dialog box, but I don't known why my code can not work.
Would anyone help me, please.
Thanks
rgds
stewang
Code:
proc openFile {} {
# use the built in file selection dialog
set filename [tk_getOpenFile]
bind filename <Button-3> { popUpLabel }
set thefile [open $filename r]
# rather than read one line at a time we read
# all of the file in one go
set filecontent [read $thefile]
close $thefile
# insert it into the text widget at line 1
# character 0
.filetext insert 1.0 $filecontent
}
proc saveFile {} {
set filename [tk_getSaveFile]
bind filename <Button-3> { popUpLabel }
set thefile [open $filename w]
# use the get command to get the text widget contents
set filecontent [.filetext get 1.0 end]
puts $thefile $filecontent
close $thefile
}
proc popUpLabel { } {
label .l
button .l.b1 -text "button1" -bg white -command { puts "test" }
button .l.b2 -text "button2" -bg grey -command { puts "test" }
pack .l .l.b1 .l.b2
}
frame .buttonframe
button .buttonframe.open -text "Open" -command openFile
button .buttonframe.save -text "Save" -command saveFile
text .filetext
pack .buttonframe.open -side left
pack .buttonframe.save -side left
pack .buttonframe
pack .filetext