Skip to content
Permalink
Browse files

set focus to python console when shown even if in a tabbed dockwidget

  • Loading branch information
brushtyler committed Oct 18, 2012
1 parent 9fb0b76 commit 1960bea81b0bd6c084f8f1e545c31cc993e9e760
Showing with 13 additions and 6 deletions.
  1. +13 −6 python/console.py
@@ -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
@@ -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):
@@ -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)

0 comments on commit 1960bea

Please sign in to comment.
You can’t perform that action at this time.