Py.Cafe

antonymilne/

vizro-what-day-minty

Current Day Finder

DocsPricing
  • app.py
  • requirements.txt
app.py
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
from datetime import datetime
import vizro.models as vm
from vizro import Vizro
from vizro.models.types import capture
import dash_bootstrap_components as dbc

@capture("action")  
def update_card():  
    day = datetime.now().strftime("%A")
    return f"Today is {day}"  

page = vm.Page(
    title="What day is it today?",
    layout=vm.Flex(),
    components=[
        vm.Button(
            actions=vm.Action(function=update_card(), outputs="time_card"),
            icon="Calendar Today",
            description="Click to find out what day of the week it is"
        ),
        vm.Card(id="time_card", text="Press the button above"),  
    ],
)

dashboard = vm.Dashboard(pages=[page], theme="vizro_light")
Vizro(external_stylesheets=[dbc.themes.MINTY]).build(dashboard).run()