Ubuntu 如何从PyGTK中的FileChooserButton获取文件名?

Ubuntu 如何从PyGTK中的FileChooserButton获取文件名?,ubuntu,pygtk,glade,filechooser,Ubuntu,Pygtk,Glade,Filechooser,我正在使用Glade和PyGtk开发一个应用程序。目前,我正在使用工具栏下的按钮打开文件,代码如下: def on_openVideo_clicked(self, widget): dialog = Gtk.FileChooserDialog("Please choose a video", self, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseTy

我正在使用Glade和PyGtk开发一个应用程序。目前,我正在使用工具栏下的按钮打开文件,代码如下:

    def on_openVideo_clicked(self, widget):
        dialog = Gtk.FileChooserDialog("Please choose a video", self,
            Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

        self.add_vfilters(dialog)
        dialog.set_current_folder('/home')  
        response = dialog.run()

        if response == Gtk.ResponseType.OK:
            self.videoInput = dialog.get_preview_filename()
            print "Video file Choosen: ", self.videoInput
        elif response == Gtk.ResponseType.CANCEL:
            print 'Cancel Clicked'           

        dialog.destroy()
但我决定用FileChooserButton替换它,因为它有更好的可视化效果。但我不知道如何打印文件名。我猜应该是这样的:

def on_filechooserbutton_file_set(self, widget):
        print widget.get_filename()

但这不起作用。所以我的问题是如何从filechooserbutton中检索文件名?

这段代码有效:

def on_filechooserbutton_file_set(self, widget):
        self.videoInput = widget.get_filename()
        print "Video file Choosen: ", self.videoInput