Feature request #4019
patch for Python Console enhancement - dock window or top-level window, without QGIS restart
|Pull Request or Patch supplied:||Yes||Resolution:|
|Easy fix?:||No||Copied to github as #:||14006|
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. re-parent the editor widget by constructing a new window of the other type containing the editor
- 2. remove/delete the existing window object that contained the editor
- 3. add the new window to the QGIS ui
- 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.
#10 Updated by Borys Jurgiel almost 3 years ago
- Description updated (diff)
- Category changed from Python plugins to PyQGIS Console
Ooops, it seems none of us Python-interested devs ever found this precious patch :(
Would it be possible to prepare a new path against the current Console (or yet better directly a github pull request) and assign it to me, so I can push it further?