Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bdieterm
Copy link
Collaborator

This PR makes it possible to define multiple views and easily switch between them. A "view" contains the window and panel geometries of the Pyzo IDE, including the tools.

There is a new default keyboard shortcut Ctrl+Shift+A for switching views, similar to the existing Ctrl+Tab for switching between editors.

See the docstring in pyzo/core/views.py for more details.

@bdieterm bdieterm merged commit 7a021fb into pyzo:main Oct 11, 2025
19 checks passed
@bdieterm bdieterm deleted the views branch October 11, 2025 08:28
@almarklein
Copy link
Member

Cool! How do you use this feature? I only use a single layout, really, and the only thing I do is change the width of the editor window as I change between smaller/bigger screens :)

@almarklein
Copy link
Member

Ah, zen mode (#289)

@bdieterm
Copy link
Collaborator Author

@almarklein

There is a description at the top of the new file:

pyzo/pyzo/core/views.py

Lines 1 to 33 in 2c23532

"""
Views
When starting Pyzo, the window and panel geometries, and the loaded tool panels
are automatically restored. And when closing Pyzo, these geometry and state
values are automatically stored to the configuration file. This view is defined
as the "[NORMAL]" view.
The ViewManager class makes it possible to have more than a single view setup
and to quickly switch between these defined views.
To switch between views, the "Views" dialog must be started, either via Pyzo's
menu, or by pressing the assigned key combination.
When invoked via a key combination that contains a modifier key (e.g. Ctrl),
the dialog will only remain open as long as at least one of these modifier keys
is kept pressed. A repeated press of the non-modifier key (e.g. the 'A' in
Ctrl+Shift+A) will advance the selection to the next entry in the dialog's list
widget, similar to the Pyzo editor's tab switching via Ctrl+Tab.
When releasing all modifier keys, the dialog will be closed and the selected
view in the dialog's list will be activated.
When invoked via the menu or a key shortcut without modifier key, the dialog
will stay open like a normal dialog window.
The list widget contains all defined views, ordered by how recently they were
used, with the currently active view on top. This makes it easier to switch
between two recently used views via the key combinations.
The state of the "[NORMAL]" view is always saved automatically before switching
to another view. All other views must be manually updated by pressing the
"Update view" button in the dialog (with the correct list entry selected).
"""

Demonstration

Create a new view:

  1. Start Pyzo with your favourite layout (window/widgets geometries and active tools).
  2. Press Ctrl+Shift+A and keep at least one modifier key pressed (to keep the dialog open).
  3. The currently selected entry in the left list widget is the currently active view ("[NORMAL]" after starting Pyzo).
  4. Click the button "Add view" (while still holding the modifier key) [or move the focus to that button using the arrow keys and then press Space/Enter/Return].
  5. Now you can release the modifier key(s).
  6. Enter a name for the new view and press "OK" -- the "Views" dialog will also disappear.
  7. Now you are in a different view -- you can quickly check the currently activated view by pressing and releasing the key combination and looking at the selected list entry.
  8. Now modify window and widget geometries, and switch on/off some tools.
  9. Press Ctrl+Shift+A and keep at least one modifier key pressed (to keep the dialog open).
  10. Press the "Update view" button (or simply press Space because that button has the default focus).

Switch back to the normal view:

  1. Press Ctrl+Shift+A and keep at least one modifier key pressed (to keep the dialog open).
  2. Select the "[NORMAL]" entry for example by clicking on that list entry and release all keys.
  3. The dialog will disappear and Pyzo switches the geometries.

To quickly switch between the two recently used views, press the "A" key again when the dialog is open. This will move the selection in the list widget, similar to repeatedly pressing the Tab key in the "Editor tab history" dialog.

The "[NORMAL]" view is exactly like in older Pyzo versions. Custom views keep their geometry settings until you update them manually.

My use cases

Currently I have following views in my user settings:

  • "narrow": the shell is below the editor; no tools; good for having the Pyzo window next to another window on a (smaller) single monitor.
  • "backup_normal": this is a backup of my nomal view, with the editor in the horizontal center, shell on the left, some tools tabbed on the bottom left, and some other tools along the right side of the editor. I sometimes use this to quickly restore the size after having closed Pyzo in maximized state (because of an issue with Qt and Wayland).
  • "large_search": like the normal view, but giving the file browser tool on the very right side much more horizontal space so that I can see full lines in search results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants