且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python GTK3:如何创建Gtk.FileChooseDialog?

更新时间:2023-01-27 11:21:28

只需遵循说明并使用关键字参数.我也将按钮更改为使用.add_buttons(),因为这也引发了DeprecationWarning:

Simply follow out the instructions and use keyword arguments. I also changed the buttons to using .add_buttons() since that also threw a DeprecationWarning:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

dialog = Gtk.FileChooserDialog(
    title="Please choose a folder",
    action=Gtk.FileChooserAction.SELECT_FOLDER,
)

dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                   "Select", Gtk.ResponseType.OK)