Handle Qt4/5 API difference in filedialog
This commit is contained in:
parent
c4a5ffa01c
commit
3fd56eb195
@ -159,17 +159,21 @@ class RelativityGUI(QtGui.QWidget):
|
||||
self.setAnimation(self.params['Animate'])
|
||||
|
||||
def save(self):
|
||||
fn = str(pg.QtGui.QFileDialog.getSaveFileName(self, "Save State..", "untitled.cfg", "Config Files (*.cfg)"))
|
||||
if fn == '':
|
||||
filename = str(pg.QtGui.QFileDialog.getSaveFileName(self, "Save State..", "untitled.cfg", "Config Files (*.cfg)"))
|
||||
if isinstance(filename, tuple):
|
||||
filename = filename[0] # Qt4/5 API difference
|
||||
if filename == '':
|
||||
return
|
||||
state = self.params.saveState()
|
||||
pg.configfile.writeConfigFile(state, fn)
|
||||
pg.configfile.writeConfigFile(state, filename)
|
||||
|
||||
def load(self):
|
||||
fn = str(pg.QtGui.QFileDialog.getOpenFileName(self, "Save State..", "", "Config Files (*.cfg)"))
|
||||
if fn == '':
|
||||
filename = str(pg.QtGui.QFileDialog.getOpenFileName(self, "Save State..", "", "Config Files (*.cfg)"))
|
||||
if isinstance(filename, tuple):
|
||||
filename = filename[0] # Qt4/5 API difference
|
||||
if filename == '':
|
||||
return
|
||||
state = pg.configfile.readConfigFile(fn)
|
||||
state = pg.configfile.readConfigFile(filename)
|
||||
self.loadState(state)
|
||||
|
||||
def loadPreset(self, param, preset):
|
||||
|
@ -790,6 +790,8 @@ class ImageView(QtGui.QWidget):
|
||||
|
||||
def exportClicked(self):
|
||||
fileName = QtGui.QFileDialog.getSaveFileName()
|
||||
if isinstance(fileName, tuple):
|
||||
fileName = fileName[0] # Qt4/5 API difference
|
||||
if fileName == '':
|
||||
return
|
||||
self.export(fileName)
|
||||
|
@ -351,6 +351,8 @@ class TableWidget(QtGui.QTableWidget):
|
||||
|
||||
def save(self, data):
|
||||
fileName = QtGui.QFileDialog.getSaveFileName(self, "Save As..", "", "Tab-separated values (*.tsv)")
|
||||
if isinstance(fileName, tuple):
|
||||
fileName = fileName[0] # Qt4/5 API difference
|
||||
if fileName == '':
|
||||
return
|
||||
open(fileName, 'w').write(data)
|
||||
|
Loading…
Reference in New Issue
Block a user