icons.py

open in new tab
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
This example demonstrates the use of icons in Flexx.
"""

import os

import flexx
from flexx import app, ui

# todo: support icons in widgets like Button, TabWidget, etc.
# todo: support fontawesome icons


class Icons(ui.Widget):

    def init(self):

        ui.Button(text='Not much to see here yet')


if __name__ == '__main__':

    fname = os.path.join(os.path.dirname(flexx.__file__), 'resources', 'flexx.ico')
    black_png = ('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAIUlEQVR42mNgY'
                 'GD4TyEeTAacOHGCKDxqwKgBtDVgaGYmAD/v6XAYiQl7AAAAAElFTkSuQmCC')

    # Select application icon. Can be a url, a relative url to a shared asset,
    # a base64 encoded image, or a local filename. Note that the local filename
    # works for setting the aplication icon in a desktop-like app, but not for
    # a web app. File types can be ico or png.

    icon = None  # use default
    # icon = 'https://assets-cdn.github.com/favicon.ico'
    # icon = app.assets.add_shared_asset('ico.icon', open(fname, 'rb'))
    # icon = 'data:image/png;base64,' + black_png
    # icon = fname

    m = app.App(Icons, title='Icon demo', icon=icon).launch('app')
    app.start()