Skip to content

Settings

UI Settings

The UI behaviour might be modified via an settings object. This can be passed to the run function or defined through a config file. Settings defined in the config file have bigger priority. Every interface has its own settings 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, Options

@dataclass
class Env:
    foo: Annotated["str", Options("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 settings object

from mininterface.settings import MininterfaceSettings

opt = MininterfaceSettings()
run(settings=opt)

mininterface.settings.MininterfaceSettings

interface: Optional[InterfaceName] = None

Enforce an interface. By default, we choose automatically.

GuiSettings

from mininterface.settings import MininterfaceSettings, GuiSettings

opt = MininterfaceSettings(gui=GuiSettings(combobox_since=1))
run(settings=opt)

mininterface.settings.GuiSettings

combobox_since: int = 10

The threshold to switch from radio buttons to a combobox.

radio_select_on_focus: bool = False

Select the radio button on focus. Ex. when navigating by arrows.