回答編集履歴

2

typo修正

2022/06/10 05:02

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -21,7 +21,7 @@
21
21
  ```python
22
22
  import tkinter as tk
23
23
 
24
- def sub_window(event=Non):
24
+ def sub_window(event=None):
25
25
  print("sub-window")
26
26
 
27
27
 

1

キーボード操作に対応

2022/06/10 05:02

投稿

teamikl
teamikl

スコア8664

test CHANGED
@@ -21,7 +21,7 @@
21
21
  ```python
22
22
  import tkinter as tk
23
23
 
24
- def sub_window(event):
24
+ def sub_window(event=Non):
25
25
  print("sub-window")
26
26
 
27
27
 
@@ -40,9 +40,11 @@
40
40
 
41
41
 
42
42
  root = tk.Tk()
43
- main_btn = tk.Button(root, width=30, height=3, text="SUB-WINDOW")
43
+ main_btn = tk.Button(root, width=30, height=3, text="SUB-WINDOW", command=sub_window)
44
44
  main_btn.pack(padx=50, pady=50)
45
45
  main_btn.bind("<ButtonRelease>", leave_skip_event)
46
- main_btn.bind("<ButtonRelease>", sub_window, add="+")
46
+ # main_btn.bind("<ButtonRelease>", sub_window, add="+")
47
47
  root.mainloop()
48
48
  ```
49
+
50
+ 追記: キーボード操作に対応