Skip to content
Permalink
Browse files

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

…sole
  • Loading branch information
slarosa committed Apr 16, 2013
1 parent 09fe728 commit 708a99c15b7d8294cfc015fe7bd9667147133140
Binary file not shown.
@@ -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)
@@ -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)
@@ -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)
@@ -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()
@@ -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()
@@ -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):
@@ -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):

0 comments on commit 708a99c

Please sign in to comment.
You can’t perform that action at this time.