MCPcopy
hub / github.com/Textualize/rich / Panel

Class Panel

rich/panel.py:17–297  ·  view source on GitHub ↗

A console renderable that draws a border around its contents. Example: >>> console.print(Panel("Hello, World!")) Args: renderable (RenderableType): A console renderable object. box (Box): A Box instance that defines the look of the border (see :ref:`appendix_box`. D

Source from the content-addressed store, hash-verified

15
16
17class Panel(JupyterMixin):
18 """A console renderable that draws a border around its contents.
19
20 Example:
21 >>> console.print(Panel("Hello, World!"))
22
23 Args:
24 renderable (RenderableType): A console renderable object.
25 box (Box): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED.
26 title (Optional[TextType], optional): Optional title displayed in panel header. Defaults to None.
27 title_align (AlignMethod, optional): Alignment of title. Defaults to "center".
28 subtitle (Optional[TextType], optional): Optional subtitle displayed in panel footer. Defaults to None.
29 subtitle_align (AlignMethod, optional): Alignment of subtitle. Defaults to "center".
30 safe_box (bool, optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
31 expand (bool, optional): If True the panel will stretch to fill the console width, otherwise it will be sized to fit the contents. Defaults to True.
32 style (str, optional): The style of the panel (border and contents). Defaults to "none".
33 border_style (str, optional): The style of the border. Defaults to "none".
34 width (Optional[int], optional): Optional width of panel. Defaults to None to auto-detect.
35 height (Optional[int], optional): Optional height of panel. Defaults to None to auto-detect.
36 padding (Optional[PaddingDimensions]): Optional padding around renderable. Defaults to 0.
37 highlight (bool, optional): Enable automatic highlighting of panel title (if str). Defaults to False.
38 """
39
40 def __init__(
41 self,
42 renderable: "RenderableType",
43 box: Box = ROUNDED,
44 *,
45 title: Optional[TextType] = None,
46 title_align: AlignMethod = "center",
47 subtitle: Optional[TextType] = None,
48 subtitle_align: AlignMethod = "center",
49 safe_box: Optional[bool] = None,
50 expand: bool = True,
51 style: StyleType = "none",
52 border_style: StyleType = "none",
53 width: Optional[int] = None,
54 height: Optional[int] = None,
55 padding: PaddingDimensions = (0, 1),
56 highlight: bool = False,
57 ) -> None:
58 self.renderable = renderable
59 self.box = box
60 self.title = title
61 self.title_align: AlignMethod = title_align
62 self.subtitle = subtitle
63 self.subtitle_align = subtitle_align
64 self.safe_box = safe_box
65 self.expand = expand
66 self.style = style
67 self.border_style = border_style
68 self.width = width
69 self.height = height
70 self.padding = padding
71 self.highlight = highlight
72
73 @classmethod
74 def fit(

Callers 15

test_panel.pyFile · 0.90
test_console_widthFunction · 0.90
test_fixed_widthFunction · 0.90
test_render_sizeFunction · 0.90
test_title_textFunction · 0.90
test_renderFunction · 0.90

Calls

no outgoing calls

Tested by 14

test_console_widthFunction · 0.72
test_fixed_widthFunction · 0.72
test_render_sizeFunction · 0.72
test_title_textFunction · 0.72
test_renderFunction · 0.72
__rich_console__Method · 0.72