Tkinterでアプリを作成中です。
メイン画面で実行ボタン押下後for文で処理をループ、ある条件を満たしたときに
サブウィンドウを表示させfor文を一時停止、サブウィンドウを閉じたときにfor文を再開したいのですが、うまくいきません。
下記例文で、実行ボタンを押下し0,1,2出力後、サブウィンドウを閉じ3,4を出力(for文を再開)させたいです。解決策をご教授ください。
from tkinter import *
def main():
for i in range(5):
if i == 3:
sub_window()
print(i)
def sub_window():
sub_win = Tk()
sub_win.geometry("300x100")
sub_button = Button(sub_win, text="閉じる", command=lambda:sub_win.destroy())
sub_button.pack()
sub_win.mainloop()
root = Tk()
root.title("tkinterによるGUI画面作成")
root.geometry("300x100")
button = Button(root, text="実行", command=main)
button.pack()
root.mainloop()

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/08/20 03:46