예제 #1
0
def main(event):
    """Main UI initialization code that generates the base HTML for the web application"""

    # Create the view and container that will parent our widgets
    v = View()
    c = Container()

    # Create a row with a little spacing from the top
    r = Row(style="padding-top:20px;")

    # Make the toolbar that will contain the Step Into / Next, Stop and Step Over / Out buttons
    tb = ButtonToolbar(cl="pull-right", style="margin-top:-7px;")
    tb.addelement(Button("Next", ident="code-next-button"))
    tb.addelement(Button("Stop", ident="code-stop-button"))
    tb.addelement(Button("Step Over", ident="code-over-button"))

    # Create the span that will contain the short description of where we're at in code execution
    title = Span("", ident="code-panel-title")

    # Add the panel with the previous title and space for showing the code
    p = Panel(heading=True, ident="code")
    p.setheading(str(title) + str(tb))
    p.addelement(Paragraph())

    # Make a large 8-wide Bootstrap column to house our panel
    col = Column('lg', 8)

    # Add the panel to the column, to the row, to the container and view
    col.addelement(p)
    r.addelement(col)
    c.addelement(r)
    v.addelement(c)

    # Load the HTML generated from this widget structure onto the browser
    app.load(str(v))
예제 #2
0
async def main(event):
    print("MAIN")
    v = View()
    c = Container()

    tweets = api.home_timeline()

    for tweet in tweets:
        p = Panel(heading=True, style="max-height:150px;min-height:150px;")
        p.setheading(tweet.user.screen_name + "<div class='pull-right'>" + tweet.created_at.strftime("%b %d %Y %H:%M:%S") + "</div>")
        p.addelement(Paragraph(tweet.text))
        col = Column('md', 4)
        col.addelement(p)
        c.addelement(col)

    v.addelement(c)

    app.load(str(v))
예제 #3
0
def test_custom_class_ident_style_and_attrs():
    assert(str(Paragraph("text", cl='abclass', ident='123', style="font-size:0.9em;", attrs={"data-test": 'abc'}))
           == "<p id=\"123\" class=\"abclass\" style=\"font-size:0.9em;\" data-test=\"abc\">text</p>")
예제 #4
0
def test_text():
    assert(str(Paragraph("text")) == "<p>text</p>")
예제 #5
0
def test_basic():
    assert(str(Paragraph()) == "<p></p>")
예제 #6
0
파일: sample.py 프로젝트: smith076/pyUnity
async def oninit(event):
    logging.info("INIT")
    v = View("Sample Sofi Widget Application")

    n = Navbar(brand="SOFI", fixed='top')
    n.addlink("LINK 1")
    n.addlink("LINK 2")
    n.addtext("Just some Text with a " + str(Anchor("link", cl='navbar-link')))
    n.addlink("LINK 2", active=True)

    b = Dropdown("Dropdown", align='right')
    b.addelement(DropdownItem('Item Header', header=True))
    b.addelement(DropdownItem('Item 1'))
    b.addelement(DropdownItem('Item 2', disabled=True))
    b.addelement(DropdownItem('', divider=True))
    b.addelement(DropdownItem('Item 3'))

    n.adddropdown(b)

    v.addelement(n)

    c = Container()
    tb = ButtonToolbar()
    bgrp = ButtonGroup()
    btnDe = Button("Default")
    btnP = Button("Primary", "primary", ident='primary')
    btnI = Button("Info", "info")
    bgrp2 = ButtonGroup()
    btnS = Button("Success", "success", ident='secondary')
    btnW = Button("Warning", "warning")
    btnDa = Button("Danger", "danger")

    r = Row()
    bgrp.addelement(btnDe)
    bgrp.addelement(btnP)
    bgrp.addelement(btnI)
    bgrp2.addelement(btnS)
    bgrp2.addelement(btnW)
    bgrp2.addelement(btnDa)
    tb.addelement(bgrp)
    tb.addelement(bgrp2)
    r.addelement(tb)
    c.addelement(r)

    c.newrow(Heading(2, "Dude!"))
    c.newrow(Paragraph("Where's My Car?", ident="fiddle"))

    bd = ButtonDropdown('A Dropdown', size='xs', dropup=True, split=True, severity="success")
    bd.addelement(DropdownItem('Item Header', header=True))
    bd.addelement(DropdownItem('Item 1'))
    bd.addelement(DropdownItem('Item 2', disabled=True))
    bd.addelement(DropdownItem('', divider=True))
    bd.addelement(DropdownItem('Item 3'))
    c.newrow(bd)

    r = Row()
    col = Column(count=3)
    p = Panel("Panel 1")
    col.addelement(p)
    r.addelement(col)

    col = Column(count=3)
    p = Panel("Panel 2", 'danger')
    col.addelement(p)
    r.addelement(col)

    c.newrow(Paragraph())
    c.addelement(r)

    v.addelement(c)

    app.load(str(v), event['client'])