djbravo_

Untitled

Dec 9th, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.29 KB | None | 0 0
  1. import flet as ft
  2.  
  3.  
  4. def main(page: ft.Page):
  5.     def resize_app_bar(i):
  6.         row_.spacing=page.width/3;
  7.         page.update();
  8.     def change_pos(i):
  9.        
  10.         if(i==1):
  11.             page.floating_action_button_location = ft.FloatingActionButtonLocation.START_DOCKED;
  12.             fab.icon=ft.icons.MENU;
  13.             row_.controls=[nothing,second,third];
  14.         elif(i==2):
  15.             page.floating_action_button_location = ft.FloatingActionButtonLocation.CENTER_DOCKED;
  16.             fab.icon=ft.icons.SEARCH;
  17.             row_.controls=[first,nothing,third];
  18.         else:
  19.             page.floating_action_button_location = ft.FloatingActionButtonLocation.END_DOCKED;
  20.             fab.icon=ft.icons.FAVORITE;
  21.             row_.controls=[first,second,nothing];
  22.         page.update();
  23.     page.horizontal_alignment = page.vertical_alignment = "center"
  24.     fab=ft.FloatingActionButton(icon=ft.icons.SEARCH,shape=ft.RoundedRectangleBorder(radius=40),)
  25.     page.floating_action_button = fab;
  26.     page.floating_action_button_location = ft.FloatingActionButtonLocation.CENTER_DOCKED;
  27.  
  28.     page.appbar = ft.AppBar(
  29.         title=ft.Text("Bottom AppBar Demo"),
  30.         center_title=True,
  31.         bgcolor=ft.colors.GREEN_300,
  32.         automatically_imply_leading=False,
  33.     )
  34.     first=ft.IconButton(
  35.                     icon=ft.icons.MENU,
  36.                     icon_size=30,
  37.                     tooltip="Menu",
  38.                     on_click=lambda i:[change_pos(1)],
  39.                 )
  40.     second=ft.IconButton(
  41.                     icon=ft.icons.SEARCH,
  42.                     icon_size=30,
  43.                     tooltip="Search",
  44.                     on_click=lambda i:[change_pos(2)],
  45.                 )
  46.     third=ft.IconButton(
  47.                     icon=ft.icons.FAVORITE,
  48.                     icon_size=30,
  49.                     tooltip="Favourties",
  50.                     on_click=lambda i:[change_pos(3)],
  51.                 )
  52.     nothing=ft.Text("            ");
  53.     row_=ft.Row(spacing=((page.width/100)*129.1)/3,controls=[first,nothing,third])
  54.     page.bottom_appbar = ft.BottomAppBar(
  55.         bgcolor=ft.colors.BLUE,
  56.         shape=ft.NotchShape.CIRCULAR,
  57.         notch_margin=5,
  58.         content=row_
  59.     )
  60.     page.on_resize=resize_app_bar;
  61.  
  62.     page.add(ft.Text("Body!"))
  63.  
  64.  
  65. ft.app(target=main)
  66.  
Advertisement
Add Comment
Please, Sign In to add comment