def __init__(self): QtGui.QDialog.__init__(self) self.ui = Ui_db_location() self.ui.setupUi(self) # Using Qt's version as os.path.expanduser('~') fails on WinPython self.initial_dir = os.path.abspath(os.path.join( QtCore.QDir.homePath(),'AssetJetData')) self.ui.location.setText(self.initial_dir) self.ui.button_change.clicked.connect(self.selectDir)
class DbLocation(QtGui.QDialog): def __init__(self): QtGui.QDialog.__init__(self) self.ui = Ui_db_location() self.ui.setupUi(self) # Using Qt's version as os.path.expanduser('~') fails on WinPython self.initial_dir = os.path.abspath(os.path.join( QtCore.QDir.homePath(),'AssetJetData')) self.ui.location.setText(self.initial_dir) self.ui.button_change.clicked.connect(self.selectDir) def selectDir(self): QtGui.QFileDialog.whatsThis = False reply = QtGui.QFileDialog.getExistingDirectory(None, 'Select Directory', self.initial_dir) if reply: # Leave the path unchanged if the users cancels self.ui.location.setText(reply) def getText(self): return self.ui.location.text()