Ejemplo n.º 1
0
    def setup(self, container):
        first = True
        for key, value in sorted(self.game.worlds.items(),
                                 key=lambda e: e[1].sortorder):
            world_container = html.DIV(Class="world-container" +
                                       (" world-container-enabled" if first
                                        else " world-container-hidden"),
                                       id="world-container_" + key)
            first = False
            resources = html.DIV(id="resources")

            resources <= html.B("Resources availible on " + value.name)
            resources <= html.HR()
            resources <= html.DIV(Class="currency-holder-holder")
            world_container <= resources
            buildings = html.DIV(id="buildings")
            buildings <= html.B("Buildings on " + value.name)
            buildings <= html.HR()
            buildings <= html.DIV(Class="building-holder-holder")
            world_container <= buildings
            world_container <= html.DIV(id="upgrades")
            vis = html.DIV(id="visualize")
            vis <= html.H1(key)
            vis <= html.IMG(src=value.image)
            world_container <= vis
            container["world-container-container"] <= world_container
Ejemplo n.º 2
0
 def __init__(self):
     super().__init__(
         [
             H.H1('todos'),
             NewTodoInput(),
         ],
         Class='header',
     )
Ejemplo n.º 3
0
def init():
    global SCREEN, CTX
    document.body.append(html.H1("Browser Invaders - a Python adventure"))
    SCREEN = html.CANVAS(width=WIDTH, height=HEIGHT)
    SCREEN.style = {"background": "black"}
    document.body.append(SCREEN)
    CTX = SCREEN.getContext("2d")
    for image_name in "ship", "enemy_01", "enemy_02":
        images[image_name] = html.IMG(src="images/{}.png".format(image_name))
        print("loaded {}.png".format(image_name))
Ejemplo n.º 4
0
def action():
    html.H1('Brython Hello', style={'height':100, 'width':200, 'position': relative})  

      <script type="text/python" id="script0">
          from browser import document, console, alert
  
          def show(e):
              console.log(e)
              alert('Hello World')
              document['hello'] <= 'Hello World'
  
          document['alert-btn'].bind('click', show)
Ejemplo n.º 5
0
    def render(self):
        app = html.DIV()

        aft = AffectedByTextField()
        input = html.INPUT(type="text")

        @bind(input, "keyup")
        def update(e):
            aft.setState({"text": e.target.value})

        app = group(app, [html.H1(self.title), aft.render(), input])
        # app <= aft.render()
        # app <= input
        return app
Ejemplo n.º 6
0
def alerts(event):
    response = False
    name = ''

    window.alert('Isso é um alerta!!')

    while not (response and name):
        name = window.prompt('Digite seu nome')
        msg = 'Seu nome é vazio. Vamos refazer a operação'
        if name:
            msg = 'Esse é mesmo o seu nome?'

        response = window.confirm(msg)

    document.select_one('.body_b') <= html.H1(f'Olar {name}')
    document.select_one('.body_b') <= html.BR()
Ejemplo n.º 7
0
def init():
    global SCREEN, CTX
    document.body.append(html.H1("Browser Invaders - a Python adventure")
                         )  #display program title to user
    SCREEN = html.CANVAS(
        width=WIDTH,
        height=HEIGHT)  #create game screen with set hight and width
    SCREEN.style = {
        "background": "black"
    }  #set the screen's background to black
    document.body.append(SCREEN)
    CTX = SCREEN.getContext("2d")

    #load images for the ship and both enemies,
    #and print an acknowledgement after each load
    for image_name in "ship", "enemy_01", "enemy_02":
        images[image_name] = html.IMG(src="images/{}.png".format(image_name))
        print("loaded {}.png".format(image_name))
Ejemplo n.º 8
0
def callresponsepost():
    if len(response) > 40:
        win.localStorage.user = response
        r = win.JSON.parse(win.localStorage.user)
        r = r.screen_name
        button = html.BUTTON("Remove data",Class="w3-button w3-blue w3-center",
                 id="remove")
        name = "Hi {nam} welcome !".format(nam=r)
        h1 = html.H1(name)
        doc['user'] <= h1  + button
        doc['remove'].bind("click", remove)
        hideshow("user", "loading", "user")



    else:
        win.swal(
            "Sorry, Request failed, press the sign up button again to log you")
        hideshow("login", "loading", "login")
        win.localStorage.clear()
Ejemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        """"""
        super().__init__(*args, **kwargs)

        document.select('body')[0] <= html.H1('Hello World')
        submodule_fn()

        document.select('body')[0] <= html.H3(self.MyClass.local_python())

        a, b = 3, 5
        c = self.MyClass.pitagoras(a, b)
        document.select('body')[0] <= html.H3(
            f"Pitagoras: {a=}, {b=}, {c=:.3f}")

        self.add_css_file('custom_styles.css')

        document <= MDCButton("Button", raised=False, unelevated=True)
        document <= MDCButton("Button raised", raised=True, unelevated=True)
        button = MDCButton("Button outlined",
                           raised=False,
                           outlined=True,
                           unelevated=True)
        button.bind('click', self.on_button)

        document <= button

        label = 'SLIDER'
        unit = 'PX'
        id = 'XXXX'

        form = MDCForm()
        label_ = MDCComponent(html.SPAN(f'{label}'))
        label_.mdc.typography('subtitle1')
        form <= label_
        slider_ = form.mdc.Slider('Slider', min=1, max=100, step=5, value=50)

        options = [[f'Option-{o}', f'value-{o}'] for o in range(10)]
        value = 'value-5'
        self.select_ = form.mdc.Select('', options=options, selected=value)

        document.select('body')[0] <= form
Ejemplo n.º 10
0
    def render(self):
        app = group(html.DIV(), [
            html.H1("HI THERE!"),
            html.H2("GOOD TO SEE YOU!"),
            html.P("Some things about me:"),
            html.UL([html.LI("I am"),
                     html.LI("Does this work")]),
            html.H2("here is a nice little ticker"),
            TickerWithDescription().render(),
            TextField("here is a prop being passed").render()
        ])
        return app


# app = html.DIV(id="hithere")

# # app <= html.H1("hi there", id="what")
# thing = group(app, [WithGroups().render()])
# # thing = app
# document["root"] <= thing
# thid = document["hithere"]
# thid.innerHTML = "hedy"
# print(document.getElementById("hithere").innerHTML)
# document["what"] <= html.H1("buy")
Ejemplo n.º 11
0
from browser import document, html
from scripts.links import anchor_in_list

lista_exercicios = html.UL()
for n in range(1, 11):
    lista_exercicios <= anchor_in_list(f'Exercício {n}',
                                       f'exercicio_0{n}.html')

lista_aulas = html.UL()
for n in range(3, 10):
    lista_aulas <= anchor_in_list(f'Aula {n}', f'aula_0{n}.html')

document['aside'] <= html.H1('Lista de Aulas')
document['aside'] <= lista_aulas

document['main'] <= html.H1('Lista de exercícios')
document['main'] <= lista_exercicios
Ejemplo n.º 12
0
from random import randint

from browser import document, html
from scripts.links import anchor_in_list

val_a = randint(1, 10)
val_b = randint(1, 10)
val_c = val_a * val_b
val_d = val_a - 2 * val_b + 1

document['main'] <= html.H1('Você está na página 1')
document['main'] <= html.P('Responda ao contrário ou o diabão vai te pegar')
document['main'] <= html.P(f'{val_a} * {val_b} = ')
if val_c % 2:
    document['main'] <= anchor_in_list(f'{val_c}', 'diabao.html', 'certo')
    document['main'] <= anchor_in_list(f'{val_d}', 'page_2.html', 'errado')
else:
    document['main'] <= anchor_in_list(f'{val_d}', 'page_2.html', 'errado')
    document['main'] <= anchor_in_list(f'{val_c}', 'diabao.html', 'certo')
Ejemplo n.º 13
0
# Create initial layout

from browser import html
from browser import document

header = html.HEADER(Class="text-center")
main = html.MAIN()
footer = html.FOOTER()

headingOne = html.H1('Python101')
subtitleOne = html.SMALL('Learning how to use python')

header.append(headingOne)
header.append(subtitleOne)

main.append(html.H2('Main Section', Class="text-center"))
footer.append(html.H3('Footer Section', Class="text-center"))

document.body.append(header)
document.body.append(main)
document.body.append(footer)
Ejemplo n.º 14
0
from browser import document, html
from scripts.links import anchor_in_list

lista_aulas = html.UL()
for n in range(3, 10):
    if n not in [8]:
        lista_aulas <= anchor_in_list(f'Aula {n}', f'aula_0{n}.html')

document['aside'] <= html.H1('Páginas das aulas')
document['aside'] <= lista_aulas
paginas_praticar = html.UL()

document['aside'] <= html.H1('Páginas para praticar')
paginas_praticar <= anchor_in_list('Caixinha', 'caixinha.html')
paginas_praticar <= anchor_in_list('Teclado', 'keyboard.html')
paginas_praticar <= anchor_in_list('Logger', 'logger.html')
paginas_praticar <= anchor_in_list('Drag n Drop', 'drag.html')
paginas_praticar <= anchor_in_list('TODO list', 'todo_list.html')
document['aside'] <= paginas_praticar

lista_explicacoes = html.UL()
document['aside'] <= html.H1('Páginas de explicação')
lista_explicacoes <= anchor_in_list('Aula 4a', 'aula_04_a.html')
lista_explicacoes <= anchor_in_list('Aula 4b', 'aula_04_b.html')
lista_explicacoes <= anchor_in_list('Aula 5a', 'aula_05_a.html')
lista_explicacoes <= anchor_in_list('Aula 5b', 'aula_05_b.html')
lista_explicacoes <= anchor_in_list('Aula 5c', 'aula_05_c.html')
lista_explicacoes <= anchor_in_list('Aula 6a', 'aula_06_a.html')
lista_explicacoes <= anchor_in_list('Aula 7a', 'aula_07_a.html')
lista_explicacoes <= anchor_in_list('Aula 7b', 'aula_07_b.html')
lista_explicacoes <= anchor_in_list('Aula 7c', 'aula_07_c.html')
Ejemplo n.º 15
0
def title_header():
    return html.H1("Employee Directory",
                 Class="w3-wide w3-myfont w3-xlarge",
                 id="title", style={"text-align":"center"})
Ejemplo n.º 16
0
page2 = ws.NotebookPage("Brython code",
                        "khaki",
                        html.TEXTAREA(open("demo.py").read()),
                        id="page2")
page3 = ws.NotebookPage("CSS",
                        "lightgreen",
                        html.TEXTAREA(open("demo.css").read()),
                        id="page3")
page4 = ws.NotebookPage("HTML",
                        "lightpink",
                        html.TEXTAREA(open("demo.html").read()),
                        id="page4")
document <= ws.Notebook([page1, page2, page3, page4])

page1 <= (
    html.H1("Brywidgets Demo"),
    html.P(
        """This page is a demo of most of the widgets in the brywidgets module.
                The whole page is a Notebook with 4 tabs - the other 3 tabs show the files which create this page.
                This page contains a RowPanel with two Panels each containing a ColumnPanel.
                The buttons on the right are laid out using GridPanels"""))

panel1 = ws.Panel(
    title="The 100 greatest singles of all time - click to find the artist",
    id="panel1")
spincontrol = ws.SpinControl(10, 5, 15, setrowcount, id="spinner")
listbox = ws.ListBox(artistdict.keys(), showartist, 10)
togglebutton = ws.ToggleButton("Button is Up!", toggleclick)

panel1 <= ws.ColumnPanel([
    html.
Ejemplo n.º 17
0
 def update(self, one_state_change=False):
     return html.H1(self.state["text"].replace("<", "&lt;"))
Ejemplo n.º 18
0
from browser import document, html
import browser


def hello(ev):
    browser.alert('Hello cloud-django-brython!')


print('WELCOME CLOUD-DJANGO-BRYTHON')
# Insert Header into document body
document <= html.H1("WELCOME CLOUD-DJANGO-BRYTHON", Id="main")

hello_button = html.BUTTON("hello")
hello_button.bind("click", hello)

document <= hello_button
Ejemplo n.º 19
0
introtext = html.DIV([
html.H1("BrySVG DEMO"),
html.P("""The other tabs on this page provide a series of short demos showing the capabilities of the BrySVG module.
For each demo there is also a tab showing the code needed to create it.  A brief description of each demo follows:"""),
html.P(html.B("Demo 1")+""" - This illustrates MouseMode.PAN: drag the canvas to move the viewport."""+html.BR()+
"""It also shows how to create most of the SVG objects:
CanvasObject, PolylineObject, PolygonObject, RectangleObject, EllipseObject, CircleObject, BezierObject,
ClosedBezierObject, SmoothBezierObject, SmoothClosedBezierObject, TextObject, WrappingTextObject"""+html.BR()+
"""and the use of the CanvasObject methods rotateElement and translateElement.
(The same set of objects is also used in Demo2 and Demo 6.)"""),
html.P(html.B("Demo 2")+""" - This is the famous Tangram puzzle, which demonstrates MouseMode.DRAG and canvas.vertexSnap.
Drag a piece onto the square. If a vertex of the piece is close to a vertex of the square, the piece will "snap"
so that the vertices match. To complete the puzzle, fill the square completely with the pieces."""),
html.P(html.B("Demo 3")+""" - This demonstrates MouseMode.TRANSFORM. Objects can be dragged around on the canvas.
In addition, clicking on an object shows a bounding box and a number of handles which can be used to transform the shape:
top-left: rotate; middle-right: stretch horizontally; bottom-middle: stretch vertically; bottom-right: enlarge"""),
html.P(html.B("Demo 4")+""" - This demonstrates canvas.edgeSnap, and also how to create RegularPolygons.
Drag the polygons around, matching edges as closely as possible. If the angle between the edges is not too great,
the dragged polygon should rotate so that the edges coincide. Polygons can also be rotated by hand."""),
html.P(html.B("Demo 5")+""" - This demonstrates ImageButtons, MouseMode.DRAW, and MouseMode.EDIT. Choose a type of shape.
Click on the canvas, then move to start drawing a shape. Click again to create a new vertex.
To finish the shape and switch to MouseMode.EDIT, either double-click on the canvas or tap on the "select" button (top left)"""+html.BR()+
"""Now clicking on a shape will display some (red) handles, which can be dragged to change the shape.
Clicking on a handle of a Bezier shape will display (green) control handles which control the curvature at that vertex.
For a smooth Bezier shape, these will move as a pair."""),
html.P(html.B("Demo 6")+""" - This demonstrates switching between MouseMode.TRANSFORM and MouseMode.EDIT.
Double-clicking on the canvas will toggle between transforming the shapes (as in Demo 2)
and editing them using the handles (as in Demo 5)."""),
html.P(html.B("Demo 7")+""" - This demonstrates some of the methods in the polygoncanvas module.
Drag one of the yellow shapes; its colour will change depending on its position relative to the white, fixed, polygon.
Green=Inside, Pink=Overlapping, Yellow=Disjoint, Orange=Containing, and Blue=Equal. The intersection points (if any) will also be shown.""")
], id="introtext")
Ejemplo n.º 20
0
def detail_employee(ev):
    global response
    if response is not None:
        test = eval(ev.target.id)
        if isinstance(test, int):
            div = html.DIV(Class="w3-animate-left")
            div1 = html.DIV(Class="w3-border-bottom w3-bar w3-animate-left")
            i = html.I(Class="fa fa-angle-left w3-xxxlarge w3-text-cyan", id="back1")
            a = html.A(Class="w3-bar-item",id="back", style={"width": "10%"})
            a <= i
            h1 =  html.H1("Employee Details",
                      Class="w3-wide w3-myfont w3-xlarge w3-bar-item w3-center",
                      style={"width": "90%"})
            div1 <= a + h1
            for x in response['employee']:
                ul = html.UL(Class="w3-ul w3-border w3-animate-left")
                if x['id'] == int(ev.target.id):
                    li = html.LI(Class="w3-bar")
                    img = html.IMG(Class="w3-bar-item w3-circle",
                           src="img/img_avatar2.png", style={"width":"85px"})
                    #first li
                    div2 = html.DIV(Class="w3-bar-item")
                    span1 = html.SPAN(x['full_name']) + html.BR()
                    span2 = html.SPAN(x['job'])
                    div2 <= span1 + span2
                    li <= img + div2
                    #second li
                    li2=  html.LI(Class="w3-bar w3-button w3-hover-cyan",id="office")
                    div3 = html.DIV(Class="w3-bar-item")
                    span3 = html.SPAN("Call Office") + html.BR()
                    span4 = html.SPAN("781-000-002")
                    a1 = html.A(href="tel:781-000-002",id="number" ,style={"display":"none"})
                    span = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"),
                                 Class="w3-right w3-bar-item")
                    div3 <= span3 + span4 + a1
                    li2 <= span + div3
                    #third li
                    li3 = html.LI(Class="w3-bar w3-button w3-hover-cyan", id="call")
                    div4 = html.DIV(Class="w3-bar-item")
                    span5 = html.SPAN("Call Mobile") + html.BR()
                    span6 = html.SPAN("615-000-002", href="tel:615-000-002")
                    a2 = html.A(href="tel:615-000-002",id="mobile" ,style={"display":"none"} )
                    spanbis = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"),
                                 Class="w3-right w3-bar-item")
                    div4 <= span5 + span6 + a2
                    li3 <= spanbis + div4
                    # fourth li
                    li4 = html.LI(Class="w3-bar w3-button w3-hover-cyan", id="sms")
                    div5 = html.DIV(Class="w3-bar-item")
                    span7 = html.SPAN("Number Sms") + html.BR()
                    span8 = html.SPAN("615-000-002", href="tel:615-000-002")
                    a3 = html.A(href="sms:615-000-002", id="sendsms", style={"display": "none"})
                    spanbis1 = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"),
                                 Class="w3-right w3-bar-item")
                    div5 <= span7 + span8 + a3
                    li4 <= spanbis1 + div5
                    #five li
                    li5 = html.LI(Class="w3-bar w3-button w3-hover-cyan", id="email")
                    div6 = html.DIV(Class="w3-bar-item")
                    span9 = html.SPAN("Email Professional") + html.BR()
                    span10 = html.SPAN("*****@*****.**",href="mailto:[email protected]")
                    a4 = html.A(href="mailto:[email protected]", id="sendemail",style={"display": "none"})
                    spanbis1 = html.SPAN(html.I(Class="fa fa-angle-right w3-xxlarge"),
                                     Class="w3-right w3-bar-item")
                    div6 <= span9 + span10 + a4
                    li5 <= spanbis1  + div6
                    #end
                    ul <= li + li2 + li3 + li4 +li5
                    retail <= div1 + html.BR() + ul
                    doc['detail'].bind("click", direction)
                    return  retail
Ejemplo n.º 21
0
    GitHub :: PCabralSoftware - 2K18 - Twitter :: @pedrogcabral

"""

from browser import document
from browser import html
from browser.template import Template

pageName = "Python 🐍"

articleContent = open('news_file.txt').read()
articleTitle = articleContent.split('\n', 1)[0]
articleText = articleContent.split('\n', 1)[1]

article = [
    html.H1('{title}', Id='art_title'),
    html.P('{text}', Id='art_content')
]

nav = html.DIV([html.H1('{title}', Id='title'),
                html.H2('☰', Id='navbtn')],
               Class="nav")

cnt = html.DIV(html.DIV(article, Class="article"), Class="content")

ftr = html.DIV(
    [html.P('Copyright {} 2018 - All rights reserved.'.format(pageName))],
    Class="footer")

document <= [nav, cnt, ftr]
    def __init__(self, *args, **kwargs):
        """"""
        super().__init__(*args, **kwargs)
        document.select_one('body') <= html.H1('Hello World')

        logging.warning('HOLA')
Ejemplo n.º 23
0
from browser import document, html
from scripts.links import anchor_in_list

document['main'] <= html.H1('Você está no exercício 3')
document['main'] <= anchor_in_list('Começar por aqui', 'page_1.html')