Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is very easy to do with Tkinter.</p> <p>There are a couple of things that have to happen to make this work. First, you need to make sure that the standard behavior <i>doesn't</i> happen. That is, you don't want tab to both insert a tab and move focus to the next widget. By default events are processed by a specific widget prior to where the standard behavior occurs (typically in class bindings). Tk has a simple built-in mechanism to stop events from further processing. </p> <p>Second, you need to make sure you send focus to the appropriate widget. There is built-in support for determining what the next widget is.</p> <p>For example:</p> <pre><code>def focus_next_window(event): event.widget.tk_focusNext().focus() return("break") text_widget=Text(...) text_widget.bind("&lt;Tab&gt;", focus_next_window) </code></pre> <p>Important points about this code:</p> <ul> <li>The method <code>tk_focusNext()</code> returns the next widget in the keyboard traversal hierarchy.</li> <li>the method <code>focus()</code> sets the focus to that widget</li> <li>returning <code>"break"</code> is critical in that it prevents the class binding from firing. It is this class binding that inserts the tab character, which you don't want.</li> </ul> <p>If you want this behavior for all text widgets in an application you can use the <code>bind_class()</code> method instead of <code>bind()</code> to make this binding affect all text widgets. </p> <p>You can also have the binding send focus to a very specific widget but I recommend sticking with the default traversal order, then make sure the traversal order is correct.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload