Add Page Editor toolbar toggles and widen the default window
Edit mode, snap to grid and the widgets/properties pane are now toggles on the main toolbar while the Page Editor is open. Outside edit mode the page and the property sheet are read-only; drags snap to the 10px grid when snapping is on. The default window grows by the right pane's width so the canvas is not squeezed when the pane shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -70,6 +70,9 @@ PALETTE_REQUESTED_ROWS = 5
|
||||
# Below this the shortfall is deep enough to shrink the tree past a usable few rows, and
|
||||
# ttk has no way to hold a pane at a floor once the room is simply not there.
|
||||
MIN_WINDOW_HEIGHT = 300
|
||||
# The editor itself, plus room for the Page Editor's widgets/properties pane.
|
||||
DEFAULT_WINDOW_WIDTH = 880 + ox_page_view.RIGHT_PANE_WIDTH
|
||||
DEFAULT_WINDOW_HEIGHT = 600
|
||||
|
||||
# How many visited views Back and Forward can walk through. A session touches few of
|
||||
# them; the cap only stops an unbounded list.
|
||||
@@ -368,11 +371,34 @@ def show_ox_page_view(comp):
|
||||
on_close=dismiss_ox_page_view,
|
||||
)
|
||||
ox_page_panel.frame.pack(fill=tk.BOTH, expand=True)
|
||||
_show_page_editor_tools(ox_page_panel)
|
||||
record_visit(VIEW_PAGE, comp)
|
||||
update_zoom_label()
|
||||
app_state.set_status(f"Page Editor: {comp.get('name', '?')}")
|
||||
|
||||
|
||||
def _show_page_editor_tools(panel):
|
||||
"""Lays the Page Editor's toggles out on the toolbar, after a separator of their own."""
|
||||
_hide_page_editor_tools()
|
||||
ttk.Separator(page_editor_tools, orient=tk.VERTICAL).pack(
|
||||
side=tk.LEFT, fill=tk.Y, padx=8, pady=2)
|
||||
for index, (icon, tip, variable, command) in enumerate(panel.toolbar_tools()):
|
||||
if variable is not None:
|
||||
button = ttk.Checkbutton(page_editor_tools, text=icon, width=3,
|
||||
style="Toolbutton", variable=variable, command=command)
|
||||
else:
|
||||
button = ttk.Button(page_editor_tools, text=icon, width=3, command=command)
|
||||
button.pack(side=tk.LEFT, padx=(3 if index else 0, 0))
|
||||
_ToolTip(button, tip)
|
||||
page_editor_tools.pack(side=tk.LEFT)
|
||||
|
||||
|
||||
def _hide_page_editor_tools():
|
||||
for child in page_editor_tools.winfo_children():
|
||||
child.destroy()
|
||||
page_editor_tools.pack_forget()
|
||||
|
||||
|
||||
def dismiss_ox_page_view(restore_canvas=True):
|
||||
"""Takes the OxPage editor down and gives the pane back."""
|
||||
global ox_page_panel
|
||||
@@ -381,6 +407,7 @@ def dismiss_ox_page_view(restore_canvas=True):
|
||||
|
||||
ox_page_panel.destroy()
|
||||
ox_page_panel = None
|
||||
_hide_page_editor_tools()
|
||||
update_zoom_label()
|
||||
|
||||
if restore_canvas:
|
||||
@@ -2386,7 +2413,7 @@ def _live_tree_expand(comp_id, tree_item_id):
|
||||
window = tk.Tk()
|
||||
app_state.window = window
|
||||
window.title(app_state.base_window_title())
|
||||
window.geometry("950x600")
|
||||
window.geometry(f"{DEFAULT_WINDOW_WIDTH}x{DEFAULT_WINDOW_HEIGHT}")
|
||||
# Width is left alone; only the height needs a floor, to keep the tree pane off zero.
|
||||
window.minsize(1, MIN_WINDOW_HEIGHT)
|
||||
|
||||
@@ -2588,6 +2615,9 @@ _btn_print = ttk.Button(toolbar, text="🖨", width=3, command=wiresheet.print_s
|
||||
_btn_print.pack(side=tk.LEFT)
|
||||
_ToolTip(_btn_print, "Print Wiresheet (Ctrl+P)")
|
||||
|
||||
# Filled with the Page Editor's own tools while it is open, and empty (unpacked) otherwise.
|
||||
page_editor_tools = ttk.Frame(toolbar)
|
||||
|
||||
paned_window = ttk.PanedWindow(window, orient=tk.HORIZONTAL)
|
||||
paned_window.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user