flet icon indicating copy to clipboard operation
flet copied to clipboard

Window theme mode bug

Open theN1C1 opened this issue 1 year ago • 3 comments

Duplicate Check

  • [ ] I have searched the opened issues and there are no duplicates

Describe the bug

When using a dark theme, the color of the window itself changes, but the title bar remains white.

Code

import flet as ft

import os, sys

def main(page: ft.Page):
    # settings
    page.title = "Console"
    page.window_width = 600
    page.window_height = 500
    page.window_resizable = True
    page.window_maximizable = False

    page.window_left = 400
    page.window_top = 200
    page.theme_mode = "DARK"

    page.window_visible = True
    page.update()

ft.app(target = main, view = ft.AppView.FLET_APP_HIDDEN)

To reproduce

  1. Put a dark theme

Expected behavior

No response

Screenshots

image-1

Operating System

Windows

Operating system details

Windows 10

Flet version

0.23.0

Regression

No, it isn't

Suggestions

No response

Additional details

No response

theN1C1 avatar Jun 19 '24 08:06 theN1C1

Can you try this:

Source: https://github.com/flutter/flutter/issues/117692#issuecomment-1367039552

ndonkoHenri avatar Jun 19 '24 14:06 ndonkoHenri

Can you try this:

new_project.mp4 Source: flutter/flutter#117692 (comment)

why the DARK theme works as SYSTEM

ghost avatar Jun 20 '24 07:06 ghost

Can you try this:

new_project.mp4 Source: flutter/flutter#117692 (comment)

The thing is that in Flet DARK works as SYSTEM. For example, on customtkinter everything works fine

https://github.com/flet-dev/flet/assets/133054489/43e9852c-0629-4413-9360-298260c36933

WagmanK avatar Jun 20 '24 08:06 WagmanK

In Flet v1 Alpha, we added a new prop to the Window class: brightness. With it, you will be able to configure/force the app window brightness, in addition to setting the page's theme mode.

Example code:

import flet as ft


def main(page: ft.Page):
    page.vertical_alignment = page.horizontal_alignment = "center"
    page.theme_mode = ft.ThemeMode.LIGHT
    page.window.brightness = ft.Brightness.LIGHT

    def handle_brightness_change(e: ft.Event[ft.Switch]):
        page.window.brightness = (
            ft.Brightness.DARK
            if page.window.brightness == ft.Brightness.LIGHT
            else ft.Brightness.LIGHT
        )
        e.control.thumb_icon = (
            ft.Icons.WB_SUNNY_OUTLINED
            if e.control.value
            else ft.Icons.MODE_NIGHT_OUTLINED
        )

    def handle_theme_mode_change(e: ft.Event[ft.Switch]):
        page.theme_mode = (
            ft.ThemeMode.DARK
            if page.theme_mode == ft.ThemeMode.LIGHT
            else ft.ThemeMode.LIGHT
        )
        e.control.thumb_icon = (
            ft.Icons.WB_SUNNY_OUTLINED
            if e.control.value
            else ft.Icons.MODE_NIGHT_OUTLINED
        )

    page.add(
        ft.Switch(
            label="Window Brightness",
            value=True,
            thumb_icon=ft.Icons.WB_SUNNY_OUTLINED,
            on_change=handle_brightness_change,
        ),
        ft.Switch(
            label="Page Theme Mode",
            value=True,
            thumb_icon=ft.Icons.WB_SUNNY_OUTLINED,
            on_change=handle_theme_mode_change,
        ),
    )


ft.run(main)
Image

ndonkoHenri avatar Aug 08 '25 14:08 ndonkoHenri