Skip to content

Commit 2a9e0ae

Browse files
committed
[pyqgis-console] enables to select multiple files to load in the file editor
1 parent 75896d9 commit 2a9e0ae

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

python/console/console.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -612,21 +612,22 @@ def uncommentCode(self):
612612
def openScriptFile(self):
613613
lastDirPath = self.settings.value("pythonConsole/lastDirPath").toString()
614614
openFileTr = QCoreApplication.translate("PythonConsole", "Open File")
615-
filename = QFileDialog.getOpenFileName(
615+
fileList = QFileDialog.getOpenFileNames(
616616
self, openFileTr, lastDirPath, "Script file (*.py)")
617-
if not filename.isEmpty():
618-
for i in range(self.tabEditorWidget.count()):
619-
tabWidget = self.tabEditorWidget.widget(i)
620-
if tabWidget.path == filename:
621-
self.tabEditorWidget.setCurrentWidget(tabWidget)
622-
break
623-
else:
624-
tabName = filename.split('/')[-1]
625-
self.tabEditorWidget.newTabEditor(tabName, filename)
626-
627-
lastDirPath = QFileInfo(filename).path()
628-
self.settings.setValue("pythonConsole/lastDirPath", QVariant(filename))
629-
self.updateTabListScript(filename, action='append')
617+
if not fileList.isEmpty():
618+
for pyFile in fileList:
619+
for i in range(self.tabEditorWidget.count()):
620+
tabWidget = self.tabEditorWidget.widget(i)
621+
if tabWidget.path == pyFile:
622+
self.tabEditorWidget.setCurrentWidget(tabWidget)
623+
break
624+
else:
625+
tabName = QFileInfo(pyFile).fileName()
626+
self.tabEditorWidget.newTabEditor(tabName, pyFile)
627+
628+
lastDirPath = QFileInfo(pyFile).path()
629+
self.settings.setValue("pythonConsole/lastDirPath", QVariant(pyFile))
630+
self.updateTabListScript(pyFile, action='append')
630631

631632
def saveScriptFile(self):
632633
tabWidget = self.tabEditorWidget.currentWidget()

0 commit comments

Comments
 (0)