Skip to content
Permalink
Browse files

minor changes for layout in console:

- moved header text in output area
- add default value to True for Use preloaded API option in settings dialog
- include traceback to codepad link
  • Loading branch information
slarosa committed Nov 4, 2012
1 parent ed4bc25 commit 38f82d3711be08d09a0b2381a2a9586791e542b2
Showing with 23 additions and 20 deletions.
  1. +19 −8 python/console/console_output.py
  2. +3 −11 python/console/console_sci.py
  3. +1 −1 python/console/console_settings.py
@@ -75,6 +75,7 @@ def __init__(self, parent=None):
sys.stdout = writeOut(self, sys.stdout)
sys.stderr = writeOut(self, sys.stderr, "traceback")

self.insertInitText()
self.setLexers()
self.setReadOnly(True)

@@ -95,7 +96,7 @@ def __init__(self, parent=None):
self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor("#fcf3ed"))

self.setMinimumHeight(80)
self.setMinimumHeight(120)

# Folding
#self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
@@ -117,7 +118,13 @@ def __init__(self, parent=None):
self.copyShortcut.activated.connect(self.copy)
self.selectAllShortcut = QShortcut(QKeySequence.SelectAll, self)
self.selectAllShortcut.activated.connect(self.selectAll)


def insertInitText(self):
txtInit = QCoreApplication.translate("PythonConsole",
"## To access Quantum GIS environment from this console\n"
"## use qgis.utils.iface object (instance of QgisInterface class). Read help for more info.\n\n")
initText = self.setText(txtInit)

def refreshLexerProperties(self):
self.setLexers()

@@ -150,6 +157,7 @@ def getTextFromEditor(self):
def clearConsole(self):
#self.SendScintilla(QsciScintilla.SCI_CLEARALL)
self.setText('')
self.insertInitText()

def contextMenuEvent(self, e):
menu = QMenu(self)
@@ -175,6 +183,7 @@ def contextMenuEvent(self, e):
self.selectAll,
QKeySequence.SelectAll)
runAction.setEnabled(False)
clearAction.setEnabled(False)
copyAction.setEnabled(False)
pastebinAction.setEnabled(False)
selectAllAction.setEnabled(False)
@@ -184,6 +193,7 @@ def contextMenuEvent(self, e):
pastebinAction.setEnabled(True)
if not self.text() == '':
selectAllAction.setEnabled(True)
clearAction.setEnabled(True)
action = menu.exec_(self.mapToGlobal(e.pos()))

def copy(self):
@@ -214,14 +224,15 @@ def keyPressEvent(self, e):

def pastebin(self):
import urllib2, urllib
#listText = self.getTextFromEditor()
listText = self.selectedText().split('\n')
getCmd = []
for s in listText:
if s[0:3] in (">>>", "..."):
if not s[4] == "_":
s.replace(">>> ", "").replace("... ", "")
getCmd.append(unicode(s))
for strLine in listText:
if strLine != "":
#if s[0:3] in (">>>", "..."):
# filter for special command (_save,_clear) and comment
if strLine[4] != "_" and strLine[:2] != "##":
strLine.replace(">>> ", "").replace("... ", "")
getCmd.append(unicode(strLine))
pasteText= u"\n".join(getCmd)
url = 'http://codepad.org'
values = {'lang' : 'Python',
@@ -50,7 +50,6 @@ def __init__(self, parent=None):

self.buffer = []

self.insertInitText()
self.displayPrompt(False)

for line in _init_commands:
@@ -95,7 +94,7 @@ def __init__(self, parent=None):

# not too small
#self.setMinimumSize(500, 300)
self.setMinimumHeight(50)
self.setMinimumHeight(20)

self.setWrapMode(QsciScintilla.WrapCharacter)
self.SendScintilla(QsciScintilla.SCI_EMPTYUNDOBUFFER)
@@ -174,7 +173,7 @@ def setLexers(self):
self.lexer.setFont(font, 4)

self.api = QsciAPIs(self.lexer)
chekBoxAPI = settings.value( "pythonConsole/preloadAPI" ).toBool()
chekBoxAPI = settings.value("pythonConsole/preloadAPI", True).toBool()
if chekBoxAPI:
self.api.loadPrepared( QgsApplication.pkgDataPath() + "/python/qsci_apis/pyqgis_master.pap" )
else:
@@ -199,13 +198,6 @@ def completion_list_selected(self, id, txt):
self.removeSelectedText()
self.insert(txt)

def insertInitText(self):
#self.setLexers(False)
txtInit = QCoreApplication.translate("PythonConsole", "## Interactive Python Console for Quantum GIS\n\n")
#"## To access Quantum GIS environment from this console\n"
#"## use qgis.utils.iface object (instance of QgisInterface class). Read help for more info.\n\n")
initText = self.setText(txtInit)

def getText(self):
""" Get the text as a unicode string. """
value = self.getBytes().decode('utf-8')
@@ -546,6 +538,6 @@ def write(self, txt):

def write_stdout(self, txt):
if len(txt) > 0:
getCmdString = self.text(2)
getCmdString = self.text()
prompt = getCmdString[0:4]
sys.stdout.write(prompt+txt+'\n')
@@ -138,7 +138,7 @@ def saveSettings(self):
def restoreSettings(self):
settings = QSettings()
self.spinBox.setValue(settings.value("pythonConsole/fontsize").toInt()[0])
self.preloadAPI.setChecked(settings.value( "pythonConsole/preloadAPI" ).toBool())
self.preloadAPI.setChecked(settings.value("pythonConsole/preloadAPI", True).toBool())
itemTable = settings.value("pythonConsole/userAPI").toStringList()
for i in range(len(itemTable)):
self.tableWidget.insertRow(i)

0 comments on commit 38f82d3

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