Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > TAB and Enter key in Tkinter

Reply
Thread Tools

TAB and Enter key in Tkinter

 
 
Scott Holmes
Guest
Posts: n/a
 
      08-09-2003
I've noticed that widgets in a Pmw toplevel are navigated by tab key. I
find I can tab between the entry fields and the buttons but hitting the
enter key after moving to a button does not activate the button. If
possible, how do I configure buttons to accept and enter key event?
--
---------------------------------------------------------------------
Scott Holmes http://sholmes.ws
http://pages.sbcglobal.net/scottholmes
http://www.velocityreviews.com/forums/(E-Mail Removed)

Independent Programmer/Analyst Passport 4GL
PHP HTML Composer PostgreSQL Informix 4GL, SQL
---------------------------------------------------------------------
There are more things in heaven and earth, Horatio,
than are dreamt of in your philosophy
---------------------------------------------------------------------


 
Reply With Quote
 
 
 
 
klappnase
Guest
Posts: n/a
 
      08-09-2003
Scott Holmes <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> I've noticed that widgets in a Pmw toplevel are navigated by tab key. I
> find I can tab between the entry fields and the buttons but hitting the
> enter key after moving to a button does not activate the button. If
> possible, how do I configure buttons to accept and enter key event?
> --
> ---------------------------------------------------------------------

Hi,

I suppose you probably bound the callback to your button with the
"command=" option, like:

button1 = Button(parent, text="Hello", command=some_function)

In this case you will get the default Tk behavior that the callback is
invoked with a (mouse-) Button-1 or a Space-Key press.
If you do not want this, use the bind method instead like:

button1 = Button(parent, text="Hello")
button1.bind("<ButtonRelease-1>", some_function)
button1.bind("<KeyRelease-Return>", some_function)

This way you will get the behavior I think you want. Of course you can
bind any other event to your callback this way.
Please note that the "bind" method unlike the "command" option passes
the event as (the first) argument to the callback function, so you
will have to change the definition line like this:

#callback for use with "command" option
def some_function():
do_something

#callback for use with "bind" method
def some_function(event):
do_something

I hope this helped.

Best regards

Michael
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make send key ([tab] [tab]Text [Enter]) in some program (Internet Explorer or Notepad)? max Perl Misc 2 04-01-2007 10:12 AM
How can I capture tab key event and cancel default action of Tab key? HopfZ Javascript 0 01-08-2007 10:04 PM
Enter Key H*ll, control enter key submit button BrianDH ASP .Net Web Controls 3 01-12-2005 08:29 PM
Urgent: How can I get the enter key to behave like a tab key? Karen Grube ASP .Net Web Controls 3 11-29-2004 03:23 PM
Replace Tab Key to Return Key (Enter Key) from Web Forms? M P ASP General 1 08-06-2004 08:32 AM



Advertisments