[Question] Align the content of a text button #1885
-
QuestionI need the content of the TextButton content to be left-aligned. Or can you help me to set a class for a toolbar, the container is 265 wide, the reference is in the following image it is the part with red border: Code sampleimport flet
from flet import*
class Herramientas(UserControl):
def __init__(self, text, icon, on_click):
super().__init__()
self.button=Container(
Row(
spacing=0,
controls=[
TextButton(
expand=True,
text=text,
icon=icon,
on_click=on_click,
icon_color='#17F1FF',
style=ButtonStyle(
shape={
'':RoundedRectangleBorder(radius=0)
}
)
),
IconButton(
icon= icons.ARROW_FORWARD_IOS_ROUNDED,
icon_color='#8DF1A9',
icon_size=24,
tooltip=text,
style=ButtonStyle(
shape={
'':RoundedRectangleBorder(radius=0)
}
)
)
]
)
)
def build(self):
return self.button
def main(page: Page):
page.title='EduConter - Dashboard'
page.theme_mode = 'DARK'
page.padding = 0
page.window_maximized = True
page.resizable = False
page.vertical_alignment = 'Center'
page.horizontal_alignment = 'Center'
dashboard=Container(
Row(
spacing=0,
controls=[
Container(
Container(
Column(
horizontal_alignment=CrossAxisAlignment.CENTER,
controls=[
Column(
horizontal_alignment=CrossAxisAlignment.CENTER,
spacing=0,
controls=[
Row(
alignment=MainAxisAlignment.CENTER,
controls=[
Image(
src='./imagenes/logoEduConter.png',
width=233,
height=186
)
]
),
Text(
'HERRAMIENTAS.',
color='#9B80B7',
weight='bold',
size=22
),
Herramientas('INVENTARIO', icons.IMPORT_CONTACTS_ROUNDED, lambda e: print('Click :3'))
]
)
],
)
),
gradient=LinearGradient(
colors=['#3733FF', '#0C6065', '#16138D'],
begin=alignment.bottom_left,
end=alignment.top_right
),
width=265,
height=page.window_height + 48,
bgcolor='red'
),
Container(
width= page.window_width + 86,
height=page.window_height + 48,
gradient=LinearGradient(
colors=['#0650E1', '#12C9B3, 0.7', '#251488'],
begin=alignment.center_right,
end=alignment.center_left
)
)
]
)
)
page.add(dashboard)
page.update()
flet.app(target=main) Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Answered by
ndonkoHenri
Sep 28, 2023
Replies: 1 comment
-
To left-align the content of the TextButton, you could make use of the TextButton(
expand=True,
# text=text,
# icon=icon,
content=Row(
alignment=MainAxisAlignment.START,
controls=[
Icon(icon),
Text(text)
]
),
on_click=on_click,
icon_color='#17F1FF',
style=ButtonStyle(
shape={
'': RoundedRectangleBorder(radius=0)
}
)
), |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
AngelCard
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To left-align the content of the TextButton, you could make use of the
content
prop as below: