コード例 #1
0
                document.div(className=GCOL3[1], childList=[document.button('33%', onclick=self.on_btn)]),
            ]),
            document.div(className=GROW, childList=[
                document.div(className=GCOL5[2], childList=[document.button('40%', onclick=self.on_btn)]),
                document.div(className=GCOL5[1], childList=[document.button('20%', onclick=self.on_btn)]),
                document.div(className=GCOL5[1], childList=[document.button('20%', onclick=self.on_btn)]),
                document.div(className=GCOL5[1], childList=[document.button('20%', onclick=self.on_btn)]),
            ]),
            document.div(className=GROW, childList=[
                document.div(className=' '.join((GCOL12[6], GSM12[6], GMD12[6], GLG12[4], GXL12[3])),
                             childList=[document.button('6/12', onclick=self.on_btn)]),
                document.div(className=' '.join((GCOL12[3], GSM12[3], GMD12[3], GLG12[2], GXL12[2])),
                             childList=[document.button('3/12', onclick=self.on_btn)]),
                document.div(className=' '.join((GCOL12[2], GSM12[2], GMD12[2], GLG12[1], GXL12[1])),
                             childList=[document.button('2/12', onclick=self.on_btn)]),
                document.div(className=' '.join((GCOL12[1], GSM12[1], GMD12[1], GLG12[1], GXL12[1])),
                             childList=[document.button('1/12', onclick=self.on_btn)]),
            ]),
        ])
        self.document.body.appendChild(self.divcont1)

    def on_btn(self, ev):
        tid = int(ev['targetId'])
        elm = self.document.getElementById(tid)
        elm.textContent = 'clicked'


if __name__ == "__main__":
    win = MyWindow()
    start_app({'window': win, 'path': '/'}, )
コード例 #2
0
# -*- coding: utf-8 -*-
# dominter
from dominter.dom import Window, start_app

win = Window()
document = win.document
tag_p1 = document.createElement('p')
tag_p1.textContent = "text content"


def on_btn1(ev):
    tag_p1.textContent = 'Hello world!'


tag_btn1 = document.createElement('button')
tag_btn1.textContent = "button1"
tag_btn1.onclick = on_btn1
document.body.appendChild(tag_p1)
document.body.appendChild(tag_btn1)
start_app(win)
コード例 #3
0
ファイル: simple_instanse.py プロジェクト: takd4com/dominter
class MyWindow1(Window):
    def __init__(self):
        super(MyWindow1, self).__init__()
        document = self.document
        self.txt1 = document.text('windows1')
        document.body.appendChild(self.txt1)
        self.btn1 = document.button('test1', onclick=self.on_btn1)
        document.body.appendChild(self.btn1)

    def on_btn1(self, ev):
        self.txt1.value = 'changed1'


class MyWindow2(Window):
    def __init__(self):
        super(MyWindow2, self).__init__()
        document = self.document
        self.txt1 = document.text('windows2')
        document.body.appendChild(self.txt1)
        self.btn1 = document.button('test1', onclick=self.on_btn1)
        document.body.appendChild(self.btn1)

    def on_btn1(self, ev):
        self.txt1.value = 'changed2'


start_app([
    MyWindow1(),  # instance for single-instance. localhost:8888/index.html
    MyWindow2
])  # class for multiple-instance. localhost:8888/index1.html
コード例 #4
0
ファイル: todonomvc.py プロジェクト: takd4com/dominter
def main():
    port = get_arg_port()
    start_app(MyWindow, port=port)
コード例 #5
0
def main():
    win1 = MyWindow()
    start_app({'window': win1, 'path': '/'},
               template_path=os.path.dirname(__file__),
               static_path=os.path.join(os.path.dirname(__file__), 'static'),
              )
コード例 #6
0
ファイル: simple_multiwin.py プロジェクト: takd4com/dominter
class MyWindow1(Window):
    def __init__(self):
        super(MyWindow1, self).__init__()
        document = self.document
        self.txt1 = document.text('windows1')
        document.body.appendChild(self.txt1)
        self.btn1 = document.button('test1', onclick=self.on_btn1)
        document.body.appendChild(self.btn1)

    def on_btn1(self, ev):
        self.txt1.value = 'changed1'


class MyWindow2(Window):
    def __init__(self):
        super(MyWindow2, self).__init__()
        document = self.document
        self.txt1 = document.text('windows2')
        document.body.appendChild(self.txt1)
        self.btn1 = document.button('test1', onclick=self.on_btn1)
        document.body.appendChild(self.btn1)

    def on_btn1(self, ev):
        self.txt1.value = 'changed2'


start_app([
    MyWindow1(),  # localhost:8888/index.html
    MyWindow2()
])  # localhost:8888/index1.html
コード例 #7
0
    def on_btn_class_set(self, ev):
        self.btn_target.className = 'cls2 cls3'
        self.disp_class_style()

    def on_btn_toggle(self, ev):
        self.btn_target.classList.toggle('cls2')
        self.disp_class_style()

    def on_btn_remove(self, ev):
        if 'cls3' in self.btn_target.classList:
            self.btn_target.classList.remove('cls3')
            self.disp_class_style()

    def on_btn_append(self, ev):
        if 'cls3' not in self.btn_target.classList:
            self.btn_target.classList.append('cls3')
            self.disp_class_style()

    def on_btn_style_set(self, ev):
        self.btn_target.style = "color:blue; background-color:orange;"
        self.disp_class_style()

    def on_btn_style_del(self, ev):
        self.btn_target.style.removeProperty('color')
        #if 'color' in self.btn_target.style:
        #    del self.btn_target.style['color']
        self.disp_class_style()


start_app(MyWindow())  # for http://localhost:8888/index.html