Flet

mail@pastecode.io avatar
unknown
python
a month ago
1.4 kB
12
Indexable
Never
import flet as ft

val = 0

def main(page: ft.Page):
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

    def func_click_button(e):
        global val
        if code_dropdown.content.value == "+":
            val += int(message.value)

        elif code_dropdown.content.value == "-":
            val -= int(message.value)
            
        output_text.value = str(val)

        page.update()

    text = ft.Text(
        "TEXT",
        size=36
    )

    code_dropdown = ft.Container(
        content=ft.Dropdown(
            width=300,
            options=[
                ft.dropdown.Option("+"),
                ft.dropdown.Option("-")
            ]
        )
    )

    message = ft.TextField(
        label="Выражение",
        width=300
    )

    button = ft.ElevatedButton(
        on_click=func_click_button,
        width=200,
        height=40,
        content=ft.Column(
            [
                ft.Text(
                    value="Выполнить",
                    size=18
                )
            ],
            alignment=ft.MainAxisAlignment.CENTER
        )
    )

    output_text = ft.Text(
        size=24
    )

    page.add(text, code_dropdown, message, button, output_text)

ft.app(target=main)
Leave a Comment