SourceClass Panel
from egui import Panelclass Panel:A panel that covers an entire side
(left, right,
top or bottom)
of a Ui or screen.
The order in which you add panels matter! The first panel you add will always be the outermost, and the last you add will always be the innermost.
⚠ Always add any CentralPanel last.
See the module level docs for more details.
Showing the panel
Pick the variant that matches the behavior you want:
Panel.show: always show the panel.Panel.show_collapsible: show or hide the panel, with a slide animation in between.Panel.show_switched: animate between two different panels: a thin/collapsed one and a thick/expanded one.
Methods§
Source@staticmethod
def bottom(id: str) -> Panel§
Create a bottom panel.
The id_salt only needs to be unique among the panels of the same parent Ui, e.g. "my_bottom_panel".
By default this is NOT resizable.
def default_height(self, /, height: float) -> Panel§
Sourcedef default_size(self, /, size: float) -> Panel§
The initial wrapping width of the Panel, including margins.
def default_width(self, /, width: float) -> Panel§
def exact_height(self, /, height: float) -> Panel§
Sourcedef exact_size(self, /, size: float) -> Panel§
Enforce this exact size, including margins.
def exact_width(self, /, width: float) -> Panel§
Sourcedef frame(self, /, frame: Frame) -> Panel§
Change the background color, margins, etc.
def height_range(self, /, min: float, max: float) -> Panel§
Source@staticmethod
def left(id: str) -> Panel§
Create a left panel.
The id_salt only needs to be unique among the panels of the same parent Ui, e.g. "my_left_panel".
def max_height(self, /, height: float) -> Panel§
Sourcedef max_size(self, /, size: float) -> Panel§
Maximum size of the panel, including margins.
def max_width(self, /, width: float) -> Panel§
def min_height(self, /, height: float) -> Panel§
Sourcedef min_size(self, /, size: float) -> Panel§
Minimum size of the panel, including margins.
def min_width(self, /, width: float) -> Panel§
Sourcedef resizable(self, /, resizable: bool) -> Panel§
Can panel be resized by dragging the edge of it?
Default is True.
If you want your panel to be resizable you also need to make the ui use the available space.
This can be done by using Ui.take_available_space, or using a
widget in it that takes up more space as you resize it, such as:
* Wrapping text (Ui.horizontal_wrapped).
* A egui.ScrollArea.
* A egui.Separator.
* A egui.TextEdit.
* …
Source@staticmethod
def right(id: str) -> Panel§
Create a right panel.
The id_salt only needs to be unique among the panels of the same parent Ui, e.g. "my_right_panel".
Sourcedef show(self, /, ctx: Context) -> Any§
Show the panel inside a Ui.
def show_animated(self, /, ctx: Context, is_expanded: bool) -> Any§
@staticmethod
def show_animated_between(ctx: Context, is_expanded: bool, collapsed_panel: Panel, expanded_panel: Panel) -> Any§
Source@staticmethod
def show_animated_between_inside(is_expanded: bool, collapsed_panel: Panel, expanded_panel: Panel) -> Any§
Renamed to egui.Panel.show_switched.
Note: egui.Panel.show_switched takes is_expanded by &mut (to allow
drag-to-collapse / drag-to-expand to flip it) and passes a bool to
add_contents instead of an float animation fraction. To opt in,
migrate to the new name.
Sourcedef show_animated_inside(self, /, is_expanded: bool) -> Any§
Renamed to egui.Panel.show_collapsible.
Note: egui.Panel.show_collapsible takes is_expanded by &mut so it can
flip it to False when the user drags the panel closed. To opt in,
migrate to the new name.
Sourcedef show_collapsible(self, /, is_expanded: Mutable) -> Any§
Show the panel if *is_expanded is True,
otherwise hide it, with a slide animation in between.
During the animation add_contents runs against the real panel, and the
panel slides off-screen toward its fixed edge (clipped against the parent).
The parent only reserves the visible portion, so neighboring widgets follow.
is_expanded is taken by &mut so the panel can flip it to False when
the user drags the resize handle past the panel's minimum size, and back
to True if the user drags the handle outward while the panel is closed.
When egui.Panel.resizable is True, double-clicking the resize edge also
flips *is_expanded.
A fully collapsed panel keeps a thin grab handle at its fixed edge, so the
user can drag it back open. See egui.Panel.drag_to_open to opt out.
Sourcedef show_inside(self, /) -> Any§
Renamed to egui.Panel.show.
Sourcedef show_separator_line(self, /, show_separator_line: bool) -> Panel§
Show a separator line, even when not interacting with it?
The separator line sits on the panel's inner edge, i.e. the edge facing the rest of the ui.
It is painted outside the Frame's outline, in room the panel reserves for it in the
frame's Frame.outer_margin, so that going from the panel contents outwards you get:
contents | Frame.inner_margin | Frame.stroke | separator line | Frame.outer_margin
Turning this off removes that reserved room too, so the panel gets no permanent gap along that edge.
A resizable panel still shows a line while hovered or dragged, regardless of this setting.
With this setting off there is no room reserved for it, so that transient line is painted
just outside the frame's outline, overlapping the Frame.outer_margin.
Default: True.
Source@staticmethod
def show_switched(is_expanded: Mutable, collapsed_panel: Panel, expanded_panel: Panel) -> Any§
Show either a collapsed or expanded panel, with a nice slide animation between.
The collapsed_panel is shown only when fully collapsed; during the
animation, the expanded_panel slides in/out toward its fixed edge,
interpolating its visible size between the two panels' sizes.
add_contents receives expanded = True whenever the expanded panel is
rendered (including mid-animation), and False for the collapsed view.
Give the two panels distinct ids so their persisted sizes don't overwrite each other.
Drag-to-collapse / drag-to-expand
The user can resize the panel by dragging its edge. Pulling that edge
past the size limits flips *is_expanded:
.resizable(True)on the expanded panel enables drag-to-collapse: shrinking pastmin_sizesets*is_expanded = False..resizable(True)on the collapsed panel enables drag-to-expand: growing pastmax_sizesets*is_expanded = True. (Useegui.Panel.exact_sizeoregui.Panel.max_sizeto set a tight cap so a small outward drag is enough to trigger the swap.)
Both panels share a single resize-handle widget under the hood (keyed to the expanded panel's id), so a single uninterrupted drag can collapse and re-expand the panel without releasing.
Double-clicking the resize edge also flips *is_expanded (whichever
panel is currently shown is the one whose edge you click).
Sourcedef size_range(self, /, min: float, max: float) -> Panel§
The allowable size range for the panel, including margins.
Source@staticmethod
def top(id: str) -> Panel§
Create a top panel.
The id_salt only needs to be unique among the panels of the same parent Ui, e.g. "my_top_panel".
By default this is NOT resizable.