3
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Python] flet.colorsで簡便に利用できる色の一覧

Posted at

blend_mode=flet.BlendMode.SRC

実際の色の見え方はBlendモードに依存します。
デフォルトのBlendモードはMODULATEで、各要素のbgcolorの見え方がPageなどの大要素のbgcolorに影響されます。
BlendモードをSRCとした場合はPargeのbgcolorによらずbgcolor本来の色が表示されます。
ただしBLACK87などはSRCモードではBLACKと同じ真っ黒として表示されるようです。

ここではSRCの場合の色の見え方をまとめました。
各Blendモードの処理についてはFlutterの公式ドキュメントをご覧ください。
https://api.flutter.dev/flutter/dart-ui/BlendMode.html

結果

List_of_Flet_Colors.png

コード

import flet as ft

def main(page: ft.Page):
    colors   = [c for c in dir(ft.colors) if not c.startswith('_')]
    rows     = []
    row      = []

    for n,c in enumerate(colors):
        color = eval('ft.colors.'+c)
        cont  = ft.Container(bgcolor=color, width=126, height=21, blend_mode=ft.BlendMode.SRC)
        text  = ft.Text(c, size=9, text_align=ft.TextAlign.RIGHT, color=ft.colors.WHITE)
        col   = ft.Column(controls=[text,cont], spacing=0)
        if n%14 == 14-1:
            row.append(col)
            rows.append(ft.Row(row))
            row = []
        else:
            row.append(col)

    page.add(ft.Column(controls=rows))
    page.title = 'List of Flet Colors (blend_mode=ft.BlendMode.SRC)'
    page.bgcolor = ft.colors.BLACK
    page.update()
        
ft.app(target=main)
3
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?