[pyqgis-console] added button to toggle the side editor in python console

This commit is contained in:
Salvatore Larosa 2013-04-13 15:20:47 +02:00
parent 09fe728104
commit 708a99c15b
4 changed files with 28 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

View File

@ -123,6 +123,17 @@ class PythonConsoleWidget(QWidget):
sizes = self.splitter.sizes()
self.splitter.setSizes(sizes)
## Action Show Editor
showEditor = QCoreApplication.translate("PythonConsole", "Show editor")
self.showEditorButton = QAction(parent)
self.showEditorButton.setCheckable(False)
self.showEditorButton.setEnabled(True)
self.showEditorButton.setCheckable(True)
self.showEditorButton.setIcon(QgsApplication.getThemeIcon("console/iconShowEditorConsole.png"))
self.showEditorButton.setMenuRole(QAction.PreferencesRole)
self.showEditorButton.setIconVisibleInMenu(True)
self.showEditorButton.setToolTip(showEditor)
self.showEditorButton.setText(showEditor)
## Action for Clear button
clearBt = QCoreApplication.translate("PythonConsole", "Clear console")
self.clearButton = QAction(parent)
@ -255,10 +266,13 @@ class PythonConsoleWidget(QWidget):
self.toolBar.setFloatable(True)
self.toolBar.addAction(self.clearButton)
self.toolBar.addAction(self.actionClass)
self.toolBar.addAction(self.runButton)
self.toolBar.addSeparator()
self.toolBar.addAction(self.showEditorButton)
self.toolBar.addAction(self.actionScript)
self.toolBar.addSeparator()
self.toolBar.addAction(self.optionsButton)
self.toolBar.addAction(self.helpButton)
self.toolBar.addAction(self.runButton)
## Menu Import Class
self.classMenu = QMenu(self)
@ -309,6 +323,7 @@ class PythonConsoleWidget(QWidget):
##------------ Signal -------------------------------
self.showEditorButton.toggled.connect(self.toggleEditor)
self.clearButton.triggered.connect(self.shellOut.clearConsole)
self.optionsButton.triggered.connect(self.openSettings)
self.loadSextanteButton.triggered.connect(self.sextante)
@ -330,7 +345,13 @@ class PythonConsoleWidget(QWidget):
def qtGui(self):
self.shell.commandConsole('qtGui')
def toggleEditor(self, checked):
self.tabEditorWidget.show() if checked else self.tabEditorWidget.hide()
self.openFileButton.setEnabled(checked)
self.saveFileButton.setEnabled(checked)
self.saveAsFileButton.setEnabled(checked)
# def openScriptFile(self):
# settings = QSettings()
# lastDirPath = settings.value("pythonConsole/lastDirPath").toString()

View File

@ -325,6 +325,7 @@ class Editor(QsciScintilla):
self.parent.pc.openFileButton.setEnabled(False)
self.parent.pc.saveFileButton.setEnabled(False)
self.parent.pc.saveAsFileButton.setEnabled(False)
self.parent.pc.showEditorButton.setChecked(False)
def runScriptCode(self):
tabWidget = self.parent.mw.currentWidget()
@ -646,8 +647,9 @@ class EditorTabWidget(QTabWidget):
def restoreTabs(self):
for script in self.restoreTabList:
pathFile = str(script.toString())
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
if os.path.exists(pathFile):
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
self.topFrame.close()
def closeRestore(self):

View File

@ -227,6 +227,7 @@ class ShellOutputScintilla(QsciScintilla):
self.parent.openFileButton.setEnabled(True)
self.parent.saveFileButton.setEnabled(True)
self.parent.saveAsFileButton.setEnabled(True)
self.parent.showEditorButton.setChecked(True)
self.shell.setFocus()
def copy(self):