Merge pull request #715 from campagnola/file-dialog-fix

File dialog fix
This commit is contained in:
Luke Campagnola 2018-06-25 09:39:47 -07:00 committed by GitHub
commit 3d3d0a2459
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 8 deletions

View File

@ -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 = 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, str(filename))
def load(self):
fn = str(pg.QtGui.QFileDialog.getOpenFileName(self, "Save State..", "", "Config Files (*.cfg)"))
if fn == '':
filename = 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(str(filename))
self.loadState(state)
def loadPreset(self, param, preset):

View File

@ -790,9 +790,11 @@ 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)
self.export(str(fileName))
def buildMenu(self):
self.menu = QtGui.QMenu()

View File

@ -351,9 +351,11 @@ 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)
open(str(fileName), 'w').write(data)
def contextMenuEvent(self, ev):
self.contextMenu.popup(ev.globalPos())