Skip to content

Facet

mininterface.facet.Facet

A frontend side of the interface. While a dialog is open, this allows to set frontend properties like the heading.

Read Tag.facet to see how to access it from the front-end side. Read Mininterface.facet to see how to access it from the back-end side.

set_title(text)

Set the main heading.

submit(_post_submit=None)

Submits the whole form.

from mininterface import run, Tag

def callback(tag: Tag):
    tag.facet.submit()

m = run()
out = m.form({
    "My choice": Tag(choices=["one", "two"], on_change=callback)
})
# continue here immediately after clicking on a radio button

Layout

Experimental

Share your thoughs about how the layout method should work!

Should you need represent more information, Facet has a hidden method _layout that you may call with a list of LayoutElements:

  • str
  • pathlib.Path
  • facet.Image
from dataclasses import dataclass
from pathlib import Path
from mininterface import run
from mininterface.facet import Image

@dataclass
class Env:
    my_str: str = "Hello"

m = run(Env)
# Image object has currently single 'src' attribute
m.facet._layout(["My text", Image("dog1.jpg"), Path("dog1.jpg")])
m.form()

As you see, the program displays "My text", then the image and than the path info. Layout GUI

Even in the TUI, the images are visible. (And mouse-zoomable.) Layout TUI