コード例 #1
0
ファイル: app.py プロジェクト: ylwb/ReactiPy
def ui():
    count, set_count = use_state(0)

    def update_counter():
        print('test->', count())
        set_count(int(count()) + 1)

    return frame()(
        "Hello World",
        label(text='Count is ' + str(count())),
        button(text="Click Me", margin_x=8, margin_y=8, width=16, background='red', color='white', on_click=lambda: update_counter())
    )
コード例 #2
0
dash = Dash(__name__)


def gen_dropdown(id):
    return Dropdown(id=id,
                    options=[{
                        'val': c,
                        'label': c
                    } for c in ['a', 'b', 'c']],
                    selected='a')


components = []
for id in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'O']:
    components.append(label(id))
    components.append(gen_dropdown(id))

dash.layout = div(components)

import time


@dash.react('O', ['C', 'B', 'D', 'E'])
def update_odata(c, b, d, e):
    print 'O'
    time.sleep(10)
    return {'selected': 'b'}


@dash.react('A', ['C'])
コード例 #3
0
ファイル: helloworld.py プロジェクト: jdfreder/dash
import pandas.io.data as web

from react import Dash
from components import div, h2, PlotlyGraph, Dropdown, label

from datetime import datetime as dt
df = web.DataReader("aapl", 'yahoo', dt(2007, 10, 1), dt(2009, 4, 1))

dash = Dash(__name__)

dash.layout = div([
    h2('hello dash'),
    div(className='row', content=[
        div(className='two columns', content=[
            div([
                label('select x data'),
                Dropdown(id='xdata', options=[{'val': c, 'label': c}
                                              for c in df.columns])
            ]),
            div([
                label('select y data'),
                Dropdown(id='ydata', options=[{'val': c, 'label': c}
                                              for c in df.columns])
            ]),
        ]),
        div(className='ten columns', content=[
            PlotlyGraph(id='graph')
        ])
    ])
])
コード例 #4
0
ファイル: network-dependencies.py プロジェクト: jdfreder/dash
from react import Dash
from components import div, Dropdown, label

dash = Dash(__name__)


def gen_dropdown(id):
    return Dropdown(id=id, options=[{"val": c, "label": c} for c in ["a", "b", "c"]], selected="a")


components = []
for id in ["A", "B", "C", "D", "E", "F", "G", "O"]:
    components.append(label(id))
    components.append(gen_dropdown(id))

dash.layout = div(components)

import time


@dash.react("O", ["C", "B", "D", "E"])
def update_odata(c, b, d, e):
    print "O"
    time.sleep(10)
    return {"selected": "b"}


@dash.react("A", ["C"])
def update_adata(c):
    print "A"
    time.sleep(10)
コード例 #5
0
from components import div, h2, PlotlyGraph, Dropdown, label

from datetime import datetime as dt

df = web.DataReader("aapl", 'yahoo', dt(2007, 10, 1), dt(2009, 4, 1))

dash = Dash(__name__)

dash.layout = div([
    h2('hello dash'),
    div(className='row',
        content=[
            div(className='two columns',
                content=[
                    div([
                        label('select x data'),
                        Dropdown(id='xdata',
                                 options=[{
                                     'val': c,
                                     'label': c
                                 } for c in df.columns])
                    ]),
                    div([
                        label('select y data'),
                        Dropdown(id='ydata',
                                 options=[{
                                     'val': c,
                                     'label': c
                                 } for c in df.columns])
                    ]),
                ]),