September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,13 +1,29 @@
|
|||
from Tkinter import Tk, Label, Button
|
||||
from functools import partial
|
||||
|
||||
def update_label():
|
||||
global n
|
||||
n += 1
|
||||
l["text"] = "Number of clicks: %d" % n
|
||||
import tkinter as tk
|
||||
|
||||
w = Tk()
|
||||
n = 0
|
||||
l = Label(w, text="There have been no clicks yet")
|
||||
l.pack()
|
||||
Button(w, text="click me", command=update_label).pack()
|
||||
w.mainloop()
|
||||
|
||||
def on_click(label: tk.Label,
|
||||
counter: tk.IntVar) -> None:
|
||||
counter.set(counter.get() + 1)
|
||||
label["text"] = f"Number of clicks: {counter.get()}"
|
||||
|
||||
|
||||
def main():
|
||||
window = tk.Tk()
|
||||
label = tk.Label(master=window,
|
||||
text="There have been no clicks yet")
|
||||
label.pack()
|
||||
counter = tk.IntVar()
|
||||
update_counter = partial(on_click,
|
||||
label=label,
|
||||
counter=counter)
|
||||
button = tk.Button(master=window,
|
||||
text="click me",
|
||||
command=update_counter)
|
||||
button.pack()
|
||||
window.mainloop()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue