Skip to content

Commit 74141c0

Browse files
author
wonder
committed
Added clearConsole() to Python console. Contributed by Nathan Woodrow - thanks!
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14999 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3120590 commit 74141c0

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

python/console.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,17 @@ def show_console():
4848
_console.edit.setFocus()
4949

5050

51-
5251
_old_stdout = sys.stdout
5352
_console_output = None
5453

5554

55+
def clearConsole():
56+
global _console
57+
if _console is None:
58+
return
59+
_console.edit.clearConsole()
60+
61+
5662
# hook for python console so all output will be redirected
5763
# and then shown in console
5864
def console_displayhook(obj):
@@ -135,10 +141,8 @@ def __init__(self,parent=None):
135141
self.setFont(monofont)
136142

137143
self.buffer = []
138-
139-
self.insertTaggedText(QCoreApplication.translate("PythonConsole", "To access Quantum GIS environment from this console\n"
140-
"use qgis.utils.iface object (instance of QgisInterface class).\n\n"),
141-
ConsoleHighlighter.INIT)
144+
145+
self.insertInitText()
142146

143147
for line in _init_commands:
144148
self.runsource(line)
@@ -149,6 +153,16 @@ def __init__(self,parent=None):
149153
self.historyIndex = 0
150154

151155
self.high = ConsoleHighlighter(self)
156+
157+
def insertInitText(self):
158+
self.insertTaggedText(QCoreApplication.translate("PythonConsole", "To access Quantum GIS environment from this console\n"
159+
"use qgis.utils.iface object (instance of QgisInterface class).\n\n"),
160+
ConsoleHighlighter.INIT)
161+
162+
163+
def clearConsole(self):
164+
self.clear()
165+
self.insertInitText()
152166

153167
def displayPrompt(self, more=False):
154168
self.currentPrompt = "... " if more else ">>> "

0 commit comments

Comments
 (0)