Skip to content

Qt interface configs

Window name

By default the window name is the name of the function, but it can be changed by name parameter of .qt_gui method:

from oneface import one, Val

@one
def bmi(name: str,
        height: Val[float, [100, 250]] = 160,
        weight: Val[float, [0, 300]] = 50.0):
    BMI = weight / (height / 100) ** 2
    print(f"Hi {name}. Your BMI is: {BMI}")
    return BMI

bmi.qt_gui(name="BMI calculator")

rename_example_qt

Argument label

By default, argument label is the variable name. But it can be explicitly set by text parameter:

@one
def bmi(name: Val(str, text="NAME"),  # explicitly label setting
        height: Val[float, [100, 250]] = 160,
        weight: Val[float, [0, 300]] = 50.0):
    BMI = weight / (height / 100) ** 2
    print(f"Hi {name}. Your BMI is: {BMI}")
    return BMI
arg_label_qt

Run multiple times

By default, oneface Qt interface run only once then exit, when click the run button.

run_once

You can use the run_once=False to make it run multiple times:

bmi.qt_gui(run_once=False)

run_once

Window size

The size parameter is used to explicitly specify the window size:

bmi.qt_gui(size=(400, 600))  # width and height