Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Control the application using the keyboard
I have a problem with key control in my tkinter app. After pressing the key ("Enter", →, ←, +, Ctrl+S) I want to do my function. How do I set this control after pressing these keys? For example here is the scheme of the program (not my app):
from tkinter import*
app = Tk()

def MyFunction(x):   #I want to do this after pressing "Enter"

def MyFunction2(y):   #I want to do this after pressing "→"
    y = y + 1
    return y

def MyFunction3(z):   #I want to do this after pressing "Ctrl+S"
    return z**2

def MyFunction4(a):   #I want to do this after pressing "+"

There are excellent sections on keyboard events in this manual:
This is John Shipman's manual which used to be available at New Mexico Tech, but no longer.
It's rather dated, but still the best tkinter doc available (In my opinion)
see section 54 starting on page 157, all of the keyboard scan codes are in the table beginning on page 161
How to bind them in writeup prior to table
buran likes this post

Top Page

Forum Jump:

Users browsing this thread: 1 Guest(s)