Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Is there any way to bind keys to a gui window in tkinter?
#1
Just like how you can bind keys to the widget, is it possible to bind certain key clicks that are performed when a certain window is open to a certain action?

Suppose, you want to focus between your widgets using arrow keys.

Googling didn't help but was wondering if you guys have any lead. Is this possible with tkinter at all? What are the alternatives?

If it's not possible, what are plausible alternatives? Presumably having a loop that constantly checks for whether a key is pressed and whether a window is active would be very resource tedious.


Also, forgetting the GUI aspect, how would you efficiently define hotkeys in Python? I assume there's a better way than a loop that checks the button's state every fraction of a second..
Quote
#2
you can set event types, see: http://infohost.nmt.edu/tcc/help/pubs/tk...types.html
then read about binding levels here: http://infohost.nmt.edu/tcc/help/pubs/tk...types.html
and event sequences here: http://infohost.nmt.edu/tcc/help/pubs/tk...ences.html

for hot keys, can't vouch for this, but: https://github.com/schurpf/pyhk
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [WxPython] Bind error PeterLinux 1 94 8 hours ago
Last Post: joe_momma
  Tkinter:Unable to bind and unbind function with a button shallanq 2 124 Mar-28-2020, 02:05 AM
Last Post: joe_momma
  Using Tkinter widgets on child window chewy1418 8 401 Feb-27-2020, 10:34 PM
Last Post: Marbelous
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 920 Jan-23-2020, 09:00 PM
Last Post: HBH
  [Tkinter] Mouse click event not working on multiple tkinter window evrydaywannabe 2 436 Dec-16-2019, 04:47 AM
Last Post: woooee
  [Tkinter] Window geometry appears different on Win and Linux steve_shambles 6 462 Nov-29-2019, 12:30 AM
Last Post: steve_shambles
  tkinter window and turtle window error 1885 3 618 Nov-02-2019, 12:18 PM
Last Post: 1885
  [Tkinter] Extrakt a Variable from a closed tkinter window hWp 5 568 Aug-23-2019, 09:01 PM
Last Post: woooee
  [Tkinter] Tkinter window pop up again when i click button Orimura_Sandy 1 906 May-12-2019, 08:17 PM
Last Post: joe_momma
  [Tkinter] Top Level Window - from tkinter import * francisco_neves2020 6 775 Apr-23-2019, 09:27 PM
Last Post: francisco_neves2020

Forum Jump:


Users browsing this thread: 1 Guest(s)