Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding docking support to python console
git-svn-id: http://svn.osgeo.org/qgis/trunk@14994 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
gsherman committed Jan 5, 2011
1 parent 9055c06 commit 1859838
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions python/console.py
Expand Up @@ -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):
Expand All @@ -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())

Expand Down

0 comments on commit 1859838

Please sign in to comment.