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

Text control is in the ft.DataColumn ,how to set the Text control's margin #3123

Closed jackwan990 closed 2 weeks ago

jackwan990 commented 2 weeks ago

Text control is in the ft.DataColumn ,how to set the Text control's margin,eg: image

import flet as ft

def main(page: ft.Page): page.add( ft.DataTable( width=700, bgcolor="yellow", border=ft.border.all(2, "red"), border_radius=10, vertical_lines=ft.border.BorderSide(3, "blue"), horizontal_lines=ft.border.BorderSide(1, "green"), sort_column_index=0, sort_ascending=True, heading_row_color=ft.colors.BLACK12, heading_row_height=100, data_row_color={"hovered": "0x30FF0000"}, show_checkbox_column=True, divider_thickness=0,

column_spacing=200,

        columns=[
            ft.DataColumn(
                ft.Text("Column 1"),
                on_sort=lambda e: print(f"{e.column_index}, {e.ascending}"),
            ),
            ft.DataColumn(
                ft.Text("ddddddddd 2",width=400,),
                tooltip="This is a second column",
                numeric=True,
                on_sort=lambda e: print(f"{e.column_index}, {e.ascending}"),
            ),
        ],
        rows=[
            ft.DataRow(
                [ft.DataCell(ft.Text("A")), ft.DataCell(ft.Text("1"))],
                selected=True,
                on_select_changed=lambda e: print(f"row select changed: {e.data}"),
            ),
            ft.DataRow([ft.DataCell(ft.Text("B")), ft.DataCell(ft.Text("2"))]),
        ],
    ),
)

ft.app(target=main)

jackwan990 commented 2 weeks ago

Looking forward to your answer,thanks