Use dock layout by default in View node-level CSS

This commit is contained in:
Darren Burns
2022-01-21 15:25:15 +00:00
parent 60134b650d
commit deb7f1cb54
3 changed files with 15 additions and 3 deletions

View File

@@ -1,7 +1,6 @@
/* CSS file for basic.py */
App > View {
layout: dock;
docks: side=left/1;
text: on #20639b;
}

View File

@@ -297,10 +297,23 @@ class LayoutProperty:
self._internal_name = f"_rule_{name}"
def __get__(self, obj: Styles, objtype: type[Styles] | None = None) -> Layout:
"""
Args:
obj (Styles): The Styles object
objtype (type[Styles]): The Styles class
Returns:
The ``Layout`` object.
"""
return getattr(obj, self._internal_name)
def __set__(self, obj: Styles, layout: LayoutName | Layout):
from ..layouts.factory import get_layout
"""
Args:
obj (Styles): The Styles object.
layout (LayoutName | Layout): The layout to use. You can supply a ``LayoutName``
(a string literal such as ``"dock"``) or a ``Layout`` object.
"""
from ..layouts.factory import get_layout # Prevents circular import
obj.refresh(True)
if isinstance(layout, Layout):

View File

@@ -16,8 +16,8 @@ from .widget import Widget
@rich.repr.auto
class View(Widget):
STYLES = """
layout: dock;
docks: main=top;
"""
def __init__(self, name: str | None = None, id: str | None = None) -> None: