Showing with 14 additions and 7 deletions.
  1. +13 −6 python/console.py
  2. +1 −1 python/plugins/sextanteexampleprovider/__init__.py
19 changes: 13 additions & 6 deletions python/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,16 @@ def show_console():
parent = iface.mainWindow() if iface else None
_console = PythonConsole( parent )
_console.show() # force show even if it was restored as hidden

# set focus to the console so the user can start typing
# defer the set focus event so it works also whether the console not visible yet
QTimer.singleShot(0, _console.activate)
else:
_console.setVisible(not _console.isVisible())

# set focus to the edit box so the user can start typing
if _console.isVisible():
_console.activateWindow()
_console.setFocus()
# set focus to the console so the user can start typing
if _console.isVisible():
_console.activate()

_old_stdout = sys.stdout
_console_output = None
Expand Down Expand Up @@ -77,11 +80,17 @@ def __init__(self, parent=None):

self.console = PythonConsoleWidget(self)
self.setWidget( self.console )
self.setFocusProxy( self.console )

# try to restore position from stored main window state
if iface and not iface.mainWindow().restoreDockWidget(self):
iface.mainWindow().addDockWidget(Qt.BottomDockWidgetArea, self)

def activate(self):
self.activateWindow()
self.raise_()
QDockWidget.setFocus(self)


class PythonConsoleWidget(QWidget):
def __init__(self, parent=None):
Expand Down Expand Up @@ -257,8 +266,6 @@ def __init__(self, parent=None):

self.e.addWidget(self.widgetButton)
self.e.addWidget(self.edit)

self.edit.setFocus()

self.clearButton.triggered.connect(self.edit.clearConsole)
#self.currentLayerButton.triggered.connect(self.cLayer)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextanteexampleprovider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from sextanteexampleprovider.SextanteExampleProviderPlugin import SextanteExampleProviderPlugin
def name():
return "SEXTANTE example provider"
def description():
Expand All @@ -35,4 +34,5 @@ def icon():
def qgisMinimumVersion():
return "1.0"
def classFactory(iface):
from sextanteexampleprovider.SextanteExampleProviderPlugin import SextanteExampleProviderPlugin
return SextanteExampleProviderPlugin()