LoginSignup
5
2

More than 5 years have passed since last update.

PySide QFileDialog ディレクトのみ選択する

Last updated at Posted at 2016-03-20

PySideでディレクトリのみを選択出来るダイアログを表示

表示して選択して、取得。

# ディレクリのみ選択可能なダイアログを表示(選択した値がdir_pathに入る)
dir_path = QFileDialog.getExistingDirectory(self)

# 第二引数はcaption / 第三引数は初期表示したいディレクリ(以下はユーザーのホーム)
dir_path = QFileDialog.getExistingDirectory(self, 'Open Directory', os.path.expanduser('~') )

表示したダイアログにファイルは表示しないようにするにはどうするんでしょうかね?

ファイルの取得は
getOpenFileName
getOpenFileNames
とかあるみたい。

参考:
https://srinikom.github.io/pyside-docs/PySide/QtGui/QFileDialog.html
http://d.hatena.ne.jp/hiramotoys/20101020/1287584018

5
2
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
5
2