35 lines
824 B
Python
35 lines
824 B
Python
|
#! /usr/bin/python
|
||
|
|
||
|
# To change this template, choose Tools | Templates
|
||
|
# and open the template in the editor.
|
||
|
|
||
|
__author__="bjschuma"
|
||
|
__date__ ="$May 16, 2010 7:21:50 PM$"
|
||
|
|
||
|
import gtk
|
||
|
|
||
|
|
||
|
class FileChooser(gtk.FileChooserDialog):
|
||
|
def __init__(self,title,file=None,seldir=False):
|
||
|
buttons = (gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK)
|
||
|
action=gtk.FILE_CHOOSER_ACTION_OPEN
|
||
|
gtk.FileChooserDialog.__init__(self,title,None,action=action,buttons=buttons)
|
||
|
|
||
|
if file != None:
|
||
|
self.select_filename(file)
|
||
|
|
||
|
if seldir == True:
|
||
|
self.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
|
||
|
|
||
|
|
||
|
def choose(self):
|
||
|
response = self.run()
|
||
|
self.hide()
|
||
|
file = ""
|
||
|
#print response
|
||
|
if response == gtk.RESPONSE_OK:
|
||
|
file = self.get_filename()
|
||
|
if response != gtk.RESPONSE_OK:
|
||
|
return None
|
||
|
return file
|