現在、Tkinterを使用してユーザーにファイルの入力を求めています。
Tk().withdraw() # keep the root window from appearing
file_path = askopenfilename() # show dialog box and return file path
# check if extension is valid
ユーザーが間違ったファイルタイプを選択した場合は、新しいウィンドウで再度プロンプトを表示します。
代わりに、選択したファイルが有効でない限り、同じtkinterウィンドウを開いたままにする方法はありますか?
だからこれの代わりに:
# 1) prompt user to open file
# 2) close file browser window
# 3) check if extension is valid
# 4) if not, print error and re-prompt user with new browser window
私はこれをしたい:
# 1) prompt user to open file
# 2) check if extension is valid while keeping window open
# 3) if not, print error, re-prompting with same window
どんな助けでも大歓迎です。