Skip to content

Commit

Permalink
[pyqgis-console] added button to toggle the side editor in python con…
Browse files Browse the repository at this point in the history
…sole
  • Loading branch information
slarosa committed Apr 16, 2013
1 parent 09fe728 commit 708a99c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 23 additions & 2 deletions python/console/console.py
Expand Up @@ -123,6 +123,17 @@ def __init__(self, parent=None):
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)
Expand Down Expand Up @@ -255,10 +266,13 @@ def __init__(self, parent=None):
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)
Expand Down Expand Up @@ -309,6 +323,7 @@ def __init__(self, parent=None):

##------------ 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)
Expand All @@ -330,7 +345,13 @@ def qtCore(self):

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()
Expand Down
6 changes: 4 additions & 2 deletions python/console/console_editor.py
Expand Up @@ -325,6 +325,7 @@ def hideEditor(self):
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()
Expand Down Expand Up @@ -646,8 +647,9 @@ def closeCurrentWidget(self):
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):
Expand Down
1 change: 1 addition & 0 deletions python/console/console_output.py
Expand Up @@ -227,6 +227,7 @@ def showEditor(self):
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):
Expand Down

0 comments on commit 708a99c

Please sign in to comment.