Beispiel #1
0
 def build(self):
     s = Tag.select(onchange=self.bind.select(b"this.value"),
                    style="width:100%",
                    disabled=bool(self.disabled))
     for idx, i in enumerate(self.choices):
         s.add(Tag.option(i, value=idx, selected=(self.value == i)))
     return Tag.div(s, klass="select")
Beispiel #2
0
    def build(self):  # DYNAMIC RENDERING HERE !
        nav = Nav(
            "gtag-demo", {
                "Page1": lambda: self.setPage(1),
                "Page2 (%s)" % int(self.nb): lambda: self.setPage(2),
                "Page3": lambda: self.setPage(3),
                "Login": lambda: self.doLogin(),
            }, {
                "exit": lambda: self.exit(-1),
            })

        if self.page == 1:
            page = Page1(self.n, self.txt)
        elif self.page == 2:
            page = Page2(self.nb)
        elif self.page == 3:
            page = Page3(self.selectedTab, self.rb, self.so, self.sb, self.cb)
        else:
            page = "no"
        return Tag.div(
            nav,
            Section(Tag.div("<br>", page, klass="container")),
            Button("test mbox", onclick=self.bind.setMBox(42)),
            Button("test toast", onclick=self.bind.setToast(42)),
            MBox(self.msg),
            Toaster(self.toast),
        )
Beispiel #3
0
 def build(self):
     o = Tag.div(klass="control")
     o.add(
         '<label class="checkbox">',
         Tag.input(
             checked=value(self.value),
             type="checkbox",
             klass="checkbox",  # override
             onclick=self.bind.switch(),
             disabled=bool(self.disabled)),
         self.title,
         self.value,
         "</label>")
     return o
Beispiel #4
0
 def build(self):
     return Tag.div(
         ShareState(),
         self.a,
         Button("++", onclick=self.bind.changeState()),
         Button("QUIT", onclick=self.bind.quit() + ";window.close()"),
     )
Beispiel #5
0
class Fake(GTag):
    headers = Tag.script("""
function m1() {alert(1)}
function m2() {alert(2)}
function m3() {alert(3)}
function JJJJJJJJJ() {}
    """)
Beispiel #6
0
 def build(self):
     return Tag.div(
         Box("A test page, with a binding value:", self.nb),
         MyInc(self.nb),
         Button("show", onclick=self.bind.kik()),
         Button("show T", onclick=self.bind.kik2()),
     )
Beispiel #7
0
 class My(GTag):
     headers=Tag.script("//hello")
     def init(self):
         self.v=12
     def build(self):
         return Tag.div("hello",self.v,onclick=self.bind.onclick())
     def onclick(self):
         pass
Beispiel #8
0
    class My(GTag):
        headers=Tag.script("// hi")

        def init(self,v):
            self.v=v

        def build(self):
            return Tag.div("hello",self.v,onclick=self.bind.onclick(42))
        def onclick(self,anArg=None):
            pass
Beispiel #9
0
def test_TagWithStrangeContent():
    assert str(Tag(False)) == '<div></div>'
    assert str(Tag(True)) == '<div></div>'
    assert str(Tag(None)) == '<div></div>'
    assert str(Tag("1")) == '<div>1</div>'
    assert str(Tag(1)) == '<div>1</div>'
    assert str(Tag(0)) == '<div>0</div>'
Beispiel #10
0
def test_Tag():
    assert str(Tag()) == '<div></div>'
    assert str(Tag(checked=True)) == '<div checked></div>'
    assert str(Tag(checked=False)) == '<div></div>'
    assert str(Tag("hello")) == '<div>hello</div>'
    assert str(Tag("hello", klass="john doe",
                   value=0)) == '<div value="0" class="john doe">hello</div>'
    assert str(Tag(
        "hello", data_mining="hell")) == '<div data-mining="hell">hello</div>'
    assert str(Tag("hello", 42,
                   klass="john doe")) == '<div class="john doe">hello 42</div>'
    assert str(
        Tag("hello", onclick='alert("bill & john")')
    ) == '<div onclick="alert(&quot;bill &amp; john&quot;)">hello</div>'
Beispiel #11
0
def test_Tag_change_props():
    t = Tag()
    t.id = 1
    assert str(t) == '<div id="1"></div>'
    t.id = None
    assert str(t) == '<div></div>'
    t.cid = 1
    assert str(t) == '<div cid="1"></div>'
    t.cid = None
    assert str(t) == '<div></div>'
Beispiel #12
0
    def build(self):
        tabs = Tabs(self.selected, ["tab1", "tab2", "tab3"])

        return Tag.div(
            tabs, Box(self.renderContent()),
            Checkbox(self.cb, "disable all (vv)"),
            HBox(
                Text("You selected", self.rb),
                RadioButtons(self.rb, ["apple", "pear", "banana"],
                             disabled=self.cb,
                             onchange=self.realCallback),
            ),
            HBox(
                Text("You selected", self.so),
                Select(self.so, ["apple", "pear", "banana"], disabled=self.cb),
            ),
            HBox(
                Text("You selected", self.sb),
                SelectButtons(self.sb, ["apple", "pear", "banana"],
                              disabled=self.cb),
            ))
Beispiel #13
0
 def build(self):
     return Tag.div( self.c, self.v )
Beispiel #14
0
 def build(self):
     return Tag.div(
         "hello",
         self.main.a,  # <-- the shared state is the main instance !
     )
Beispiel #15
0
 def build(self):
     return Tag.div("hello")
Beispiel #16
0
 def build(self):
     return Tag.pre("hello")
Beispiel #17
0
 def build(self):
     ll = [Star(i) for i in range(int(self.n))]
     return Tag.text("-%s-" % self.n, *ll)
Beispiel #18
0
 def build(self):
     return Tag.div(ShareState(), )
Beispiel #19
0
 def build(self):
     return Tag.div(self.v,
                    Tag.button("++", onclick=self.bind.add()),
                    style="border:2px solid red")
Beispiel #20
0
 def compute(self):
     return Tag.text("-%s-" % self.n)
Beispiel #21
0
 def build(self):
     rows=[C(i) for i in self.ll]
     return Tag.div(*rows)
Beispiel #22
0
 def build(self):
     return Tag.div( self.c, C())
Beispiel #23
0
 def build(self):
     o=Tag.div( self.v,
         Tag.button("reload1",onclick=self.bind.evtReload()),
         Tag.button("reload2",onclick=self.bind.evtReload2()),
     )
     return o
Beispiel #24
0
 def build(self):
     return Tag.div("hello", self.main.a, self.parent.v)
Beispiel #25
0
 def build(self):
     return Tag.div("hello",self.v,onclick=self.bind.onclick(42))
Beispiel #26
0
 def build(self):
     return Tag.text(self.n, *self.stars())
Beispiel #27
0
 def build(self):
     return Tag.div(self.cpt, Btn(self.cpt), XSelect(self.v, list("123")),
                    Checkbox(self.cb, "yoo"), self.cb,
                    Tag.button("EXIT", onclick=self.bind.exxx()))
Beispiel #28
0
 def build(self):
     self.child=C()
     return Tag.div( self.child )
Beispiel #29
0
 def build(self):
     self("m3()")
     return Tag.span(self.cpt,
                     Tag.Button("++", onclick=self.bind.add()),
                     style="background:yellow;padding:10px")
Beispiel #30
0
 def build(self):
     return Tag.text(self.compute(), self.stars(
     ))  # <---- DANGEROUS the binded is str'ised at build !!!!