- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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
How to bind to shift+tab in Tkinter?
Tkinter Events are very useful for any application where we need to perform a certain task or action. In Tkinter, the events are generally created by defining the function which contains the piece of code and the logic for the certain event. To call the event, we generally bind the Event with some Keys or a Button widget. The bind function takes two parameters ('<Key-Combination>', callback) which enable the button to trigger the event.
Using the same approach in the following example, we will trigger a popup message by pressing the key combination <Shift + Tab>.
Example
# Import the required libraries from tkinter import * from tkinter import messagebox # Create an instance of tkinter frame win= Tk() # Set the size of the tkinter window win.geometry("700x350") # Define a function to show the popup message def show_msg(e): messagebox.showinfo("Message","Hey There! I hope you are doing well.") # Add an optional Label widget Label(win, text = "Admin Has Sent You a Message. " "Press <Shift+Tab> to View the Message.", font = ('Aerial 15')).pack(pady= 40) # Bind the Shift+Tab key with the event win.bind('<Shift-Tab>', lambda e: show_msg(e)) win.mainloop()
Output
When we execute the above program, it will display a window containing a label widget. When we press the key combination <Shift + Tab>, it will pop up a message on the screen.
- Related Articles
- How to bind multiple events with one "bind" in Tkinter?
- How to bind events to Tkinter Canvas items?
- How to bind a key to a button in Tkinter?
- How to bind all the number keys in Tkinter?
- How to bind a click event to a Canvas in Tkinter?
- How to bind the Enter key to a tkinter window?
- How to bind the spacebar key to a certain method in Tkinter?
- How to bind the Escape key to close a window in Tkinter?
- How to set the tab order in a Tkinter application?
- How to remove Ttk Notebook Tab Dashed Line? (tkinter)
- How do I bind the enter key to a function in Tkinter?
- How to bind a Tkinter event to the left mouse button being held down?
- How to bind attributes in VueJS?
- How to Bind a Book?
- Change the color of "tab header" in ttk.Notebook (tkinter)

Advertisements