S or /

SourceClass Frame

from egui import Frame
class Frame:

A frame around some content, including margin, colors, etc.

Definitions

The total (outer) size of a frame is content_size + inner_margin + 2 * stroke.width + outer_margin.

Everything within the stroke is filled with the fill color (if any).

The four rectangles, from inside to outside, are: * content_rect: the rectangle that is made available to the inner Ui or widget. * fill_rect: the rectangle that is filled with the fill color (inside the stroke, if any). * widget_rect: is the interactive part of the widget (what sense clicks etc). * outer_rect: what is allocated in the outer Ui, and is what is returned by Response.rect.

Usage

Dynamic color

If you want to change the color of the frame based on the response of the widget, you need to break it up into multiple steps:

You can also respond to the hovering of the frame itself:

Note that you cannot change the margins after calling begin.

Methods§

Source@staticmethod def canvas(style: Style) -> Frame§

A canvas to draw on.

In bright mode this will be very bright, and in dark mode this will be very dark.

Source@staticmethod def central_panel(style: Style) -> Frame§
Sourcedef corner_radius(self, /, corner_radius: CornerRadius) -> Frame§

The rounding of the outer corner of the egui.Frame.stroke (or, if there is no stroke, the outer corner of egui.Frame.fill).

In other words, this is the corner radius of the widget rect.

Source@staticmethod def dark_canvas(style: Style) -> Frame§

A dark canvas to draw on.

Sourcedef fill(self, /, fill: Color32) -> Frame§

The background fill color of the frame, within the egui.Frame.stroke.

Known as background in CSS.

Sourcedef fill_rect(self, /, content_rect: Rect) -> Rect§

Calculate the fill_rect from the content_rect.

This is the rectangle that is filled with the fill color (inside the stroke, if any).

Source@staticmethod def group(style: Style) -> Frame§

For when you want to group a few widgets together within a frame.

Sourcedef inner_margin(self, /, margin: float) -> Frame§

Margin within the painted frame.

Known as padding in CSS.

Sourcedef multiply_with_opacity(self, /, opacity: float) -> Frame§

Opacity multiplier in gamma space.

For instance, multiplying with 0.5 will make the frame half transparent.

@staticmethod def none() -> Frame§
Sourcedef outer_margin(self, /, margin: float) -> Frame§

Margin outside the painted frame.

Similar to what is called margin in CSS. However, egui does NOT do "Margin Collapse" like in CSS, i.e. when placing two frames next to each other, the distance between their borders is the SUM of their other margins. In CSS the distance would be the MAX of their outer margins. Supporting margin collapse is difficult, and would requires complicating the already complicated egui layout code.

Consider using egui.Spacing.item_spacing for adding space between widgets.

Sourcedef outer_rect(self, /, content_rect: Rect) -> Rect§

Calculate the outer_rect from the content_rect.

This is what is allocated in the outer Ui, and is what is returned by Response.rect.

def rounding(self, /, corner_radius: CornerRadius) -> Frame§
Sourcedef shadow(self, /, shadow: Shadow) -> Frame§

Optional drop-shadow behind the frame.

Sourcedef show(self, /) -> Any§

Show the given ui surrounded by this frame.

The returned InnerResponse.response will have the rect of the entire frame, including margins.

Source@staticmethod def side_top_panel(style: Style) -> Frame§
Sourcedef stroke(self, /, stroke: Stroke) -> Frame§

The width and color of the outline around the frame.

The width of the stroke is part of the total margin/padding of the frame.

Sourcedef total_margin(self, /) -> MarginF32§

How much extra space the frame uses up compared to the content.

egui.Frame.inner_margin + egui.Frame.stroke.width + egui.Frame.outer_margin.

Sourcedef widget_rect(self, /, content_rect: Rect) -> Rect§

Calculate the widget_rect from the content_rect.

This is the visible and interactive rectangle.

Source@staticmethod def window(style: Style) -> Frame§

The default frame for an egui.Window.