mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Tabs widget now sends Tabs.Cleared when there is no active tab.
|
- Tabs widget now sends Tabs.Cleared when there is no active tab.
|
||||||
- Breaking change: changed default behaviour of `Vertical` (see `VerticalScroll`) https://github.com/Textualize/textual/issues/1957
|
- Breaking change: changed default behaviour of `Vertical` (see `VerticalScroll`) https://github.com/Textualize/textual/issues/1957
|
||||||
- The default `overflow` style for `Horizontal` was changed to `hidden hidden` https://github.com/Textualize/textual/issues/1957
|
- The default `overflow` style for `Horizontal` was changed to `hidden hidden` https://github.com/Textualize/textual/issues/1957
|
||||||
|
- `DirectoryTree` also accepts `pathlib.Path` objects as the path to list https://github.com/Textualize/textual/issues/1438
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import ClassVar
|
from typing import ClassVar
|
||||||
@@ -7,14 +8,13 @@ from typing import ClassVar
|
|||||||
from rich.style import Style
|
from rich.style import Style
|
||||||
from rich.text import Text, TextType
|
from rich.text import Text, TextType
|
||||||
|
|
||||||
from .._types import MessageTarget
|
|
||||||
from ..message import Message
|
from ..message import Message
|
||||||
from ._tree import TOGGLE_STYLE, Tree, TreeNode
|
from ._tree import TOGGLE_STYLE, Tree, TreeNode
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DirEntry:
|
class DirEntry:
|
||||||
"""Attaches directory information ot a node."""
|
"""Attaches directory information to a node."""
|
||||||
|
|
||||||
path: str
|
path: str
|
||||||
is_dir: bool
|
is_dir: bool
|
||||||
@@ -26,9 +26,9 @@ class DirectoryTree(Tree[DirEntry]):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
path: Path to directory.
|
path: Path to directory.
|
||||||
name: The name of the widget, or None for no name. Defaults to None.
|
name: The name of the widget, or None for no name.
|
||||||
id: The ID of the widget in the DOM, or None for no ID. Defaults to None.
|
id: The ID of the widget in the DOM, or None for no ID.
|
||||||
classes: A space-separated list of classes, or None for no classes. Defaults to None.
|
classes: A space-separated list of classes, or None for no classes.
|
||||||
disabled: Whether the directory tree is disabled or not.
|
disabled: Whether the directory tree is disabled or not.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -83,13 +83,14 @@ class DirectoryTree(Tree[DirEntry]):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str | Path,
|
||||||
*,
|
*,
|
||||||
name: str | None = None,
|
name: str | None = None,
|
||||||
id: str | None = None,
|
id: str | None = None,
|
||||||
classes: str | None = None,
|
classes: str | None = None,
|
||||||
disabled: bool = False,
|
disabled: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
path = os.fspath(path)
|
||||||
self.path = path
|
self.path = path
|
||||||
super().__init__(
|
super().__init__(
|
||||||
path,
|
path,
|
||||||
|
|||||||
Reference in New Issue
Block a user