Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding keypress to button confusion....

Status
Not open for further replies.

AndoSam

Technical User
Jul 14, 2010
16
GB
Hi

I am attempting to streamline the use of a tk application by binding the <return> button to a button executing a process.
I have read through the other forum posts and found several suggestions but none seem to be working for me.

I have defined the button widget etc. as
Code:
button .traceWindow.runProc -text "Follow path..." -command proceed

Then, a few lines later I use the line
Code:
bind .traceWindow.runProc <Return> {proceed}

as suggested in other forum posts, however this appears to have no effect. I have been thinking about trying to assign focus to the button once the value of an entry box has changed, however this seems a bit lengthy if I could just bind the button.

Thanks in advance
 
What your binding statement says, I think, is "when the Return key is pressed when the focus is in .traceWindow.runProc execute the proceed procedure". Is this what you want? What happens when you get the focus to the button (presumably with tab) and press "Enter"?

_________________
Bob Rashkin
 
Aah I see, that does execute the process yes.
This isn't exactly the functionality I was after, I would like the user to be able to make a selection in a seperate entry widget and then just press the return button and the process fires off.
I assume this should be done by an event driven 'change focus' command? Where the event is the value in the entry box changing?

Thanks
 
Yes that seems to have done the trick.

Whenever the value in the entry changes, the focus is reassigned to the button so the user can just press 'Return'.

Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top