Textfield colors updates not working #940
-
Hi Everybody,
the only way to have control of the textfield colors is to wrap it with a container, but then the color properties of the textfield looks useless.. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
What is your flet version please? A PR was made to solve this issue automatically: #807. I think you have to upgrade your flet version to latest. But to fix your problem, First, modify the first line in your function from def textbox_changed(e):
tb.bgcolor = ft.colors.RED
# ... Then, add |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply. Same problem if I try to set the text color inside the textfield.. |
Beta Was this translation helpful? Give feedback.
-
So, I tried your code with the flet v0.4.0.dev1117, and the only change you have to make having this version is to change import flet as ft
def main(page: ft.Page):
def textbox_changed(e):
tb.bgcolor = ft.colors.RED ### <-------------------- change e.bgcolor to tb.bgcolor
c.bgcolor = ft.colors.RED
page.update()
c = ft.Container(
content=ft.Text('test'),
bgcolor=ft.colors.YELLOW,
padding=5,
)
tb = ft.TextField(
bgcolor=ft.colors.AMBER,
label="Textbox with 'change' event:",
on_submit=textbox_changed
)
page.add(tb, c)
ft.app(target=main) If you don't want to upgrade to one of the latest pre-release, and still want to use the import flet as ft
def main(page: ft.Page):
def textbox_changed(e):
tb.bgcolor = ft.colors.RED ### <------------------------------- change e.bgcolor to tb.bgcolor
c.bgcolor = ft.colors.RED
page.update()
c = ft.Container(
content=ft.Text('test'),
bgcolor=ft.colors.YELLOW,
padding=5,
)
tb = ft.TextField(
bgcolor=ft.colors.AMBER,
label="Textbox with 'change' event:",
on_submit=textbox_changed,
filled=True ### <--------------------------------------add this prop
)
page.add(tb, c)
ft.app(target=main) The PR #807 is not present in v0.3.2 hence if you stay on this version, you must explicitly set the Hope I could help you. |
Beta Was this translation helpful? Give feedback.
So, I tried your code with the flet v0.4.0.dev1117, and the only change you have to make having this version is to change
e.bgcolor
totb.bgcolor
. Below is the full code with that one line modification. It works as expected.