All possible interfaces
Normally, you get an interface through mininterface.run
but if you do not wish to parse CLI and config file, you can invoke one directly from mininterface.interfaces import *
.
Apart from the default Mininterface
, the base interface the others are fully compatible with, several interfaces exist:
How to invoke a specific interface.
from mininterface.interfaces import TuiInterface
with TuiInterface("My program") as m:
number = m.ask_number("Returns number")
Mininterface
When a GUI is not available (GuiInterface), nor the rich TUI is available (TextualInterface), nor the mere interactive TextInterface is available, the original non-interactive Mininterface is used. The ensures the program is still working in cron jobs etc.
GuiInterface
or TkInterface
or 'gui'
A tkinter window.
It inherits from GuiOptions
TuiInterface
or 'tui'
An interactive terminal.
TextualInterface
If textual installed, rich and mouse clickable interface is used.
TextInterface
Plain text only interface with no dependency as a fallback. The non-interactive session becomes interactive if possible but there is no mouse support. Does not clear whole screen as TextualInterface if it suits better your program flow.
WebInterface
or 'web'
Exposed to a web.
from dataclasses import dataclass
from mininterface import run
@dataclass
class Env:
my_flag: bool = False
my_number: int = 4
if __name__ == "__main__":
m = run(Env, interface="web")
m.form() # Exposed on the web
Note that you can expose to the web any mininterface application, like this GUI:
from dataclasses import dataclass
from mininterface import run
@dataclass
class Env:
my_flag: bool = False
my_number: int = 4
if __name__ == "__main__":
m = run(Env, interface="gui")
m.form() # Seen in the GUI
We expose it to the web by invoking it through the mininterface
program.
Caveat
Should you plan to use the WebInterface, we recommend invoking it be the first thing your program do. All the statements before invoking it run multiple times!
Warning
Still in beta. We appreciate help with testing etc.
ReplInterface
A debug terminal. Invokes a breakpoint after every dialog.