Created
November 1, 2020 18:23
-
-
Save secantsquared/60f68767c181c2448a6cf84003b371e6 to your computer and use it in GitHub Desktop.
click events in tkinter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
# Instantiate tkinter app | |
app = tk.Tk() | |
# Create example callback functions to use during click event | |
def leftclick(event): | |
print("left") | |
def middleclick(event): | |
print("middle") | |
def rightclick(event): | |
print("right") | |
# Create a basic frame | |
frame = Frame(var, width=300, height=250) | |
# Bind three buttons in the frame to the callbacks | |
frame.bind("<Button-1>", leftclick) | |
frame.bind("<Button-2>", middleclick) | |
frame.bind("<Button-3>", rightclick) | |
# Pack frame | |
frame.pack() | |
# Run main loop | |
app.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment