python flet带tab的页面,笔记

import flet as ft
import platform



def main(page: ft.Page):

    
    
    page.fonts = {"simhei":"/usr/share/fonts/ms-fonts/simhei.ttf",
                  "msyh":"C:/WINDOWS/Fonts/MSYH.TTC"}

    if platform.system() =="Windows":
        page.theme = ft.Theme(font_family="msyh")
    else:
        #page.theme = ft.Theme(font_family = "simhei")
        pass

    page.bgcolor = ft.colors.GREEN_100  #设置背景
    
    page.title = "两个标签页"

    tb1 = ft.Tab(text="标签页1")
    tb2 = ft.Tab(text="标签页2")

    
    def btn_click(e):
        print("牙买呆")
        items1.append(ft.Text("Yamede", size=100))
        #tb1.content = ft.Column(controls=items1)
        page.update()  #别忘了刷新页面

    items1 = [ft.Text(value="hello", size=100),
         ft.ElevatedButton("点我", bgcolor=ft.colors.BROWN_100,on_click=btn_click)]
            
    tb1.content = ft.Column(controls=items1)
    tb2.content = ft.Text(value="baga", size=200)

    tabbar = ft.Tabs()
    tabbar.tabs = [tb1, tb2]

    page.window_width = 600
    page.window_height = 600

    page.window_left = 0
    page.window_top = 0

    page.add(tabbar)
    
    

ft.app(target=main)

你可能感兴趣的:(python,笔记,开发语言)