Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:qgis/Quantum-GIS

  • Loading branch information
homann committed Sep 14, 2012
2 parents e1a1627 + 5b91b38 commit 82410309576d635adefcc544573a6dae377305e1
@@ -121,7 +121,7 @@ FOREACH (PU pylupdate4;pyrcc4)
ENDIF ()
ENDFOREACH (PU)
IF (NOT EXISTS "${QBINDIR}/pyuic4")
EXECUTE_PROCESS (COMMAND sed -E "s, /.*/PyQt4/uic/pyuic.py, ${QDATADIR}/python/PyQt4/uic/pyuic.py," "@PYQT4_BIN_DIR@/pyuic4"
EXECUTE_PROCESS (COMMAND sed -E "s, /.*/PyQt4/uic/pyuic.py, \"\$(/usr/bin/dirname \"\$0\")/../../Resources/python/PyQt4/uic/pyuic.py\"," "@PYQT4_BIN_DIR@/pyuic4"
OUTPUT_VARIABLE PYUIC_CONTENTS)
FILE (WRITE "${QBINDIR}/pyuic4" "${PYUIC_CONTENTS}")
EXECUTE_PROCESS (COMMAND chmod +x "${QBINDIR}/pyuic4")
@@ -100,33 +100,36 @@ def __init__(self, parent=None):
self.clearButton = QAction(parent)
self.clearButton.setCheckable(False)
self.clearButton.setEnabled(True)
self.clearButton.setIcon(QIcon("icon/iconClearConsole.png"))
self.clearButton.setMenuRole(QAction.PreferencesRole)
self.clearButton.setIconVisibleInMenu(True)
self.clearButton.setToolTip('Clear console')
## Action for paste snippets code
self.clearButton = QAction(parent)
self.clearButton.setCheckable(False)
self.clearButton.setEnabled(True)
self.clearButton.setIcon(QIcon(os.path.dirname(__file__) + "/iconConsole/iconClearConsole.png"))
self.clearButton.setMenuRole(QAction.PreferencesRole)
self.clearButton.setIconVisibleInMenu(True)
self.clearButton.setToolTip('Clear console')
self.clearButton.setText('Clear console')
## Action for paste snippets code
# self.currentLayerButton = QAction(parent)
# self.currentLayerButton.setCheckable(False)
# self.currentLayerButton.setEnabled(True)
# self.currentLayerButton.setIcon(QIcon("icon/iconTempConsole.png"))
# self.currentLayerButton.setMenuRole(QAction.PreferencesRole)
# self.currentLayerButton.setIconVisibleInMenu(True)
##
## Import Sextante class
self.loadSextanteButton = QAction(parent)
self.loadSextanteButton.setCheckable(False)
self.loadSextanteButton.setEnabled(True)
self.loadSextanteButton.setIcon(QIcon(os.path.dirname(__file__) + "iconConsole/iconSextanteConsole.png"))
self.loadSextanteButton.setMenuRole(QAction.PreferencesRole)
self.loadSextanteButton.setIconVisibleInMenu(True)
self.loadSextanteButton.setToolTip('Import sextante class')
self.loadSextanteButton.setText('Import sextante class')
## Import QgisInterface class
self.loadIfaceButton = QAction(parent)
self.loadIfaceButton.setCheckable(False)
self.loadIfaceButton.setEnabled(True)
self.loadIfaceButton.setIcon(QIcon(os.path.dirname(__file__) + "/iconConsole/iconTempConsole.png"))
self.loadIfaceButton.setMenuRole(QAction.PreferencesRole)
self.loadIfaceButton.setIconVisibleInMenu(True)
self.loadIfaceButton.setToolTip('Import iface class')
self.loadIfaceButton.setText('Import iface class')
## Action for Open File
self.openFileButton = QAction(parent)
self.openFileButton.setCheckable(False)
@@ -135,14 +138,16 @@ def __init__(self, parent=None):
self.openFileButton.setMenuRole(QAction.PreferencesRole)
self.openFileButton.setIconVisibleInMenu(True)
self.openFileButton.setToolTip('Open script file')
self.openFileButton.setText('Open script file')
## Action for Save File
self.saveFileButton = QAction(parent)
self.saveFileButton.setCheckable(False)
self.saveFileButton.setEnabled(True)
self.saveFileButton.setIcon(QIcon(os.path.dirname(__file__) + "/iconConsole/iconSaveConsole.png"))
self.saveFileButton.setMenuRole(QAction.PreferencesRole)
self.saveFileButton.setIconVisibleInMenu(True)
self.saveFileButton.setToolTip('Save to file')
self.saveFileButton.setToolTip('Save to script file')
self.saveFileButton.setText('Save to script file')
## Action for Run script
self.runButton = QAction(parent)
self.runButton.setCheckable(False)
@@ -151,6 +156,7 @@ def __init__(self, parent=None):
self.runButton.setMenuRole(QAction.PreferencesRole)
self.runButton.setIconVisibleInMenu(True)
self.runButton.setToolTip('Run command')
self.runButton.setText('Run')
## Help action
self.helpButton = QAction(parent)
self.helpButton.setCheckable(False)
@@ -159,10 +165,12 @@ def __init__(self, parent=None):
self.helpButton.setMenuRole(QAction.PreferencesRole)
self.helpButton.setIconVisibleInMenu(True)
self.helpButton.setToolTip('Help')
self.helpButton.setText('Help')

self.toolBar.addAction(self.clearButton)
#self.toolBar.addAction(self.currentLayerButton)
self.toolBar.addAction(self.loadIfaceButton)
self.toolBar.addAction(self.loadSextanteButton)
self.toolBar.addAction(self.openFileButton)
self.toolBar.addAction(self.saveFileButton)
self.toolBar.addAction(self.helpButton)
@@ -182,6 +190,7 @@ def __init__(self, parent=None):
self.clearButton.triggered.connect(self.edit.clearConsole)
#self.currentLayerButton.triggered.connect(self.cLayer)
self.loadIfaceButton.triggered.connect(self.iface)
self.loadSextanteButton.activated.connect(self.sextante)
self.runButton.triggered.connect(self.edit.entered)
self.openFileButton.triggered.connect(self.openScriptFile)
self.saveFileButton.triggered.connect(self.saveScriptFile)
@@ -192,20 +201,28 @@ def __init__(self, parent=None):

def cLayer(self):
self.edit.commandConsole('cLayer')

def sextante(self):
self.edit.commandConsole('sextante')

def iface(self):
self.edit.commandConsole('iface')

def openScriptFile(self):
settings = QSettings()
lastDirPath = settings.value("/pythonConsole/lastDirPath").toString()
scriptFile = QFileDialog.getOpenFileName(
self, "Open File", "", "Script file (*.py)")
self, "Open File", lastDirPath, "Script file (*.py)")
if scriptFile.isEmpty() == False:
oF = open(scriptFile, 'r')
listScriptFile = []
for line in oF:
if line != "\n":
listScriptFile.append(line)
self.edit.insertTextFromFile(listScriptFile)

lastDirPath = QFileInfo(scriptFile).path()
settings.setValue("/pythonConsole/lastDirPath", QVariant(scriptFile))


def saveScriptFile(self):
@@ -223,13 +240,10 @@ def saveScriptFile(self):
is_first_line = True
for s in listText:
if s[0:3] in (">>>", "..."):
s.replace(">>> ", "")
s.replace("... ", "")
s.replace(">>> ", "").replace("... ", "")
if is_first_line:
# see, no write() in this branch
is_first_line = False
else:
# we've just written a line; add a newline
sF.write('\n')
sF.write(s)
sF.close()
@@ -21,9 +21,10 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.Qsci import *
from PyQt4.Qsci import QsciScintilla, QsciScintillaBase, QsciLexerPython
#from qgis.utils import iface
from PyQt4.Qsci import (QsciScintilla,
QsciScintillaBase,
QsciLexerPython,
QsciAPIs)

import sys
import os
@@ -32,11 +33,6 @@

_init_commands = ["from qgis.core import *", "import qgis.utils"]

_console = None

_old_stdout = sys.stdout
_console_output = None

class PythonEdit(QsciScintilla, code.InteractiveInterpreter):
def __init__(self, parent=None):
#QsciScintilla.__init__(self, parent)
@@ -136,6 +132,10 @@ def commandConsole(self, command):
"""Import QgisInterface class"""
self.append('from qgis.utils import iface')
self.move_cursor_to_end()
elif command == "sextante":
"""Import Sextante class"""
self.append('from sextante.core.Sextante import Sextante')
self.move_cursor_to_end()
elif command == "cLayer":
"""Retrive current Layer from map camvas"""
self.append('cLayer = iface.mapCanvas().currentLayer()')
@@ -43,6 +43,10 @@ <h2>Python Console for QGIS</h2>
<td>Tool to import iface class</td>
</tr>
<tr>
<td><img src="../iconConsole/iconSextanteConsole.png" /></td>
<td>Tool to import Sextante class</td>
</tr>
<tr>
<td><img src="../iconConsole/iconOpenConsole.png" /></td>
<td>Tool to open a python script and load in console</td>
</tr>
@@ -3,6 +3,7 @@ iconClearConsole.png
iconOpenConsole.png
iconRunConsole.png
iconTempConsole.png
iconSextanteConsole.png
iconSaveConsole.png
iconHelpConsole.png
imgHelpDialog.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8241030

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