mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Use dock layout by default in View node-level CSS
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
/* CSS file for basic.py */
|
/* CSS file for basic.py */
|
||||||
|
|
||||||
App > View {
|
App > View {
|
||||||
layout: dock;
|
|
||||||
docks: side=left/1;
|
docks: side=left/1;
|
||||||
text: on #20639b;
|
text: on #20639b;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,10 +297,23 @@ class LayoutProperty:
|
|||||||
self._internal_name = f"_rule_{name}"
|
self._internal_name = f"_rule_{name}"
|
||||||
|
|
||||||
def __get__(self, obj: Styles, objtype: type[Styles] | None = None) -> Layout:
|
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)
|
return getattr(obj, self._internal_name)
|
||||||
|
|
||||||
def __set__(self, obj: Styles, layout: LayoutName | Layout):
|
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)
|
obj.refresh(True)
|
||||||
if isinstance(layout, Layout):
|
if isinstance(layout, Layout):
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ from .widget import Widget
|
|||||||
@rich.repr.auto
|
@rich.repr.auto
|
||||||
class View(Widget):
|
class View(Widget):
|
||||||
STYLES = """
|
STYLES = """
|
||||||
|
layout: dock;
|
||||||
docks: main=top;
|
docks: main=top;
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name: str | None = None, id: str | None = None) -> None:
|
def __init__(self, name: str | None = None, id: str | None = None) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user