Search code examples
pythonflet

The color of the window title does not change with the flet python theme


I would like to change the window title, how can I do this? Image

import flet as ft

def main(page: ft.Page):
    page.theme_mode = ft.ThemeMode.DARK
    page.window_height, page.window_width = 300, 300
    page.title = 'app'
    
    page.add(ft.Text('Hello'))
ft.app(main)

Tried to change the theme, didn't help, and it's not in the documentation.


Solution

  • I examined your code and realized that something is missing. You need to use an AppBar(). Pros: You can change the color! Cons: There's some limited colors...

    page.appbar = ft.AppBar(
            title=ft.Text("AppBar Example"),
            center_title=False,
            bgcolor=ft.colors.PRIMARY)
    

    You have to enter the color in bgcolor=ft.colors.here Add this to the main function so you can use these limited colors: colors

    I researched a bit and found out that you can also change the page.theme (not the page.theme_mode). I'll affect your widget's theme but it's better and nicer.

    page.theme = Theme(color_scheme_seed="blue")
    page.update()