0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pywinautoをインポートしている時にtkinterのfiledialog.askdirectory()が使えない話

Posted at

問題

tkinterのフォルダ選択ダイアログを開くメソッドとしてfiledialog.askdirectory()がある。
tkinterのfiledialog.askdirectory()とpywinautoを同時に実行するとフリーズする。

解決策

こちらのissueが参考になった
https://github.com/pywinauto/pywinauto/issues/517

要約するとpywinautoとaskdirectory()でCOMのスレッドの立て方が異なるために干渉するらしい。

以下のようにすればいいらしい

import sys
sys.coinit_flags = 2  #これを挿入

import pywinauto
import tkinter.filedialog
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?