- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Keyboard shortcuts with Tkinter in Python 3
Tkinter window contains many inbuilt functionalities and features which can be taken and used for various application development. There might be cases when we have to run a particular part of the application with the help of some key or function. It can be achieved by binding a particular key with the callback that contains the functions for the operation. The key can be anything from Mouse Buttons to Keyboard Keys. We can even bind the callback with Keyboard Key Combinations.
#Import the Tkinter Library from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry of window win.geometry("700x350") #Define a callback function for exit def quit_program(e): win.destroy() #Add a Label widget label = Label(win, text= "Press Ctrl + x to Exit", font= ('Helvetica 15 bold')) label.pack(pady= 40) #Bind the Keyboard shortcut Key win.bind('<Control-x>', quit_program) win.mainloop()
In the above code, we have added a combination of Keys. Pressing the keys will close the window.
- Tkinter dropdown Menu with keyboard shortcuts
- Top Keyboard Shortcuts For Mozilla Firefox
- Top Keyboard Shortcuts for Google Chrome
- How to disable the keyboard shortcuts in Matplotlib?
- Top Keyboard Shortcuts For Mozilla Firefox Browser
- Keyboard module in Python
- Select all text in a Text widget using Python 3 with tkinter
- Reading Keyboard Input in Python
- Single-Row Keyboard in python
- Tkinter button commands with lambda in Python
- How to add all borders to cells with shortcuts in Excel
- Mouse and keyboard automation using Python?
- Interfacing 8279 Keyboard with 8085 Microprocessor
- Program to find out the length between two cities in shortcuts in Python
- How to get a string from a tkinter filedialog in Python 3?