Advertisement
Guest User

reddit

a guest
Jan 12th, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import *
  3.  
  4. class uLabel():
  5. def __init__(self, win):
  6. self.counter = -1
  7.  
  8. self.lab_tx = tk.StringVar()
  9. self.lab_tx.set("yest")
  10. tk.Label(win, textvariable = self.lab_tx, bg="yellow").grid(row=0, column=0)
  11. self.increase_counter()
  12.  
  13. tk.Button(win, text="Increase\n Counter",
  14. command = self.increase_counter, bg="lightblue"
  15. ).grid(row=1, column=0)
  16.  
  17.  
  18. def increase_counter(self):
  19. self.counter += 1
  20. self.lab_tx.set("counter = %d" % (self.counter))
  21. maping = ["M","M","P","M","T","F","P","E","F"]
  22. w = Label(root, text=maping[self.counter])
  23. w.grid(row=1, column=1)
  24.  
  25. root = tk.Tk()
  26. #maping = ["M","M","P","M","T","F","P","E","F"]
  27. #w = Label(root, text=maping[self.counter])
  28. #w.grid(row=1, column=1)
  29. root.geometry("350x400")
  30. ul=uLabel(root)
  31.  
  32. root.mainloop()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement