Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
Created March 10, 2024 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vigilantPotato/120ebf17853f3f99dbb380afbaa0e5dc to your computer and use it in GitHub Desktop.
Save vigilantPotato/120ebf17853f3f99dbb380afbaa0e5dc to your computer and use it in GitHub Desktop.
how to change widge's state
import ctypes
import tkinter
def disable_10_times_clicked():
b["text"] = b["text"] + 1 #count click number
if b["text"] == 10:
b["state"] = "disable" #disable button
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
b = tkinter.Button(
root,
width=15,
text=0,
command=disable_10_times_clicked, #クリック時に実行する関数
)
b.pack()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment