flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
9.43k stars 360 forks source link

IconButton rotate #3182

Closed andreizolotarev closed 2 weeks ago

andreizolotarev commented 2 weeks ago

Description I wanted to rotate the icons using rotate in ft.IconButton() and got incorrect rotation angles.

Code example to reproduce the issue:

import flet as ft

def main(page: ft.Page):
    page.title = "Flet counter example"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(e):
        txt_number.value = str(int(txt_number.value) - 1)
        page.update()

    def plus_click(e):
        txt_number.value = str(int(txt_number.value) + 1)
        page.update()

    page.add(
        ft.Row(
            [
                ft.IconButton(ft.icons.ARROW_BACK_IOS, on_click=minus_click, rotate=ft.Rotate(angle=90)),
                txt_number,
                ft.IconButton(ft.icons.ARROW_FORWARD_IOS, on_click=plus_click, rotate=ft.Rotate(angle=-90)),
            ],
            alignment=ft.MainAxisAlignment.CENTER,
        )
    )

ft.app(main)

Describe the results you received: incorrect_angle

Describe the results you expected: correct_angle

Additional information you deem important (e.g. issue happens only occasionally):

Flet version (pip show flet):

Name: flet
Version: 0.22.0
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: /home/az/miniconda3/envs/flet22/lib/python3.12/site-packages
Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog

Operating system: Linux