Skip to content
Permalink
Browse files
Adding docking support to python console
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14994 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman committed Jan 5, 2011
1 parent ce1dabc commit 6f299a40752ef637aaaa1cbe2e05dd8f500155aa
Showing with 11 additions and 14 deletions.
  1. +11 −14 python/console.py
@@ -24,31 +24,27 @@

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.utils import iface
import sys
import traceback
import code


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


_console = None

def show_console():
""" called from QGIS to open the console """
global _console
if _console is None:
_console = PythonConsole()
_console.show()
_console.raise_()
_console.setWindowState( _console.windowState() & ~Qt.WindowMinimized )
_console.activateWindow()


_console.setVisible(True)

_old_stdout = sys.stdout
_console_output = None


# hook for python console so all output will be redirected
# and then shown in console
def console_displayhook(obj):
@@ -69,17 +65,18 @@ def flush(self):

sys.stdout = QgisOutputCatcher()


class PythonConsole(QWidget):
class PythonConsole(QDockWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)

QDockWidget.__init__(self, parent)

self.widget = QWidget()
self.l = QVBoxLayout(self.widget)
self.edit = PythonEdit()
self.l = QVBoxLayout()
self.l.addWidget(self.edit)
self.setLayout(self.l)
self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Python Console"))
self.setWidget(self.widget)

self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Python Console"))
iface.addDockWidget(Qt.BottomDockWidgetArea,self)
s = QSettings()
self.restoreGeometry(s.value("/python/console/geometry").toByteArray())

0 comments on commit 6f299a4

Please sign in to comment.