How to use the awe.Page function in awe

To help you get started, we’ve selected a few awe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dankilman / awe / tests / test_element.py View on Github external
def test_update_props():
    page = Page()

    class TestElement(view.Element):
        pass

    element = page._new_child(TestElement)
    element.update_props({'key1': 'value1', 'key2': 'value2'})
    assert element.props == {'key1': 'value1', 'key2': 'value2', 'key': element.id}
    element.update_props({'key1': 'new_value1'})
    assert element.props == {'key1': 'new_value1', 'key2': 'value2', 'key': element.id}
    element.update_props({'key1': 'newer_value1', 'key3': 'value3'}, override=False)
    assert element.props == {'key1': 'new_value1', 'key2': 'value2', 'key': element.id, 'key3': 'value3'}
github dankilman / awe / tests / test_parser.py View on Github external
def test_chart():
    page = Page()
    c = page.new('Chart')
    assert isinstance(c, chart.Chart)
github dankilman / awe / tests / test_parser.py View on Github external
def test_parse_children():
    page = Page()
    result = page.new(['Divider', 'Text'])
    children = result.children
    assert len(children) == 2
    divider, text = children
    assert isinstance(divider, view.Divider)
    assert isinstance(text, view.Text)
github dankilman / awe / tests / test_element.py View on Github external
def test_element_builder():
    page = Page()
    builder = page.element_builder
    code_element1 = builder('code')
    assert code_element1.element_type == 'Raw'
    assert code_element1.data['tag'] == 'code'
    code_element2 = builder('code', props={'test_key': 'test_value'})
    assert code_element2.element_type == 'Raw'
    assert code_element2.data['tag'] == 'code'
    assert code_element2.props['test_key'] == 'test_value'
    text_element1 = builder.text('hello')
    assert text_element1.element_type == 'Text'
    assert text_element1.text == 'hello'
    text_element2 = builder.text('hello', props={'test_key2': 'test_value2'})
    assert text_element2.element_type == 'Text'
    assert text_element2.text == 'hello'
    assert text_element2.props['test_key2'] == 'test_value2'
github dankilman / awe / tests / test_parser.py View on Github external
def test_parse_raw_element_dict_text_value():
    page = Page()
    result = page.new('span: Hello There')
    assert len(result.children) == 1
    assert isinstance(result.children[0], view.Inline)
    assert result.children[0].text == 'Hello There'
github dankilman / awe / tests / view / test_page.py View on Github external
def wrapper(fn):
        page = Page(**page_kwargs)
        page.start(open_browser=False)

        @retry()
        def result():
            driver.get('http://localhost:{}'.format(page._port))
            fn()
        return result
    return wrapper
github dankilman / awe / examples / hello_world.py View on Github external
def main():
    page = Page()
    page.new_text('Hello World!')
    page.start(block=True)
github dankilman / awe / examples / showcase.py View on Github external
def main():
    now = time.time()
    page = Page('Showcase')
    grid = page.new_grid(columns=3, props={'gutter': 12})
    grid.new_card('Card 1')
    card = grid.new_card()
    tabs = grid.new_tabs()
    collapse = grid.new_collapse()
    grid.new_chart([(now+i, -i) for i in range(100)], transform='numbers')
    grid.new_table(['Header 1', 'Header 2', 'Header 3'], page_size=4).extend([
        ['Value {}'.format(i), 'Value {}'.format(i+1), 'Value {}'.format(i+2)]
        for i in range(1, 20, 3)
    ])
    grid.new_divider()
    grid.new_button(lambda: None, 'Button 1', block=True)
    grid.new_input()
    grid.new_icon('heart', theme='twoTone', two_tone_color='red')
    inline = grid.new_inline()
    card.new_text('Card Text 1')
github dankilman / awe / examples / chart_flat.py View on Github external
def main():
    page = Page()
    data = generate_random_data()
    chart = page.new_chart(data=data, transform={
        'type': 'flat',
        'chart_mapping': ['color', 'fruit'],
        'series_mapping': ['temp', 'city'],
        'value_key': 'value'
    }, moving_window=3 * 60)
    page.start()
    while True:
        time.sleep(0.7)
        chart.add(generate_random_data())
github dankilman / awe / examples / collapse.py View on Github external
def main():
    page = Page()
    collapse = page.new_collapse()
    panel1 = collapse.new_panel('Panel 1', active=True)
    panel1.new_text('Hello From Panel 1')
    panel2 = collapse.new_panel(active=False)
    panel2.header.new_icon('pie-chart')
    panel2.header.new_inline(' Panel 2')
    panel2.new_text('Hello From Panel2')
    panel3 = collapse.new_panel('Panel 3')
    panel3.new_text('Hello From Panel3')
    page.start(block=True)