forked from p0cisk/Generalizer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
dialogs.py
33 lines (26 loc) · 1.02 KB
/
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
32
33
from builtins import str
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets 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 = 'GeoPackage (*.gpkg)'
outFilePath, __ = QFileDialog.getSaveFileName(parent, parent.tr('Save output GeoPackage'), outDir, filter)
outFilePath = str(outFilePath)
if outFilePath:
root, ext = splitext(outFilePath)
if ext.upper() != '.GPKG':
outFilePath = '%s.gpkg' % 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