Built-in argument types
oneFace support the following types:
Type | Example | Type check | Range check | Description |
---|---|---|---|---|
str | Val(str) |
True |
False |
String input. |
int | Val(int, [0, 10]) |
True |
True |
Int input. |
float | Val(float, [0, 1]) |
True |
True |
Float input. |
bool | Val(bool) |
True |
False |
Bool input. |
OneOf | Val(OneOf, ["a", "b", "c"]) |
False |
True |
Input should be a element of the range. |
SubSet | Val(SubSet, ["a", "b", "c"]) |
False |
True |
Input should be a subset of the range. |
InputPath | Val(InputPath) |
True |
True |
Input should be an exist file path(str or pathlib.Path ). |
OutPath | Val(OutputPath) |
True |
False |
Input should be a file path(str or pathlib.Path ) |
This example show all built-in types, name as builtin_example.py
:
from oneface.core import one, Val
from funcdesc.types import (OneOf, SubSet, InputPath, OutputPath)
@one
def func(in_path: InputPath,
out_path: OutputPath = "./test",
a: Val[int, [0, 10], text="parameter (a)"] = 10,
b: Val[float, [0, 1]] = 0.1,
c: Val[str] = "aaaa",
d: Val[bool] = False,
e: Val[OneOf, ["a", "b", "c"]] = "a",
f: Val[SubSet, ["a", "b", "c"]] = ["a"]):
print(in_path, out_path)
print(a, b, c, d, e, f)
return a + b
func.qt_gui()
Running the script will get:
Change the last line to func.dash_app()
and run it again, you will get: