Skip to content

Options

UI Options

The UI behaviour might be modified via an options object. This can be passed to the run function or defined through a config file. Options defined in the config file have bigger priority. Every interface has its own options object.

Config file special section

In a YAML config file, use a special section 'mininterface' to set up the UI. For example, this stub will enforce your program to use the Tui interface.

mininterface:
    interface: tui

Complete example

Source of program.py, we have one single attribute foo:

from typing import Annotated
from dataclasses import dataclass
from mininterface import run, Choices

@dataclass
class Env:
    foo: Annotated["str", Choices("one", "two")] = "one"

m = run(Env)
m.form()

Source of program.yaml will enforce the comboboxes:

number: 5
mininterface:
    gui:
        combobox_since: 1

The difference when using such configuration file.

Configuration not used Configuration used

The options object

from mininterface.options import MininterfaceOptions

opt = MininterfaceOptions()
run(options=opt)

mininterface.options.MininterfaceOptions

interface: Optional[InterfaceName] = None

Enforce an interface. By default, we choose automatically.

GuiOptions

from mininterface.options import MininterfaceOptions, GuiOptions

opt = MininterfaceOptions(gui=GuiOptions(combobox_since=1))
run(options=opt)

mininterface.options.GuiOptions

combobox_since: int = 5

The threshold to switch from radio buttons to a combobox.