Gtk.FileChooseDialogを正しく作成する方法は?Python GTK3:Gtk.FileChooseDialogを作成するには?
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
dialog = Gtk.FileChooserDialog("Please choose a folder", None,
Gtk.FileChooserAction.SELECT_FOLDER,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
"Select", Gtk.ResponseType.OK))
しかし、あなたは(非推奨警告をキャッチする)python -W error
でこれを実行した場合、それは言う::
This popular tutorialは、次のようなコードを使用すると言うGtk.FileChooserDialog.new
を使用し
File "test3.py", line 8, in <module>
"Select", Gtk.ResponseType.OK))
File "/usr/lib/python2.7/dist-packages/gi/overrides/__init__.py", line 287, in new_init
category, stacklevel=stacklevel)
gi.overrides.Gtk.PyGTKDeprecationWarning: Using positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "title, parent, action, buttons" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecations
がTypeError: Dialog constructor cannot be used to create instances of a subclass FileChooserDialog
を与えます。
The APIはコンストラクタについて何も言いません。奇妙な。
ps:この質問に対する回答は、python -W error
と一致する必要があります。非難されたAPIに依存するべきではありません。それは私に求めているのです。