回答編集履歴
1
global変数を使わない形に修正
test
CHANGED
@@ -5,15 +5,16 @@
|
|
5
5
|
for i in range(5):
|
6
6
|
print(i)
|
7
7
|
if i == 2:
|
8
|
-
sub_window()
|
8
|
+
sub_win = sub_window()
|
9
9
|
root.wait_window(sub_win) # サブウィンドウが閉じられるのを待つ
|
10
10
|
|
11
11
|
def sub_window():
|
12
|
-
global sub_win
|
12
|
+
# global sub_win
|
13
13
|
sub_win = Toplevel(root) # Toplevelを使用
|
14
14
|
sub_win.geometry("300x100")
|
15
15
|
sub_button = Button(sub_win, text="閉じる", command=sub_win.destroy)
|
16
16
|
sub_button.pack()
|
17
|
+
return sub_win
|
17
18
|
|
18
19
|
root = Tk()
|
19
20
|
root.title("tkinterによるGUI画面作成")
|