How to hide a Gtk+ FileChooserDialog in Python 3.4?

假如想象 提交于 2019-12-05 08:28:27

You can set up a window first by doing:

def __init__ (self):

  [.. snip ..]

  w = Gtk.Window ()

  dia = Gtk.FileChooserDialog("Please choose a file", w,
        Gtk.FileChooserAction.OPEN,
        (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
         Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

also, set a default value for path in case the user cancels:

  path = ''

Then, at the end of your script:

print (path)

while Gtk.events_pending ():
  Gtk.main_iteration ()

print ("done")

to collect and handle all events.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!