File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -95,8 +95,10 @@ def arrange(
9595
9696 if layout_widgets :
9797 # Arrange layout widgets (i.e. not docked)
98- layout_placements = widget .layout .arrange (
99- widget , layout_widgets , dock_region .size , greedy = not optimal
98+ layout_placements = widget .process_layout (
99+ widget .layout .arrange (
100+ widget , layout_widgets , dock_region .size , greedy = not optimal
101+ )
100102 )
101103 scroll_spacing = scroll_spacing .grow_maximum (dock_spacing )
102104 placement_offset = dock_region .offset
Original file line number Diff line number Diff line change 7979 Spacing ,
8080 clamp ,
8181)
82- from textual .layout import Layout
82+ from textual .layout import Layout , WidgetPlacement
8383from textual .layouts .vertical import VerticalLayout
8484from textual .message import Message
8585from textual .messages import CallbackType , Prune
@@ -722,6 +722,22 @@ def _cover(self, widget: Widget) -> None:
722722 self .app .stylesheet .apply (widget )
723723 self .refresh (layout = True )
724724
725+ def process_layout (
726+ self , placements : list [WidgetPlacement ]
727+ ) -> list [WidgetPlacement ]:
728+ """A hook to allow for the manipulation of widget placements before rendering.
729+
730+ You could use this as a way to modify the positions / margins of widgets if your requirement is
731+ not supported in TCSS. In practice, this method is rarely needed!
732+
733+ Args:
734+ placements: A list of [`WidgetPlacement`][textual.layout.WidgetPlacement] objects.
735+
736+ Returns:
737+ A new list of placements.
738+ """
739+ return placements
740+
725741 def _uncover (self ) -> None :
726742 """Remove any widget, previously set via [`_cover`][textual.widget.Widget._cover]."""
727743 if self ._cover_widget is not None :
You can’t perform that action at this time.
0 commit comments