[QGIS Commit] r14999 - trunk/qgis/python

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jan 5 18:32:29 EST 2011


Author: wonder
Date: 2011-01-05 15:32:29 -0800 (Wed, 05 Jan 2011)
New Revision: 14999

Modified:
   trunk/qgis/python/console.py
Log:
Added clearConsole() to Python console. Contributed by Nathan Woodrow - thanks!


Modified: trunk/qgis/python/console.py
===================================================================
--- trunk/qgis/python/console.py	2011-01-05 23:26:18 UTC (rev 14998)
+++ trunk/qgis/python/console.py	2011-01-05 23:32:29 UTC (rev 14999)
@@ -48,11 +48,17 @@
     _console.edit.setFocus()
 
   
-
 _old_stdout = sys.stdout
 _console_output = None
 
 
+def clearConsole():
+  global _console
+  if _console is None:
+    return
+  _console.edit.clearConsole()
+
+
 # hook for python console so all output will be redirected
 # and then shown in console
 def console_displayhook(obj):
@@ -135,11 +141,9 @@
     self.setFont(monofont)
 
     self.buffer = []
+    
+    self.insertInitText()
 
-    self.insertTaggedText(QCoreApplication.translate("PythonConsole", "To access Quantum GIS environment from this console\n"
-                          "use qgis.utils.iface object (instance of QgisInterface class).\n\n"),
-			  ConsoleHighlighter.INIT)
-
     for line in _init_commands:
       self.runsource(line)
 
@@ -149,7 +153,17 @@
     self.historyIndex = 0
 
     self.high = ConsoleHighlighter(self)
+    
+  def insertInitText(self):
+    self.insertTaggedText(QCoreApplication.translate("PythonConsole", "To access Quantum GIS environment from this console\n"
+                          "use qgis.utils.iface object (instance of QgisInterface class).\n\n"),
+                          ConsoleHighlighter.INIT)
 
+
+  def clearConsole(self):
+    self.clear()
+    self.insertInitText()
+
   def displayPrompt(self, more=False):
     self.currentPrompt = "... " if more else ">>> "
     self.currentPromptLength = len(self.currentPrompt)



More information about the QGIS-commit mailing list