質問するログイン新規登録

質問編集履歴

1

コードの追記

2019/07/22 06:37

投稿

y20190719
y20190719

スコア12

title CHANGED
File without changes
body CHANGED
@@ -76,4 +76,87 @@
76
76
  1)で開始ボタンが押されるまで、2)以降の処理を実行しないようにするには、
77
77
  どのように記述すればよいのでしょうか。できましたら、
78
78
  グローバル変数を使用しない方法でお願いします。
79
- (Windows10,Python 3.7.3)
79
+ (Windows10,Python 3.7.3)
80
+
81
+ 【追記】
82
+
83
+ ●list1
84
+ ```Python
85
+ import tkinter
86
+ import win32api
87
+
88
+ def pushed1():
89
+ root1.destroy()
90
+
91
+ def pushed2():
92
+ root2.destroy()
93
+
94
+ #メイン処理
95
+
96
+ # 1) 開始処理
97
+ root1=tkinter.Tk()
98
+ root1.title('開始')
99
+ root1.geometry('300x200')
100
+ label1=tkinter.Label(root1,text='実行を開始します')
101
+ label1.grid()
102
+ button1=tkinter.Button(root1,text='開始',command=lambda : pushed1())
103
+ button1.grid()
104
+
105
+ root1.mainloop()
106
+
107
+ # 2) 本処理
108
+ win32api.Sleep(10000)
109
+
110
+ # 3) 終了処理
111
+ root2=tkinter.Tk()
112
+ root2.title('終了')
113
+ root2.geometry('300x200')
114
+ label2=tkinter.Label(root2,text='終了しました')
115
+ label2.grid()
116
+ button2=tkinter.Button(root2,text='完了',command=lambda : pushed2())
117
+ button2.grid()
118
+
119
+ root2.mainloop()
120
+
121
+ print('END')
122
+ ```
123
+ ●list2
124
+ ```Python
125
+ import tkinter
126
+ import win32api
127
+
128
+ def pushed1():
129
+ root1.destroy()
130
+
131
+ def pushed2():
132
+ root2.destroy()
133
+
134
+ #メイン処理
135
+
136
+ # 1) 開始処理
137
+ root1=tkinter.Tk()
138
+ root1.title('開始')
139
+ root1.geometry('300x200')
140
+ label1=tkinter.Label(root1,text='実行を開始します')
141
+ label1.grid()
142
+ button1=tkinter.Button(root1,text='開始',command=lambda : pushed1())
143
+ button1.grid()
144
+ root1.grab_set()
145
+ root1.wait_window(root1)
146
+
147
+ # 2) 本処理
148
+ win32api.Sleep(10000)
149
+
150
+ # 3) 終了処理
151
+ root2=tkinter.Tk()
152
+ root2.title('終了')
153
+ root2.geometry('300x200')
154
+ label2=tkinter.Label(root2,text='終了しました')
155
+ label2.grid()
156
+ button2=tkinter.Button(root2,text='完了',command=lambda : pushed2())
157
+ button2.grid()
158
+ root2.grab_set()
159
+ root2.wait_window(root2)
160
+
161
+ print('END')
162
+ ```