Created
March 10, 2024 21:51
-
-
Save vigilantPotato/120ebf17853f3f99dbb380afbaa0e5dc to your computer and use it in GitHub Desktop.
how to change widge's state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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