add Notification Badge in IconButton Every 1 Second not work . #2757
Unanswered
bobwatcherx
asked this question in
Q&A
Replies: 1 comment
-
replaced from flet import *
import asyncio
import random
async def main(page:Page):
page.window_width = 300
page.window_height = 180
select_index = Text(1)
def change_page(e, index):
pass
async def interval_chats():
count = 0
while True:
count = count + 1
random_index = random.randint(0, len(page.bottom_appbar.content.controls) - 1)
template = Badge(
content=page.bottom_appbar.content.controls[random_index],
text=count
)
page.bottom_appbar.content.controls[random_index] = template
page.bottom_appbar.content = Row(page.bottom_appbar.content.controls, alignment="spaceEvenly")
print("===========================")
print(page.bottom_appbar.content.controls)
print("===========================")
await asyncio.sleep(1)
await page.update_async()
page.bottom_appbar = BottomAppBar(
bgcolor="blue",
content=Row([
IconButton(icon="home",
icon_size=30,
icon_color="white",
on_click=lambda e:change_page(e,1)
),
IconButton(icon="notifications",
icon_size=30,
icon_color="white" ,
on_click=lambda e:change_page(e,2)
)
], alignment="spaceEvenly")
)
asyncio.create_task(interval_chats()) # Mulai interval_chats sebagai sebuah tugas asinkron
await page.add_async(select_index)
app(main, view=AppView.WEB_BROWSER, port=5050) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question
i make notif like chat app but in button and every seconds random add notification . with badge but . not work . and in print success change but ui not changed
Code sample
Error message
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions