File size: 1,986 Bytes
211b5f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import gradio
import random
import numpy

# function for generating random integers
def generate_random_integers(n):
    return numpy.random.randint(1,100, n)

# function for displaying random integers
def display_random_integers(integers):
    # create a Dataframe to display the integers
    columns = ["Number"]
    df = pandas.DataFrame(columns=columns)
    for i in integers:
        df = df.append({"Number": i}, ignore_index=True)
    return df

#define the main step function
def todo_list_app(num_items, items):
    # create a Dataframe to display the items
    columns = ["Task", "Completion Status"]
    df = pandas.DataFrame(columns=columns)
    for i in range(num_items):
        item = items[i]
        due_date = item["due_date"]
        completion_status = item["completion_status"]
        df = df.append({"Task": due_date, "Completion Status": completion_status}, ignore_index=True)
    return df

#define the function for progressive web app
def progressive_web_app(num_items, items):
    return todo_list_app(num_items, items)

#create the interface
interface = gradio.Interface(
    fn=todo_list_app,
    inputs=[
        "number",
        gradio.Radio(["buy groceries", "take dog for a walk", "learn gradio", "write a note", "workout", "learn a new skill"]),
        gradio.Dataframe(
            headers=["Item", "Due Date", "Completion Status"],
            datatype=["str", "str", "bool"],
            label="To-Do List",
        ),
    ],
    outputs="number",
    examples=[
        [5, "buy groceries", [["buy groceries", "due today", False], ["take dog for a walk", "due tomorrow", False], ["learn gradio", "due next week", False], ["write a note", "due in a few days", False], ["workout", "due tomorrow", False]]],
        [3, "buy groceries", [["buy groceries", "due today", False], ["take dog for a walk", "due tomorrow", False], ["learn gradio", "due next week", False]]],
    ],
)

#create the progressive web app interface
interface.launch(kind="pwa")