m.rule_menu.style(display='table', margin='10px')
        m.rule_item.style(color='#000000',
                          fontSize='1.5em',
                          textTransform='uppercase',
                          fontFamily='Arial, Verdana, Sans-serif',
                          float='bottom',
                          padding='10px',
                          listStyle='none',
                          cursor='pointer',
                          webkitTransition='all 0.3s linear',
                          webkitUserSelect='none')
        m.rule_item_hover.style(
            color='#ffffff',
            background='#000000',
            paddingLeft='20px',
        )
        m.rule_item_selected.style(padding='10px',
                                   background='#FF0000',
                                   color='#000000',
                                   webkitTransform='rotate(3deg)')
        # populate the menu with shared colors dict
        m.add_item(*self.sdata.keys())
        m.sort()
        return m


if __name__ == '__main__':
    # this self import is needed to do live-editing. Everything else works without it
    from colors_meteor_example import ColorsMeteorApp
    server.run(ColorsMeteorApp)
Ejemplo n.º 2
0
        if self.i.count>5:
            self.i.stop()
            self.i2.stop()
        self.i.count+=1
        try:
            self.tp.remove()
        except Exception as e:
            pass
        self.tp= self.rdoc.element('p',text='New paragraph #'+str(self.i.count))
        self.tp.att.style(
            position='absolute',
            left=str(50*self.i.count)+'px',
            top=str(50*self.i.count)+'px')
        self.rdoc.body.append(self.tp)
        self.p.text= 'there are now '+str(self.i.count+1)+' paragraphs'

    # this method is called on incomming messages from other sessions
    @gen.coroutine
    def outmessage(self, txt, sender):
        self.p_doc.text= 'total documents open: '+txt

    # this method is called when session is closed
    @gen.coroutine
    def onclose(self):
        total_clients= str(len(self.wsh.sharedhandlers))
        self.wsh.msg_in_proc(total_clients)

if __name__=='__main__':
    import webalchemy.server
    server.run(8083,my_app) # the first parameter is the port...
Ejemplo n.º 3
0
from webalchemy import server

class HellowWorldApp:
    def initialize(self, **kwargs):
        self.rdoc = kwargs['remote_document']
        self.rdoc.body.element(h1='Hello World!!!').events.add(click=self.clicked, translate=True)
        self.rdoc.body.element(h2='--------------')
        self.rdoc.stylesheet.rule('h1').style(
            color='#FF0000',
            marginLeft='75px',
            marginTop='75px',
            background='#00FF00'
        )

    def clicked(self):
        self.textContent = self.textContent[1:]
        rpc(self.handle_click_on_backend, 'some message', 'just so you see how to pass paramaters')

    def handle_click_on_backend(self, sender_id, m1, m2):
        self.rdoc.body.element(h1=m1+m2)

if __name__ == '__main__':
    # this import is necessary because of the live editing. Everything else works OK without it
    from hello_world_example import HellowWorldApp
    server.run(HellowWorldApp)


Ejemplo n.º 4
0
                                        for code in codes.split(';'):
                                            s.br()
                                            s.code(text=code).events.add(click=lambda: self.inp.prop(value=code))
                    with s.div(cls='row'), s.div(cls='col-md-12'), s.div(cls='panel panel-info'):
                        s.div(text="Symbols:", cls='panel-heading')
                        s.div(text="x", cls='panel-body')
                    with s.div(cls='row'), s.div(cls='col-md-12'), s.div(cls='panel panel-info'):
                        s.div(text="Functions:", cls='panel-heading')
                        s.div(text="bla bla", cls='panel-body')
        self.rdoc.JS('MathJax.Hub.Queue(["Typeset",MathJax.Hub, "examples_body"]);')

    def execute(e):
        if e.keyCode == weba.KeyCode.ENTER:
            rpc(self.calc_with_sympy, self.value)

    def calc_with_sympy(self, sender_id, text):
        try:
            self.pbody.element(p=str(sympify(text)))
        except Exception as e:
            self.pbody.element('p').prop.innerHTML = str(e).replace("\n", '<br>')


if __name__ == "__main__":
    from webalchemy import server
    from math_explorer import MathExplorer
    server.run(MathExplorer)




Ejemplo n.º 5
0
                                    for code in codes.split(';'):
                                        h.br()
                                        h.code(text=code).events.add(
                                            click=lambda: self.inp.prop(value=
                                                                        code))
                    with b.panel(flavor='info'):
                        b.panel_heading(text="Symbols:")
                        b.panel_body(text="x")
                    with b.panel(flavor='info'):
                        b.panel_heading(text="Functions:")
                        b.panel_body(text="bla bla")
        self.rdoc.JS(
            'MathJax.Hub.Queue(["Typeset",MathJax.Hub, "examples_body"]);')

    def execute(e):
        if e.keyCode == weba.KeyCode.ENTER:
            rpc(self.calc_with_sympy, self.value)

    def calc_with_sympy(self, sender_id, text):
        try:
            self.pbody.element(p=str(sympify(text)))
        except Exception as e:
            self.pbody.element('p').prop.innerHTML = str(e).replace(
                "\n", '<br>')


if __name__ == "__main__":
    from webalchemy import server
    from math_explorer import MathExplorer
    server.run(MathExplorer)
from webalchemy import server
from three_d_earth import ThreeDEarth

if __name__ == '__main__':
    server.run(ThreeDEarth)
Ejemplo n.º 7
0
from webalchemy import server
from three_d_earth import ThreeDEarth


if __name__ == '__main__':
    server.run(ThreeDEarth)
Ejemplo n.º 8
0
            fontSize='1.5em',
            textTransform='uppercase',
            fontFamily='Arial, Verdana, Sans-serif',
            float='bottom',
            padding='10px',
            listStyle='none',
            cursor='pointer',
            webkitTransition='all 0.3s linear',
            webkitUserSelect='none'
        )
        m.rule_item_hover.style(
            color='#ffffff',
            background='#000000',
            paddingLeft='20px',
        )
        m.rule_item_selected.style(
            padding='10px',
            background='#FF0000',
            color='#000000',
            webkitTransform='rotate(3deg)'
        )
        # populate the menu with shared colors dict
        m.add_item(*self.sdata.keys())
        m.sort()
        return m

if __name__ == '__main__':
    # this self import is needed to do live-editing. Everything else works without it
    from colors_meteor_example import ColorsMeteorApp
    server.run(ColorsMeteorApp)
from webalchemy import server


class JQueryMobileExample:

    # Include the jQuery mobile stylesheet and the jQuery/jQuery mobile scripts
    stylesheets = ["http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css"]
    include = [
        "http://code.jquery.com/jquery-1.10.2.min.js",
        "http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js",
    ]

    # Use the modified html
    main_html_file_path = "jquerymobile_example.html"

    def initialize(self, **kwargs):
        self.rdoc = kwargs["remote_document"]
        # Grab the main <div> from the html document and inject some elements
        self.main = self.rdoc.getElementById("main")
        self.main.element(h1="Main content")
        self.main.element(button="A button")
        # Force jQuery to redraw (enhance) the document
        self.rdoc.JS('jQuery(#{self.main}).trigger("create")')


if __name__ == "__main__":
    # this import is necessary because of the live editing. Everything else works OK without it
    from jquerymobile_example import JQueryMobileExample

    server.run(JQueryMobileExample)
def run():
    from webalchemy import server
    from webalchemy.examples.three_d_earth.three_d_earth import ThreeDEarth
    server.run(ThreeDEarth)
from webalchemy import server
from todomvc import AppTodoMvc as app

if __name__ == '__main__':
    server.run(app)
Ejemplo n.º 12
0
class HellowWorldApp:
    def initialize(self, **kwargs):
        self.rdoc = kwargs['remote_document']
        self.print_hi = self.rdoc.translate(self.print_hi)
        self.rdoc.body.element(h1='Hello World!').events.add(
            click=self.clicked, translate=True)
        self.rdoc.body.element(h2='--------------')
        self.rdoc.stylesheet.rule('h1').style(color='#FF0000',
                                              marginLeft='75px',
                                              marginTop='75px',
                                              background='#00FF00')

    def clicked(self):
        self.textContent = self.textContent[1:]
        rpc(self.handle_click_on_backend, 'some message',
            'just so you see how to pass paramaters')
        srv(self.print_hi)()

    def handle_click_on_backend(self, sender_id, m1, m2):
        self.rdoc.body.element(h1=m1 + m2)

    def print_hi(self):
        print('hi!')


if __name__ == '__main__':
    # this import is necessary because of the live editing. Everything else works OK without it
    from hello_world_example import HellowWorldApp
    server.run(HellowWorldApp)
def run():
    from webalchemy import server
    from webalchemy.examples.todomvc.todomvc import AppTodoMvc as app
    server.run(app)
Ejemplo n.º 14
0

class JQueryMobileExample:

    # Include the jQuery mobile stylesheet and the jQuery/jQuery mobile scripts
    stylesheets = [
        'http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css'
    ]
    include = [
        'http://code.jquery.com/jquery-1.10.2.min.js',
        'http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js'
    ]

    # Use the modified html
    main_html_file_path = "jquerymobile_example.html"

    def initialize(self, **kwargs):
        self.rdoc = kwargs['remote_document']
        # Grab the main <div> from the html document and inject some elements
        self.main = self.rdoc.getElementById('main')
        self.main.element(h1="Main content")
        self.main.element(button="A button")
        # Force jQuery to redraw (enhance) the document
        self.rdoc.JS('jQuery(#{self.main}).trigger("create")')


if __name__ == '__main__':
    # this import is necessary because of the live editing. Everything else works OK without it
    from jquerymobile_example import JQueryMobileExample
    server.run(JQueryMobileExample)