-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdialogs.py
31 lines (24 loc) · 982 Bytes
/
dialogs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from os.path import splitext, dirname
def saveDialog(parent):
"""Shows a save file dialog and return the selected file path."""
settings = QSettings()
key = '/UI/lastShapefileDir'
outDir = settings.value(key)
filter = 'Shapefiles (*.shp)'
outFilePath = QFileDialog.getSaveFileName(parent, parent.tr('Save output shapefile'), outDir, filter)
outFilePath = unicode(outFilePath)
if outFilePath:
root, ext = splitext(outFilePath)
if ext.upper() != '.SHP':
outFilePath = '%s.shp' % outFilePath
outDir = dirname(outFilePath)
settings.setValue(key, outDir)
return outFilePath
def openDir(parent):
settings = QSettings()
key = '/UI/lastShapefileDir'
outDir = settings.value(key)
outPath = QFileDialog.getExistingDirectory(parent, 'Generalizer', outDir)#, QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
return outPath