Feature request #4019

patch for Python Console enhancement - dock window or top-level window, without QGIS restart

Added by Steven Mizuno over 6 years ago. Updated 7 months ago.

Category:Python plugins
Pull Request or Patch supplied:Yes Resolution:
Easy fix?:No


This provides Python Console as either a dock widget or a top-level window. It can be switched on the fly - no need to restart QGIS.

This suggests a way for the other dialogs that can be dock widgets or separate windows to be modified similarly. There is no good reason that I can see not to do it this way, and it is somewhat annoying to have to restart QGIS on a change of window type.

For a long time the Python Console was a top-level window. Fairly recently it was changed to a dock widget. The way I use the console necessitates easy navigation (Alt+Tab, for example) using the keyboard. I found it difficult to use the dock widget type using the keyboard.

I was inclined to make my personal copy of QGIS revert to the top-level window type, but I considered that it is possible to have both ways, AND to be able to switch without restarting QGIS. In other words, give the user a choice, as this has been implemented at least two different ways.

The basics to switch from one type to the other:
on change of type - determined by the current state not being the same as the state stored by the Options dialog
  1. 1. re-parent the editor widget by constructing a new window of the other type containing the editor
  2. 2. remove/delete the existing window object that contained the editor
  3. 3. add the new window to the QGIS ui
  4. 4. save the new state

Settings, Options, General tab, "Open Python console in a dock window" check box is the user configuration choice.

Changing Python Console's window type takes effect the next time Plugins, Python Console is chosen, even if the console is visible. As the editor is retained, nothing done in the console will be lost.

When it is a dock window it is alternately toggled on and off each time the Plugins, Python Console menu item is chosen. (no change from its behavior when the dock widget type was instituted)

As a top-level window it will be shown each time the Plugins, Python Console menu item is chosen; the window may be minimized or closed using the buttons on its title bar.

Note that as a dock window an item for it will appear in the main window's context menu and it can be toggled on and off there. It should probably appear in the View, Panels menu, but I did not do this as it hadn't been done previously.

The contents margins for the editor are to zero to give maximum real estate for the console content. This is especially useful with small screens.

patch_for_4019.txt Magnifier (8.02 KB) Steven Mizuno, 06/25/2011 06:48 PM


#1 Updated by Steven Mizuno over 6 years ago

#2 Updated by Alister Hood about 6 years ago

  • Pull Request or Patch supplied set to Yes

#3 Updated by Tim Sutton about 6 years ago

  • Target version changed from Version 1.7.1 to Version 1.7.2

#4 Updated by Giovanni Manghi almost 6 years ago

  • Target version changed from Version 1.7.2 to Version 1.7.3

#5 Updated by Giovanni Manghi almost 6 years ago

  • Target version changed from Version 1.7.3 to Version 1.7.4

#6 Updated by Giovanni Manghi over 5 years ago

  • Target version changed from Version 1.7.4 to Version 2.0.0

#7 Updated by Pirmin Kalberer about 5 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

#8 Updated by Médéric RIBREUX almost 2 years ago

Hello, bug triage...

this is still true in QGIS 2.13,master. Python console is still a QDockWidget and we should be able to have it as a main Window when coding...

#9 Updated by Giovanni Manghi 7 months ago

  • Easy fix? set to No

Also available in: Atom PDF