tkinter.Tk.bind("<ButtonPress>")


Definition
ButtonPress is sequence of a string of concatenated event patterns.

Syntax
tkinter.Tk.bind("<ButtonPress>")

Sequence
SEQUENCE is a string of concatenated event patterns. An event pattern is of the form <MODIFIER-MODIFIER-TYPE-DETAIL> where MODIFIER is one of Control, Mod2, M2, Shift, Mod3, M3, Lock, Mod4, M4, Button1, B1, Mod5, M5 Button2, B2, Meta, M, Button3, B3, Alt, Button4, B4, Double, Button5, B5 Triple, Mod1, M1. TYPE is one of Activate, Enter, Map, ButtonPress, Button, Expose, Motion, ButtonRelease FocusIn, MouseWheel, Circulate, FocusOut, Property, Colormap, Gravity Reparent, Configure, KeyPress, Key, Unmap, Deactivate, KeyRelease Visibility, Destroy, Leave and DETAIL is the button number for ButtonPress, ButtonRelease and DETAIL is the Keysym for KeyPress and KeyRelease.

Examples
The ButtonPress triggers the event which created new Tk widget while destroyed main Widget.
 from tkinter import*
import tkinter

def widget_Tk(buttonpress):
    master=Tk()
    master.title("Click Widget")
    master1.destroy()
    
master1=Tk()
master1.title("Main Widget")
master1.bind("<ButtonPress>", widget_Tk)

master1.mainloop()









Comments