#!/usr/bin/env python

import gtk

ftr = None

class FileChooserButton:
    def __init__(self):
        window = gtk.Window()
        window.set_default_size(200, -1)
        self.filechooserbutton = gtk.FileChooserButton("Select A Folder", None)
        self.filechooserbutton.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
        self.filechooserbutton.connect("current-folder-changed", self.file_selected)

        window.connect("destroy", self.on_quit)
        window.add(self.filechooserbutton)
        window.show_all()
        print "Initial folderpath: %s" % self.filechooserbutton.get_filename()

    def file_selected(self, widget):
        print "Signal widget folderpath: %s" % widget.get_filename()
        print "Signal filechooser folderpath: %s" % self.filechooserbutton.get_filename()

    def on_quit(self, widget):
        print "Final folderpath: %s" % self.filechooserbutton.get_filename()
        gtk.main_quit()

FileChooserButton()
gtk.main()

