質問編集履歴
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,9 +32,9 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
def clicked():
|
35
|
+
def clicked(event):
|
36
36
|
|
37
|
-
|
37
|
+
event.widget["state"] = tk.DISABLED
|
38
38
|
|
39
39
|
|
40
40
|
|
1
要求
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,41 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
**.bindメソッドを用いていてもボタンを無効化できる方法を教えてください。**
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
例(実際のコードは長くなり過ぎてしまうので簡易的に再現すると)
|
28
|
+
|
29
|
+
```python
|
30
|
+
|
31
|
+
import tkinter as tk
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def clicked():
|
36
|
+
|
37
|
+
bt.widget["state"] = tk.DISABLED
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
root = tk.Tk()
|
42
|
+
|
43
|
+
root.title("test")
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
bt = [[tk.Button(root) for i in range(3)] for j in range(3)]
|
48
|
+
|
49
|
+
for i in range(3):
|
50
|
+
|
51
|
+
for j in range(3):
|
52
|
+
|
53
|
+
bt[j][i].grid(column=i, row=j)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
root.bind("<1>", clicked)
|
58
|
+
|
59
|
+
root.mainloop()
|
60
|
+
|
61
|
+
```
|