Wie mache ich die Häufigkeit, mit der ein bestimmter Schaltfläche in der Shell in Python Tkinter geklickt wurde?Python

Python-Programme
Anonymous
 Wie mache ich die Häufigkeit, mit der ein bestimmter Schaltfläche in der Shell in Python Tkinter geklickt wurde?

Post by Anonymous »

meine GUI ist also voll funktionsfähig, außer dass ich in der Konsole in der Konsole von Klicken jeder verschiedenen Taste aufbewahren möchte (z. B. "Die Schaltfläche" Gefällt mir wurde "und" Die UM -Schaltfläche wurde auf Y Times geklickt "). Ich habe erfolglos versucht, mein Problem ist, dass nichts tatsächlich in der Konsole gedruckt wird. < /P>
Kann jemand darauf hinweisen, wie man dies richtig ausführt? Danke. < /P>

Code: Select all

from tkinter import *
import tkinter as tk

window = tk.Tk()
window.geometry('900x900')
window.config(bg = 'honeydew2')
window.title('The Speech Filler Counter')

like = 0
def likes():
global like
like = like + 1
likelabel.configure(text=like)

likelabel = tk.Label(window, text = like, bg = 'honeydew2', fg = 'red')
likelabel.place(x = 22, y = 1)

likebutton = tk.Button(window, text="Like", activebackground= 'blue', activeforeground = 'honeydew2', bg = 'deep sky blue', fg = 'red', command=likes).place(x= 2, y = 25)

um = 0
def ums():
global um
um = um + 1
umlabel.configure(text = um)

umlabel = tk.Label(window, text = um, bg = 'honeydew2', fg = 'cyan')
umlabel.place(x = 122, y = 1 )

umbutton = tk.Button(window, text="Um", activebackground= 'brown', activeforeground = 'honeydew2', bg = 'light pink', fg = 'blue', command=ums).place(x= 100, y = 25)

basically = 0
def basicallys():
global basically
basically = basically + 1
baslabel.configure(text = basically)

baslabel = tk.Label(window, text = basically, bg = 'honeydew2', fg = 'deep pink')
baslabel.place(x = 235, y = 1 )

basbutton = tk.Button(window, text="Basically", activebackground= 'red', activeforeground = 'black', bg = 'gold', fg = 'brown', command=basicallys).place(x= 200, y = 25)

uh = 0
def uhs():
global uh
uh = uh + 1
uhlabel.configure(text = uh)

uhlabel = tk.Label(window, text = uh, bg = 'honeydew2', fg = 'lime green')
uhlabel.place(x = 350, y = 1 )

uhbutton = tk.Button(window, text="Uh", activebackground= 'purple2', activeforeground = 'goldenrod1', bg = 'firebrick1', fg = 'blue2', command=uhs).place(x= 335, y = 25)

youknow = 0
def youknows():
global youknow
youknow = youknow + 1
youknowlab.configure(text = youknow)

youknowlab = tk.Label(window, text = youknow, bg = 'honeydew2', fg = 'SlateBlue1')
youknowlab.place(x = 455, y = 1 )

youknowbutton = tk.Button(window, text="You know", activebackground= 'DarkOrange1', activeforeground = 'DeepSkyBlue1', bg = 'hot pink', fg = 'lemon chiffon', command=youknows).place(x= 425, y = 25)

ok = 0
def oks():
global ok
ok = ok + 1
oklabel.configure(text = ok)

oklabel = tk.Label(window, text = ok, bg = 'honeydew2', fg = 'blue2')
oklabel.place(x = 595, y = 1 )

okbutton = tk.Button(window, text="Ok", activebackground= 'midnight blue', activeforeground = 'SeaGreen2', bg = 'SlateBlue2', fg = 'magenta2', command=oks).place(x= 575, y = 25)

print(f"um: {(um)}")
print(f"like: {like}")
print(f"uh: {uh}")
print(f"basically: {basically}")
print(f"ok: {ok}")
print(f"youknow: {youknow}")

window.mainloop()

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post