実現したいこと
起動中画面を表示して、初期設定を行った後、起動中画面を消し、プログラム本体に進みたい。
初期設定に20秒~30秒かかるので、その間、無反応状態にならないよう、
「検査ソフト起動中」の画面を表示したままにしたい。
前提
Pythonを独学で学習し始めて、約3か月の初心者です。
windows11+Python+Tkinter
簡単なPySimpleGUIでプログラム開発していたが、PySimpleGUIで越えられない問題が出たので、
Tkinterで同様の表現ができないか試行錯誤しています。
発生している問題・エラーメッセージ
エラーメッセージはありません。 「検査ソフト起動中」の画面が表示されないまま、初期設定に進む。
該当のソースコード
import tkinter as tk import cv2 root = tk.Tk() root.title('Window Title') root.overrideredirect(True) root.attributes('-topmost', True) text1 = tk.Label(root, text=' ') text2 = tk.Label(root, text='検査ソフト起動中', font=('Helvetica', 20), justify='center') text3 = tk.Label(root, text=' ') text1.pack() text2.pack() text3.pack() root.update_idletasks() width = root.winfo_width() height = root.winfo_height() x = (root.winfo_screenwidth() // 2) - (width // 2) y = (root.winfo_screenheight() // 2) - (height // 2) root.geometry('{}x{}+{}+{}'.format(width, height, x, y)) cap = cv2.VideoCapture(0) # 初期設定例 ret, frame = cap.read() # 初期設定例 cap.release() cv2.destroyAllWindows() root.destroy()
試したこと
初期設定の前に
root.after(5000, root.destroy)
root.mainloop()
などといれると、「検査ソフト起動中」の画面が表示されるが、その画面が消えてから初期設定が始まる。
Webで検索しても、monicaで質問しても、解決策を見つけられませんでした。
補足情報(FW/ツールのバージョンなど)
環境:
i5-7400 16GBメモリ 256GBSSD QuadroP600Video Windows11
VSCode 1.81.1 Python 3.11.4 Opencv-python 4.7.0.72

回答1件
あなたの回答
tips
プレビュー