'School assignment Tkinter with method triple button
all I need in tkinter help, cos when you click with mouse three times read as once in counter. I know about it. I tried a couple of methods in mouse-event and I try with My current code. Tnx for your help in advance
from tkinter import *
counter=0
def mouse_click(event):
global counter
print('Counter is ',counter)
counter+=1
window = Tk()
window.minsize(300, 100)
label = Label( window, text="Click here")
label.pack()
label.bind( "<Double-Button>", mouse_click)
window.mainloop()
I have found a solution to this code thanks to everyone who tried
from tkinter import *
counter = 0
def mouse_click_times(event):
global counter
print("You press triple button times: ",counter)
counter +=1
windows = Tk()
windows.minsize(400,250)
label = Label(windows, text = "Click me 3x: ",bg = "blue", fg = "white")
label.pack()
label.bind("<Triple-Button-1>",mouse_click_times)
windows["bg"]="green"
exit_from_tkinter_loop = Button(windows, text="Exit from window", bg =
"blue", fg = "white",command=windows.destroy)
exit_from_tkinter_loop.pack(pady = 20)
windows.mainloop()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
