class W2UIPage:

    pg = None
    g_col1 = None
    g_col2 = None
    g_column_coll = None
    g_rec1 = None
    g_rec2 = None
    g_record_coll = None
    grid = None
    sgl = None
    bt_tgl = None
    bt_add = None
    bt_sel_all = None
    bt_unsel_all = None
    bt_sel = None
    bt_unsel = None

    def show_layout(self):
        self.pg = Page('myPage', 'My Page')
        self.sgl = SimpleGridLayout('sgl', 1, 6)
        self.bt_tgl = Button('bt_tgl', 'Toggle', socketio, click_callback=self.grid_col_callback)
        self.bt_add = Button('bt_add', 'Add Record', socketio, click_callback=self.grid_add_rec_callback)
        self.bt_sel_all = Button('bt_sel_all', 'Select All', socketio, click_callback=self.grid_sel_all_callback)
        self.bt_unsel_all = Button('bt_unsel_all', 'Unselect All', socketio,
                                   click_callback=self.grid_unsel_all_callback)
        self.bt_sel = Button('bt_sel', 'Select', socketio, click_callback=self.grid_sel_callback)
        self.bt_unsel = Button('bt_unsel', 'UnSelect', socketio, click_callback=self.grid_unsel_callback)
        self.sgl.add(self.bt_tgl)
        self.sgl.add(self.bt_add)
        self.sgl.add(self.bt_sel_all)
        self.sgl.add(self.bt_unsel_all)
        self.sgl.add(self.bt_sel)
        self.sgl.add(self.bt_unsel)
        self.pg.add(self.sgl)
        self.g_col1 = GridColumn('fname', 'First Name', 50)
        self.g_col2 = GridColumn('lname', 'Last Name', 50)
        self.g_column_coll = GridColumnCollection()
        self.g_column_coll.add(self.g_col1)
        self.g_column_coll.add(self.g_col2)
        self.g_rec1 = GridRecord()
        self.g_rec1.add_cell("fname", "Ajeet")
        self.g_rec1.add_cell("lname", "Singh")
        self.g_rec2 = GridRecord()
        self.g_rec2.add_cell("fname", "Armin")
        self.g_rec2.add_cell("lname", "Kaur")
        self.g_record_coll = GridRecordCollection()
        self.g_record_coll.add(self.g_rec1)
        self.g_record_coll.add(self.g_rec2)
        self.grid = Grid('grid', 'My Table', self.g_column_coll, socketio, row_collection=self.g_record_coll,
                         toolbar=True, footer=True, line_numbers=True, select_column=True,
                         multi_select=True, toolbarAdd=True, toolbarDelete=True,
                         toolbarSave=True, toolbarEdit=True)
        self.pg.add(self.grid)
        content = self.pg.render()
        return content

    def grid_col_callback(self, source, props):
        self.grid.toggle_column('fname')

    def grid_add_rec_callback(self, source, props):
        rec = GridRecord()
        rec.add_cell("fname", "Jippy")
        rec.add_cell("lname", "Singh")
        self.grid.add_record(rec)

    def grid_sel_all_callback(self, source, props):
        self.grid.select_all_records()

    def grid_unsel_all_callback(self, source, props):
        self.grid.unselect_all_records()

    def grid_sel_callback(self, source, props):
        self.grid.select_records("2")

    def grid_unsel_callback(self, source, props):
        self.grid.unselect_records("2")
class MobileExample:

    _pg = None
    _mpg = None

    def show_layout(self):
        self._pg = Page('pg', 'Mobile Example')
        self._mpg1 = MobilePage('mpg1', 'Page1 Example', socketio, footer_title="Footer", click_callback=self.pg_clicked)  # noqa
        self._mpg2 = MobilePage('mpg2', 'Page2 Example', socketio, footer_title="Dialog Footer", is_dialog=True)  # noqa
        self._btn = Button('btn', socketio, btn_styles=[ButtonStyle.ROUND_CORNERS, ButtonStyle.ICON_LEFT],
                           title="My Button", icon='ui-icon-delete', click_callback=self.btn_clicked, href='#mpg2')  # noqa
        self._btn1 = FormButton('btn1', socketio, title="Form Button", icon='ui-icon-delete',
                                btn_styles=[ButtonStyle.ROUND_CORNERS, ButtonStyle.ICON_LEFT],
                                click_callback=self.btn_clicked)
        self._chkbox = CheckBox('chkbox', socketio, is_group=True, orientation="vertical",
                                icon_position="right", legend="My Checkboxes",
                                click_callback=self.chk_clicked)
        self._chkbox.add_item('item1', 'Item1')
        self._chkbox.add_item('item2', 'Item2')
        self._chkbox.add_item('item3', 'Item3')
        self._chkbox.add_item('item4', 'Item4')
        self._rd = Radio('rd', socketio, is_group=True, orientation="vertical",
                         legend="My RadioButtons",
                         click_callback=self.chk_clicked)
        self._rd.add_item('rd_item1', 'RadioItem1')
        self._rd.add_item('rd_item2', 'RadioItem2')
        self._rd.add_item('rd_item3', 'RadioItem3')
        self._rd.add_item('rd_item4', 'RadioItem4')
        self._ctrl_gp = ControlGroup('ctrl_gp', socketio)
        self._ctrl_gp.add(self._rd)
        self._clsp1 = Collapsible('clsp1', 'My Collapsible1', socketio, collapse_callback=self.clsp_clicked)
        self._clsp2 = Collapsible('clsp2', 'My Collapsible2', socketio, collapse_callback=self.clsp_clicked)
        self._clsp3 = Collapsible('clsp3', 'My Collapsible3', socketio, collapse_callback=self.clsp_clicked)
        self._clsp = CollapsibleSet('clsp', '', socketio, use_filter=True)
        self._fs = FlipSwitch('fs', socketio, on_text="Light", off_text="Dark",
                              change_callback=self.fs_changed)
        self._clsp.add(self._clsp1)
        self._clsp.add(self._clsp2)
        self._clsp.add(self._clsp3)
        self._grid = GridLayout('grid', 4)
        self._grid.add(Button('gb1', socketio, title="Btn1"))
        self._grid.add(Button('gb2', socketio, title="Btn2"))
        self._grid.add(Button('gb3', socketio, title="Btn3"))
        self._grid.add(Button('gb4', socketio, title="Btn4"))
        self._pnl_html = HTML('pnl_html', '<h2>My Panel</h2><br>This is a standard left panel with close button')
        self._pnl = Panel('pnl', socketio, display='overlay', show_close_btn=True,
                          before_close_callback=self.before_panel_closed, child_widgets=[self._pnl_html])
        self._sl = SectionLayout('sl', 'My Section', header_corners=True, body_corners=True, body_theme='a')
        self._sl.add(Button('slb', socketio, title='Button', href='#pnl'))
        self._lv = ListView('lv', socketio, is_filterable=True)
        self._li1 = ListItem('li1', 'ListItem1', socketio, click_callback=self.li_clicked)
        self._li2 = ListItem('li2', 'ListItem2', socketio, click_callback=self.li_clicked)
        self._li3 = ListItem('li3', 'ListItem3', socketio, click_callback=self.li_clicked)
        self._li4 = ListItem('li4', 'ListItem4', socketio, click_callback=self.li_clicked)
        self._lv.add(self._li1)
        self._lv.add(self._li2)
        self._lv.add(self._li3)
        self._lv.add(self._li4)
        self._nb = NavBar('nb', socketio, click_callback=self.nb_clicked)
        self._nb.add_item('nb1', 'NB1', True, href='#pop', data_rel='popup')
        self._nb.add_item('nb2', 'NB2', False)
        self._nb.add_item('nb3', 'NB3', False)
        self._nb.add_item('nb4', 'NB4', False)
        self._nb.add_item('nb5', 'NB5', False)
        self._pop_html = HTML('pop_html', '<center><h4>My Popup</h4></center>This is an popup with a HTML child widget')
        self._pop = Popup('pop', socketio, child_widgets=[self._pop_html])
        self._rng = RangeSlider('rng', socketio, 'Title1', 'Title2', value_changed_callback=self.val_changed)
        self._sel = SelectMenu('sel', socketio, click_callback=self.select_clicked)
        self._sel.add_option('a', 'ABC', opt_group='Group1', disabled=True)
        self._sel.add_option('d', 'DEF', opt_group='Group1')
        self._sel.add_option('g', 'GHI', opt_group='Group2')
        self._sel.add_option('j', 'JKL', opt_group='Group2')
        self._sel.add_option('m', 'MNO')
        self._sel.add_option('p', 'PQR')
        self._slide = Slider('slide', socketio, 'My Title', value_changed_callback=self.val_changed,
                             highlight=True)
        self._tbl = Table('tbl', socketio, mode=TableModes.COLUMN_TOGGLE, display_row_number=True,
                          row_rendering_option=RowRenderingOptions.TEXT, click_callback=self.tbl_clicked)
        self._tbl.add_column('income', 1, 'Q12012')
        self._tbl.add_column('profit', 1, 'Q12012')
        self._tbl.add_column('change', 1, 'Q12012')
        self._tbl.add_column('income', 1, 'Q22012')
        self._tbl.add_column('profit', 1, 'Q22012')
        self._tbl.add_column('change', 1, 'Q22012')
        self._tbl.add_column('Total', 1, 'Total')
        self._tbl.data = [["<input type='text' />", 20, 30, 120, 40, 40, 10],
                          [199, 70, 50, 190, 60, 20, 30],
                          [188, 23, 38, 126, 78, 56, 22]
                          ]
        self._slv = SimpleListView('slv', socketio, "Simple List View")
        self._slv.add_item('itm1', 'Item 1')
        self._slv.add_item('itm2', 'Item 2')
        self._slv.add_item('itm3', 'Item 3')
        self._slv.add_item('itm4', 'Item 4')
        self._slv.add_item('itm5', 'Item 5')
        self._slv.add_item('itm6', 'Item 6')
        self._mpg1.add(self._btn)
        self._mpg1.add(self._btn1)
        self._mpg1.add(self._chkbox)
        self._mpg1.add(self._ctrl_gp)
        self._mpg1.add(self._clsp)
        self._mpg1.add(self._fs)
        self._mpg1.add(self._grid)
        self._mpg1.add(self._sl)
        self._mpg1.add(self._lv)
        self._mpg1.add(self._nb)
        self._mpg1.add_panel(self._pnl)
        self._mpg1.add(self._pop)
        self._mpg1.add(self._rng)
        self._mpg1.add(self._sel)
        self._mpg1.add(self._slide)
        self._mpg1.add(self._tbl)
        self._mpg1.add(self._slv)
        self._pg.add(self._mpg1)
        self._pg.add(self._mpg2)
        return self._pg.render()

    def tbl_clicked(self, source, props):
        print('Table clicked: ' + source + ', Props: ' + str(props))

    def select_clicked(self, source, props):
        print('Select widget clicked: ' + source + ", Props: " + str(props))

    def val_changed(self, source, props):
        print('Value changed for: ' + source + ", Props: " + str(props))

    def before_panel_closed(self, source, props):
        print("Before Panel Closed: " + source + ", Props: " + str(props))

    def pg_clicked(self, source, props):
        print("Mobile Page Clicked: " + source + ", Props:" + str(props))

    def nb_clicked(self, source, props):
        print("NavBar clicked: " + source + ", Props: " + str(props))

    def lv_clicked(self, source, props):
        print("List view clicked: " + source + ", Props: " + str(props))

    def li_clicked(self, source, props):
        print("List Item clicked: " + source + ", Props: " + str(props))

    def fs_changed(self, source, props):
        print("FlipSwitch Changed: " + source + ", Props:" + str(props))

    def clsp_clicked(self, source, props):
        print("Collapsible closed! Source: " + source + ", Props: " + str(props))
        # self._fs._is_checked = not self._fs._is_checked

    def chk_clicked(self, source, status, items):
        print("Check Clicked: " + source + ", " + str(status))

    def btn_clicked(self, source, props):
        print("Button clicked: " + source + ", Props: " + str(props))
        self._clsp1.is_collapsed = not self._clsp1.is_collapsed
        if self._btn.icon == 'ui-icon-delete':
            self._btn.icon = 'ui-icon-alert'
            self._btn.remove_style(ButtonStyle.ICON_LEFT)
            self._btn.add_style(ButtonStyle.ICON_RIGHT)
        else:
            self._btn.remove_style(ButtonStyle.ICON_RIGHT)
            self._btn.add_style(ButtonStyle.ICON_LEFT)
            self._btn.icon = 'ui-icon-delete'
Exemple #3
0
class W2UIPage:

    pg = None
    toolbar = None
    tool_btn = None
    tool_chk = None
    tool_html = None
    tool_menu = None
    tool_menu_chk = None
    tool_menu_rd = None
    tool_rd = None
    tool_sep = None
    tool_dd = None
    tool_spacer = None

    def show_layout(self):
        self.pg = Page('myPage', 'My Page')
        self.toolbar = Toolbar('toolbar',
                               socketio,
                               onclick_callback=self._toolbar_clicked)
        self.tool_btn = ToolbarButton('toolbtn', 'Button')
        self.tool_chk = ToolbarCheck('tool_chk', 'Check')
        self.tool_dd = ToolbarDropDown('tool_dd', 'My DropDown content',
                                       'DropDown')
        self.tool_html = ToolbarHTML('tool_html', '<input type=text />',
                                     'Html')
        self.tool_menu = ToolbarMenu('tool_menu', 'Actions')
        self.tool_menu.add_item('Add')
        self.tool_menu.add_item('Insert')
        self.tool_menu.add_item('Remove')
        self.tool_menu.add_item('Show')
        self.tool_menu.add_item('Hide')
        self.tool_menu.add_item('Enable')
        self.tool_menu.add_item('Disable')
        self.tool_menu_chk = ToolbarMenuCheck('tool_menu_chk', 'MenuCheck')
        self.tool_menu_chk.add_item('item1', 'Item1')
        self.tool_menu_chk.add_item('item2', 'Item2')
        self.tool_menu_rd = ToolbarMenuRadio('tool_menu_rd', 'MenuRadio')
        self.tool_menu_rd.add_item('item1', 'Item1')
        self.tool_menu_rd.add_item('item2', 'Item2')
        self.tool_rd = ToolbarRadio('tool_rd', 'Radio')
        self.tool_sep = ToolbarSeparator('tool_sep', 'Sep')
        self.tool_spacer = ToolbarSpacer('tool_spacer', 'Spac')
        self.toolbar.add(self.tool_btn)
        self.toolbar.add(self.tool_chk)
        self.toolbar.add(self.tool_dd)
        self.toolbar.add(self.tool_html)
        self.toolbar.add(self.tool_menu)
        self.toolbar.add(self.tool_menu_chk)
        self.toolbar.add(self.tool_menu_rd)
        self.toolbar.add(self.tool_rd)
        self.toolbar.add(self.tool_sep)
        self.toolbar.add(self.tool_spacer)
        self.pg.add(self.toolbar)
        content = self.pg.render()
        return content

    def _toolbar_clicked(self, name, props):
        menu = self.toolbar.clicked_item
        if str(menu).find(':') > 0:
            item = str(menu).split(':')[1]
            if item.upper() == 'ADD':
                new_btn = ToolbarButton('new_btn', 'New Button')
                self.toolbar.add_item(new_btn)
            if item.upper() == 'INSERT':
                new_ins_btn = ToolbarButton('new_ins_btn', 'New Insert Button')
                self.toolbar.insert_item(new_ins_btn, 'tool_btn')
            if item.upper() == 'REMOVE':
                self.toolbar.remove_item('new_ins_btn')
            if item.upper() == 'HIDE':
                self.toolbar.hide_item('toolbtn')
            if item.upper() == 'SHOW':
                self.toolbar.show_item('toolbtn')
            if item.upper() == 'ENABLE':
                self.toolbar.enable_item('toolbtn')
            if item.upper() == 'DISABLE':
                self.toolbar.disable_item('toolbtn')
Exemple #4
0
 def show_layout(self):
     pg = Page('myPage', 'My Page')
     # self.ctx_item1 = ContextMenuItem('Item1', "function(item, ref, ele, pos){alert(item);}")
     # self.ctx_item2 = ContextMenuItem('Item2', "function(item, ref, ele, pos){}")
     # self.ctx_item21 = ContextMenuItem('Item2-1', "function(item, ref, ele, pos){}")
     # self.ctx_item22 = ContextMenuItem('Item2-2', "function(item, ref, ele, pos){}")
     # self.ctx_item2.add('Item2-1', self.ctx_item21)
     # self.ctx_item2.add('Item2-2', self.ctx_item22)
     # self.ctx_item3 = ContextMenuItem('Item3', "function(item, ref, ele, pos){}")
     self.tree = JSTree('tree',
                        plugin_contextmenu=True,
                        plugin_dnd=True,
                        plugin_search=True,
                        plugin_unique=True,
                        plugin_checkbox=True,
                        core_chk_callbk_create_node=True,
                        core_chk_callbk_rename_node=True,
                        core_chk_callbk_edit=True,
                        core_chk_callbk_delete_node=True,
                        core_chk_callbk_copy_node=True,
                        core_chk_callbk_move_node=True,
                        app=app)
     self.tree.on_open_node_event(self.tree_node_opened)
     self.tree.on_before_open_event(self.tree_node_opened)
     # self.tree.add_ctx_menu_item('Item1', self.ctx_item1)
     # self.tree.add_ctx_menu_item('Item2', self.ctx_item2)
     # self.tree.add_ctx_menu_item('Item3', self.ctx_item3)
     self.tree_node_type = JSTreeNodeType('tree_node_type', max_depth=10)
     self.tree.add_node_type('tree_node_type', self.tree_node_type)
     self.node1 = JSTreeNode('node1', 'Node 1', is_opened=True)
     self.node2 = JSTreeNode('node2', 'Node 2')
     self.node3 = JSTreeNode('node3', 'Node 3')
     self.tree.add(self.node1)
     self.node1.add(self.node2)
     self.node1.add(self.node3)
     # self.pop = Popup('pop', 'Test Title', app=app,
     #                  buttons='<input type="button" onclick="w2popup.close();" value="Close" />',
     #                  show_max=True, show_close=True, modal=True,
     #                  body='<span>This message for you to show in popup widow!</span>')
     # self.frm_text = FormFieldText('frm_text', caption='Text Field', required=True)
     # self.frm_alpha = FormFieldAlpha('frm_alpha', caption='Alphanum Field')
     # self.frm_dt = FormFieldDate('frm_dt', caption='Date Field', required=True)
     # self.frm_lst = FormFieldList('frm_lst', caption='List Field', options=True, items=['abc', 'def', 'ghi'])
     # self.frm_enm = FormFieldEnum('frm_enm', caption='Enum Field', options=True, items=['abc', 'def', 'ghi'])
     # self.frm_sel = FormFieldSelect('frm_sel', caption='Select Field', options=True, items=['abc', 'def', 'ghi'])
     # self.frm = Form('frm', app=app, submit_callback=self.w2ui_form_submitted)
     # self.frm.add(self.frm_text)
     # self.frm.add(self.frm_alpha)
     # self.frm.add(self.frm_dt)
     # self.frm.add(self.frm_lst)
     # self.frm.add(self.frm_enm)
     # self.frm.add(self.frm_sel)
     # self.sidebar = Sidebar('sidebar', flatButton=True, app=app, onclick_callback=self.sidebar_clicked)
     # self.sidebar.add_style("height", "100%")
     # self.sidebar.add_style("width", "100%")
     # self.s_node1 = SidebarNode('s_node1', text='Level1', expanded=True, group=True)
     # self.s_node11 = SidebarNode('s_node11', text='Level1-1', is_leaf=True)
     # self.s_node12 = SidebarNode('s_node12', text='Level1-2', is_leaf=True)
     # self.s_node13 = SidebarNode('s_node13', text='Level1-3', is_leaf=True)
     # self.s_node2 = SidebarNode('s_node2', text='Level2', expanded=True, group=True)
     # self.s_node21 = SidebarNode('s_node21', text='Level2-1', expanded=True)
     # self.s_node211 = SidebarNode('s_node211', text='Level2-1-1', is_leaf=True)
     # self.s_node212 = SidebarNode('s_node212', text='Level2-1-2', is_leaf=True)
     # self.s_node213 = SidebarNode('s_node213', text='Level2-1-3', is_leaf=True)
     # self.s_node22 = SidebarNode('s_node22', text='Level2-2', is_leaf=True)
     # self.s_node23 = SidebarNode('s_node23', text='Level2-3', is_leaf=True)
     # self.s_node1.add(self.s_node11)
     # self.s_node1.add(self.s_node12)
     # self.s_node1.add(self.s_node13)
     # self.s_node2.add(self.s_node21)
     # self.s_node21.add(self.s_node211)
     # self.s_node21.add(self.s_node212)
     # self.s_node21.add(self.s_node213)
     # self.s_node2.add(self.s_node22)
     # self.s_node2.add(self.s_node23)
     # self.sidebar.add(self.s_node1)
     # self.sidebar.add(self.s_node2)
     # self.toolbar = Toolbar('MyBar', onclick_callback=self.toolbar_clicked, app=app)
     # self.tool_btn1 = ToolbarButton('tool_btn1', 'Button1', icon='fa-star')
     # self.tool_btn2 = ToolbarButton('tool_btn2', 'Button2', icon='fa-heart')
     # self.tool_sep = ToolbarSeparator('tool_sep', 'Sep')
     # self.tool_rd1 = ToolbarRadio('tool_rd1', 'Radio1', group='A')
     # self.tool_rd2 = ToolbarRadio('tool_rd2', 'Radio2', group='A')
     # self.tool_chk1 = ToolbarCheck('tool_chk1', 'Checkbox')
     # self.tool_menu = ToolbarMenu('tool_menu', 'Menu', count=2)
     # self.tool_menu.add_item('Item1', '', count=1)
     # self.tool_menu.add_item('Item2', '', count=1)
     # self.tool_menu_rd = ToolbarMenuRadio('tool_menu_rd', 'MenuRadio')
     # self.tool_menu_rd.add_item('rd1', 'Radio1')
     # self.tool_menu_rd.add_item('rd2', 'Radio2')
     # self.tool_menu_rd.add_item('rd3', 'Radio3')
     # self.tool_menu_chk = ToolbarMenuCheck('tool_menu_chk', 'MenuCheck')
     # self.tool_menu_chk.add_item('ck1', 'Check1')
     # self.tool_menu_chk.add_item('ck2', 'Check2')
     # self.tool_menu_chk.add_item('ck3', 'Check3')
     # self.tool_dd = ToolbarDropDown('tool_dd', "<p>My name is Singh...Ajeet Singh!!", "Drop")
     # self.tool_html = ToolbarHTML('tool_html', '<span>Name:</span><input type="text" id="smid" />', title='abc')
     # self.toolbar.add(self.tool_btn1)
     # self.toolbar.add(self.tool_sep)
     # self.toolbar.add(self.tool_btn2)
     # self.toolbar.add(self.tool_rd1)
     # self.toolbar.add(self.tool_rd2)
     # self.toolbar.add(self.tool_chk1)
     # self.toolbar.add(self.tool_menu)
     # self.toolbar.add(self.tool_menu_rd)
     # self.toolbar.add(self.tool_menu_chk)
     # self.toolbar.add(self.tool_dd)
     # self.toolbar.add(self.tool_html)
     # pg.add(self.toolbar)
     # self.g_col1 = GridColumn('fname', 'First Name', 50)
     # self.g_col2 = GridColumn('lname', 'Last Name', 50)
     # self.g_column_coll = GridColumnCollection()
     # self.g_column_coll.add(self.g_col1)
     # self.g_column_coll.add(self.g_col2)
     # self.g_rec1 = GridRecord()
     # self.g_rec1.add_cell("fname", "Ajeet")
     # self.g_rec1.add_cell("lname", "Singh")
     # self.g_rec2 = GridRecord()
     # self.g_rec2.add_cell("fname", "Armin")
     # self.g_rec2.add_cell("lname", "Kaur")
     # self.g_record_coll = GridRecordCollection()
     # self.g_record_coll.add(self.g_rec1)
     # self.g_record_coll.add(self.g_rec2)
     # self.grid = Grid('grid', 'My Table', self.g_column_coll, row_collection=self.g_record_coll,
     #                  toolbar=True, footer=True, line_numbers=True, select_column=True,
     #                  multi_select=True, app=app, toolbarAdd=True, toolbarDelete=True,
     #                  toolbarSave=True, toolbarEdit=True)
     # self.frm = Form('frm', app=app, submit_callback=self.form_submitted)
     sg = SimpleGridLayout("Grid", 1, 2, col_ratio=["20%", "80%"])
     sg.add_style("height", "500px")
     sg.add_style("width", "100%")
     sg.add(self.tree)
     sg1 = SimpleGridLayout('Grid1', 6, 2)
     sg1.add_style("height", "500px")
     sg1.add_style("width", "100%")
     sg.add(sg1)
     self.btn_js_open_all = Button('btn_js_open_all',
                                   'Open All',
                                   onclick_callback=self._modify_tree_open,
                                   app=app)
     self.btn_js_close_all = Button(
         'btn_js_close_all',
         'Close All',
         onclick_callback=self._modify_tree_close,
         app=app)
     self.btn_js_hide_all = Button('btn_js_hide_all',
                                   'Hide All',
                                   onclick_callback=self._modify_tree_hide,
                                   app=app)
     self.btn_js_show_all = Button('btn_js_show_all',
                                   'Show All',
                                   onclick_callback=self._modify_tree_show,
                                   app=app)
     self.btn_js_sel_all = Button('btn_js_sel_all',
                                  'Select All',
                                  onclick_callback=self._modify_tree_sel,
                                  app=app)
     self.btn_js_desel_all = Button(
         'btn_js_desel_all',
         'Deselect All',
         onclick_callback=self._modify_tree_unsel,
         app=app)
     self.btn_js_show_stripes = Button(
         'btn_js_show_stripes',
         'Show Stripes',
         onclick_callback=self._modify_tree_show_stps,
         app=app)
     self.btn_js_hide_stripes = Button(
         'btn_js_hide_stripes',
         'Hide Stripes',
         onclick_callback=self._modify_tree_hide_stps,
         app=app)
     self.btn_js_hide_chkbox = Button(
         'btn_js_hide_chkbox',
         'Hide Checkbox',
         onclick_callback=self._modify_tree_hide_chk,
         app=app)
     self.btn_js_show_chkbox = Button(
         'btn_js_show_chkbox',
         'Show Checkbox',
         onclick_callback=self._modify_tree_show_chk,
         app=app)
     self.btn_js_chk_all = Button(
         'btn_js_chk_all',
         'Check All',
         onclick_callback=self._modify_tree_chk_all,
         app=app)
     self.btn_js_unchk_all = Button(
         'btn_js_unchk_all',
         'Uncheck All',
         onclick_callback=self._modify_tree_unchk_all,
         app=app)
     sg1.add(self.btn_js_open_all)
     sg1.add(self.btn_js_close_all)
     sg1.add(self.btn_js_hide_all)
     sg1.add(self.btn_js_show_all)
     sg1.add(self.btn_js_sel_all)
     sg1.add(self.btn_js_desel_all)
     sg1.add(self.btn_js_show_stripes)
     sg1.add(self.btn_js_hide_stripes)
     sg1.add(self.btn_js_hide_chkbox)
     sg1.add(self.btn_js_show_chkbox)
     sg1.add(self.btn_js_chk_all)
     sg1.add(self.btn_js_unchk_all)
     # sg.add(self.sidebar)
     # sg.add(self.grid)
     # self.btn = Button('btn', 'Push', app=app, onclick_callback=self.change_btn_title)
     # self.btn1 = Button('btn1', 'Populate', app=app, onclick_callback=self.populate_text)
     # self.txt = TextBox('txt', app=app, onchange_callback=self.text_changed)
     # self.chk = CheckBox('chk', "Checkbox text", app=app, onclick_callback=self.checkbox_clicked)
     # self.clr = Color('clr', app=app, onchange_callback=self.color_changed)
     # self.dt = Date('dt', min="2019-01-01", max="2020-12-31", app=app, onchange_callback=self.date_changed)
     # self.dtl = DateTimeLocal('dtl', app=app, onchange_callback=self.datetime_changed)
     # self.eml = Email('eml', app=app, onchange_callback=self.email_changed)
     # self.fl = File('fl', app=app, onchange_callback=self.file_changed)
     # self.img = Image('img', url_for('static', filename='images.jpeg'), app=app,
     # onclick_callback=self.image_clicked)
     # self.mth = Month('mth', app=app, onchange_callback=self.month_changed)
     # self.num = Number('num', app=app, onchange_callback=self.numb_changed)
     # self.passwd = Password('passwd', app=app, onchange_callback=self.pass_changed)
     # self.rd = Radio('rd', "Radio Text", app=app, onclick_callback=self.radio_clicked)
     # self.rng = Range('rng', app=app, onchange_callback=self.range_changed)
     # sg.add(self.btn)
     # sg.add(self.btn1)
     # sg.add(self.txt)
     # sg.add(self.chk)
     # sg.add(self.clr)
     # sg.add(self.dt)
     # sg.add(self.dtl)
     # sg.add(self.eml)
     # sg.add(self.fl)
     # sg.add(self.img)
     # sg.add(self.mth)
     # sg.add(self.num)
     # sg.add(self.passwd)
     # sg.add(self.rd)
     # sg.add(self.rng)
     pg.add(sg)
     # self.lbl1 = Label('lbl1', 'TextBox Label:', self.txt)
     # self.dd = DropDown('dd', app=app, onchange_callback=self.dd_changed)
     # self.dd.add_option('a', 'A', False)
     # self.dd.add_option('b', 'B', False)
     # self.dd.add_option('c', 'C', False)
     # self.lbl2 = Label('lbl2', 'DropDown Label:', self.dd, app=app, onclick_callback=self.lbl_clicked)
     # self.frm.add(self.lbl1)
     # self.frm.add(self.txt)
     # self.frm.add(self.lbl2)
     # self.frm.add(self.dd)
     # pg.add(self.frm)
     # self.acrd = Accordion('acrd', collapsible=True)
     # self.sec1 = Section('sec1', 'Section1', app=app, onclick_callback=self.section_clicked)
     # self.sec2 = Section('sec2', 'Section2', app=app, onclick_callback=self.section_clicked)
     # self.acrd.add(self.sec1)
     # self.acrd.add(self.sec2)
     # self.rbg = RadioButtonGroup('rbg', "RadioBtn Group", self.rbg_items,
     #                             app=app, onclick_callback=self.rbg_clicked)
     # self.cbg = CheckBoxGroup('cbg', "CheckBox Group", self.cbg_items,
     #                          app=app, onclick_callback=self.cbg_clicked)
     # self.dlg = DialogBox('dlg', 'My Dialog', DialogTypes.MODAL_CONFIRM, app=app)
     # self.dlg_btn = Button('dlg_btn', "Open Dialog", app=app, onclick_callback=self.open_dialog)
     # pg.add(self.acrd)
     # pg.add(self.rbg)
     # pg.add(self.cbg)
     # pg.add(self.dlg)
     # pg.add(self.dlg_btn)
     # self.menu = Menu('menu', menu_type=MenuTypes.HORIZONTAL)
     # self.m_menu_itm1 = MenuItem('m_menu_itm1', 'Item1', app=app,
     #                             menu_clicked_callback=self.menu_clicked, icon='ui-icon-disk')
     # self.m_menu_itm2 = MenuItem('m_menu_itm2', 'Item2', app=app,
     #                             menu_clicked_callback=self.menu_clicked, icon='ui-icon-zoomin')
     # self.m_submenu_itm3 = SubMenu('m_submenu_itm3', 'Item3')
     # self.m_menu_itm4 = MenuItem('m_menu_itm4', 'Item4', app=app, menu_clicked_callback=self.menu_clicked)
     # self.sm_menu_itm1 = MenuItem('sm_menu_itm1', 'SubItem1', app=app,
     #                              menu_clicked_callback=self.menu_clicked, icon='ui-icon-play')
     # self.sm_menu_itm2 = MenuItem('sm_menu_itm2', 'SubItem2', app=app,
     #                              menu_clicked_callback=self.menu_clicked, icon='ui-icon-stop')
     # self.m_submenu_itm3.add(self.sm_menu_itm1)
     # self.m_submenu_itm3.add(self.sm_menu_itm2)
     # self.menu.add(self.m_menu_itm1)
     # self.menu.add(self.m_menu_itm2)
     # self.menu.add(self.m_submenu_itm3)
     # self.menu.add(self.m_menu_itm4)
     # pg.add(self.menu)
     # self.sld = Slider('sld', slider_changed_callback=self.slider_changed, app=app)
     # pg.add(self.sld)
     # self.spn = Spinner('spn', app=app, onchange_callback=self.spinner_changed, number_format="C")
     # pg.add(self.spn)
     # self.tab = Tab('tab', app=app, tab_activated_callback=self.tab_clicked)
     # self.tab_sec1 = TabSection('tab_sec1', 'Tab1')
     # self.tab_sec2 = TabSection('tab_sec2', 'Tab2')
     # self.tab.add(self.tab_sec1)
     # self.tab.add(self.tab_sec2)
     # pg.add(self.tab)
     # pg.add(self.frm)
     # pg.add(self.pop)
     content = pg.render()
     return content
class W2UIPage:

    pg = None
    pop = None
    bt_open = None
    sg = None

    def show_layout(self):
        self.pg = Page('pg', 'Popup Example')
        self.pop = Popup(
            'pop',
            socketio,
            'Test Title',
            buttons=
            '<input type="button" onclick="w2popup.close();" value="Close" />',
            show_max=True,
            show_close=True,
            modal=True,
            body='<span>This message for you to show in popup widow!</span>',
            on_close_callback=self.pop_closed,
            on_keydown_callback=self.pop_key_pressed,
            on_max_callback=self.pop_max,
            on_min_callback=self.pop_min,
            on_open_callback=self.pop_open,
            on_toggle_callback=self.pop_toggled)
        self.bt_open = Button('bt_open',
                              'Open',
                              socketio,
                              click_callback=self.button_open)
        self.sg = SimpleGridLayout('sg', 1, 1)
        self.sg.add(self.bt_open)
        self.pg.add(self.pop)
        self.pg.add(self.sg)
        return self.pg.render()

    def pop_closed(self):
        print("Popup Closed!")

    def pop_key_pressed(self):
        print("Popup Key Pressed!")

    def pop_max(self):
        print("Popup Maximized!")

    def pop_min(self):
        print("Popup Minimized!")

    def pop_open(self):
        print("Popup Opened!")

    def pop_toggled(self):
        print("Popup Toggled!")

    def button_open(self, name, props):
        print('Opening...')
        self.pop.open()
        time.sleep(10)
        print('Closing...')
        self.pop.close()
        time.sleep(10)
        print('Opening again...')
        self.pop.open()
        time.sleep(10)
        print('Loading...')
        self.pop.load('https://google.com')
        time.sleep(10)
        print('Closing again...')
        self.pop.close()
        time.sleep(10)
        print('Opening again!')
        self.pop.open()
        time.sleep(10)
        print('Locking up')
        self.pop.lock("Popup Locked", True)
        time.sleep(10)
        print('Unlocking it')
        self.pop.unlock()
        time.sleep(10)
        print('Locking screen...')
        self.pop.lock_screen()
        time.sleep(10)
        print('Unlocking screen')
        self.pop.unlock_screen()
        time.sleep(10)
        print('Closing again...')
        self.pop.close()
        time.sleep(10)
        print('Opening again!')
        self.pop.open()
        time.sleep(10)
        print('Maximizing')
        self.pop.max()
        time.sleep(10)
        print('Minimizing')
        self.pop.min()
        time.sleep(10)
        print('Resizing')
        self.pop.resize(800, 800)
        print('Done!')
class W2UIPage:

    pg = None
    btn_btn = None
    btn_enb_dsbl = None
    btn_title = None
    txt = None
    btn_txt_rd = None
    btn_txt_enb_dsbl = None
    chk = None
    btn_chk_dsbl = None
    btn_chk = None
    clr = None
    btn_clr_dsbl = None
    dt = None
    btn_dt_dsbl = None
    btn_dt_rd = None
    btn_dt_min = None
    btn_dt_max = None
    dtl = None
    btn_dtl_dsbl = None
    btn_dtl_rd = None
    btn_dtl_min = None
    btn_dtl_max = None
    _file = None
    btn_fl_dsbl = None
    btn_fl_multi = None
    img = None
    mth = None
    num = None
    password = None
    rd = None
    rset = None
    rng = None
    srch = None
    sbmt = None
    tlph = None
    time = None
    url = None
    week = None
    dd = None

    def show_layout(self):
        self.pg = Page('pg', 'Forms')
        sg1 = SimpleGridLayout('sg1', 1, 3)
        self.btn_btn = Button('btn_btn',
                              'My Button',
                              onclick_callback=self.btn_clicked,
                              app=app)
        self.btn_enb_dsbl = Button('btn_enb_dsbl',
                                   'Toggle Enable/Disable',
                                   onclick_callback=self.btn_clicked,
                                   app=app)
        self.btn_title = Button('btn_title',
                                'Change Title',
                                onclick_callback=self.btn_clicked,
                                app=app)
        sg1.add(self.btn_btn)
        sg1.add(self.btn_enb_dsbl)
        sg1.add(self.btn_title)
        sg2 = SimpleGridLayout('sg2', 1, 4)
        self.txt = TextBox('txt', app=app, onchange_callback=self.text_changed)
        self.btn_txt_rd = Button('btn_txt_rd',
                                 'Toggle ReadOnly',
                                 app=app,
                                 onclick_callback=self.btn_clicked)
        self.btn_txt_enb_dsbl = Button('btn_txt_enb_dsbl',
                                       'Toggle Enable/Disable',
                                       app=app,
                                       onclick_callback=self.btn_clicked)
        sg2.add(Label('lbl_txt', 'Text', self.txt))
        sg2.add(self.txt)
        sg2.add(self.btn_txt_rd)
        sg2.add(self.btn_txt_enb_dsbl)
        sg3 = SimpleGridLayout('sg3', 1, 3)
        self.chk = CheckBox('chk',
                            'CheckBox',
                            value="checkit",
                            onclick_callback=self.chk_clicked,
                            app=app)
        self.btn_chk = Button('btn_chk',
                              'Toggle Checked',
                              app=app,
                              onclick_callback=self.btn_clicked)
        self.btn_chk_dsbl = Button('btn_chk_dsbl',
                                   'Toggle Disabled',
                                   app=app,
                                   onclick_callback=self.btn_clicked)
        sg3.add(self.chk)
        sg3.add(self.btn_chk)
        sg3.add(self.btn_chk_dsbl)
        sg4 = SimpleGridLayout('sg4', 1, 2)
        self.clr = Color('clr', app=app, onchange_callback=self.clr_changed)
        self.btn_clr_dsbl = Button('btn_clr_dsbl',
                                   "Toggle Disabled",
                                   app=app,
                                   onclick_callback=self.btn_clicked)
        sg4.add(self.clr)
        sg4.add(self.btn_clr_dsbl)
        sg5 = SimpleGridLayout('sg5', 1, 6)
        self.dt = Date('dt', app=app, onchange_callback=self.dt_changed)
        self.btn_dt_dsbl = Button('btn_dt_dsbl',
                                  'Toggle Disable',
                                  app=app,
                                  onclick_callback=self.btn_clicked)
        self.btn_dt_rd = Button('btn_dt_rd',
                                'Toggle Readonly',
                                app=app,
                                onclick_callback=self.btn_clicked)
        self.btn_dt_min = Button('btn_dt_min',
                                 'Change Min',
                                 app=app,
                                 onclick_callback=self.btn_clicked)
        self.btn_dt_max = Button('btn_dt_max',
                                 'Change Max',
                                 app=app,
                                 onclick_callback=self.btn_clicked)
        sg5.add(Label('lbl_sg5', 'Date', self.dt))
        sg5.add(self.dt)
        sg5.add(self.btn_dt_dsbl)
        sg5.add(self.btn_dt_rd)
        sg5.add(self.btn_dt_min)
        sg5.add(self.btn_dt_max)
        sg6 = SimpleGridLayout('sg6', 1, 6)
        self.dtl = DateTimeLocal('dtl',
                                 app=app,
                                 onchange_callback=self.dt_changed)
        self.btn_dtl_dsbl = Button('btn_dtl_dsbl',
                                   'Toggle Disable',
                                   app=app,
                                   onclick_callback=self.btn_clicked)
        self.btn_dtl_rd = Button('btn_dtl_rd',
                                 'Toggle Readonly',
                                 app=app,
                                 onclick_callback=self.btn_clicked)
        self.btn_dtl_min = Button('btn_dtl_min',
                                  'Change Min',
                                  app=app,
                                  onclick_callback=self.btn_clicked)
        self.btn_dtl_max = Button('btn_dtl_max',
                                  'Change Max',
                                  app=app,
                                  onclick_callback=self.btn_clicked)
        sg6.add(Label('lbl_sg6', 'DateTimeLocal', self.dtl))
        sg6.add(self.dtl)
        sg6.add(self.btn_dtl_dsbl)
        sg6.add(self.btn_dtl_rd)
        sg6.add(self.btn_dtl_min)
        sg6.add(self.btn_dtl_max)
        sg7 = SimpleGridLayout('sg7', 1, 4)
        self.email = Email('email',
                           app=app,
                           onchange_callback=self.text_changed)
        self.btn_eml_rd = Button('btn_eml_rd',
                                 'Toggle ReadOnly',
                                 app=app,
                                 onclick_callback=self.btn_clicked)
        self.btn_eml_enb_dsbl = Button('btn_eml_enb_dsbl',
                                       'Toggle Enable/Disable',
                                       app=app,
                                       onclick_callback=self.btn_clicked)
        sg7.add(Label('lbl_email', 'Email', self.email))
        sg7.add(self.email)
        sg7.add(self.btn_eml_rd)
        sg7.add(self.btn_eml_enb_dsbl)
        sg8 = SimpleGridLayout('sg8', 1, 3)
        self._file = File('_file',
                          app=app,
                          onchange_callback=self.file_changed)
        self.btn_fl_dsbl = Button('btn_fl_dsbl',
                                  'Toggle Disable',
                                  app=app,
                                  onclick_callback=self.btn_clicked)
        self.btn_fl_multi = Button('btn_fl_multi',
                                   'Toggle Multiple',
                                   app=app,
                                   onclick_callback=self.btn_clicked)
        sg8.add(self._file)
        sg8.add(self.btn_fl_dsbl)
        sg8.add(self.btn_fl_multi)
        sg9 = SimpleGridLayout('sg9', 14, 2)
        self.img = Image('img', 'src', app=app)
        self.mth = Month('mth', app=app)
        self.num = Number('num', app=app)
        self.password = Password('password', app=app)
        self.rd = Radio('rd', 'Radio', app=app)
        self.rset = Reset('rset', 'Reset', app=app)
        self.rng = Range('rng', app=app)
        self.srch = Search('srch', app=app)
        self.sbmt = Submit('sbmt', 'Submit', app=app)
        self.tlph = Telephone('tlph', app=app)
        self.time = Time('time', app=app)
        self.url = URL('url', app=app)
        self.week = Week('week', app=app)
        self.dd = DropDown('dd', app=app)
        self.dd.add_option('abc', 'ABC', True)
        self.dd.add_option('def', 'DEF')
        self.dd.add_option('ghi', 'GHI')
        sg9.add(Label('lbl', 'Image', self.img))
        sg9.add(self.img)
        sg9.add(Label('lbl1', 'Month', self.mth))
        sg9.add(self.mth)
        sg9.add(Label('lbl', 'Number', self.num))
        sg9.add(self.num)
        sg9.add(Label('lbl', 'Password', self.password))
        sg9.add(self.password)
        sg9.add(Label('lbl', 'Radio', self.rd))
        sg9.add(self.rd)
        sg9.add(Label('lbl', 'Reset', self.rset))
        sg9.add(self.rset)
        sg9.add(Label('lbl', 'Range', self.rng))
        sg9.add(self.rng)
        sg9.add(Label('lbl', 'Search', self.srch))
        sg9.add(self.srch)
        sg9.add(Label('lbl', 'Submit', self.sbmt))
        sg9.add(self.sbmt)
        sg9.add(Label('lbl', 'Telephone', self.tlph))
        sg9.add(self.tlph)
        sg9.add(Label('lbl', 'Time', self.time))
        sg9.add(self.time)
        sg9.add(Label('lbl', 'Url', self.url))
        sg9.add(self.url)
        sg9.add(Label('lbl', 'Week', self.week))
        sg9.add(self.week)
        sg9.add(Label('dd_lbl', 'DropDown', self.dd))
        sg9.add(self.dd)
        self.frm = Form('frm',
                        app=app,
                        use_fieldset=True,
                        legend="Form",
                        on_form_submit=self.form_submitted)
        self.frm.add(sg9)
        self.pg.add(sg1)
        self.pg.add(sg2)
        self.pg.add(sg3)
        self.pg.add(sg4)
        self.pg.add(sg5)
        self.pg.add(sg6)
        self.pg.add(sg7)
        self.pg.add(sg8)
        self.pg.add(self.frm)
        return self.pg.render()

    def form_submitted(self, source, form_data):
        print("Form Submitted: " + str(form_data))

    def file_changed(self, source, props):
        print(props['filename'] + " file has been loaded to path: " +
              props['upload_path'])

    def dt_changed(self, source, props):
        print(source + "'s date changed: " + props['value'] + ", " +
              props['min'] + ", " + props['max'])

    def clr_changed(self, source, props):
        print(source + "'s color changed: " + props['value'])

    def chk_clicked(self, source, props):
        print(source + "'s clicked: " + props['checked'] + ", " +
              props['value'])

    def text_changed(self, source, props):
        print(source + "'s Text Changed: " + props['text'])

    def btn_clicked(self, source, props):  # noqa
        if source == 'btn_btn':
            print("My button clicked")
        elif source == 'btn_enb_dsbl':
            self.btn_btn.disabled = not self.btn_btn.disabled
        elif source == 'btn_title':
            if self.btn_btn.title == 'My Button':
                self.btn_btn.title = 'Your Button'
            else:
                self.btn_btn.title = 'My Button'
        elif source == 'btn_txt_rd':
            self.txt.readonly = not self.txt.readonly
        elif source == 'btn_txt_enb_dsbl':
            self.txt.disabled = not self.txt.disabled
        elif source == 'btn_chk':
            self.chk.checked = not self.chk.checked
        elif source == 'btn_chk_dsbl':
            self.chk.disabled = not self.chk.disabled
        elif source == 'btn_clr_dsbl':
            self.clr.disabled = not self.clr.disabled
        elif source == 'btn_dt_dsbl':
            self.dt.disabled = not self.dt.disabled
        elif source == 'btn_dt_rd':
            self.dt.readonly = not self.dt.readonly
        elif source == 'btn_dt_min':
            self.dt.min = "1980-12-03"
        elif source == 'btn_dt_max':
            self.dt.max = "2050-12-03"
        elif source == 'btn_dtl_dsbl':
            self.dtl.disabled = not self.dtl.disabled
        elif source == 'btn_dtl_rd':
            self.dtl.readonly = not self.dtl.readonly
        elif source == 'btn_dtl_min':
            self.dtl.min = "1980-12-03"
        elif source == 'btn_dtl_max':
            self.dtl.max = "2050-12-03"
        elif source == 'btn_eml_rd':
            self.email.readonly = not self.email.readonly
        elif source == 'btn_eml_enb_dsbl':
            self.email.disabled = not self.email.disabled
        elif source == 'btn_fl_dsbl':
            self._file.disabled = not self._file.disabled
        elif source == 'btn_fl_multi':
            self._file.multiple = not self._file.multiple
Exemple #7
0
class W2UIPage:

    pg = None
    form = None
    ffa = None
    ffc = None
    ffd = None
    ffe = None
    fff = None
    ffi = None
    ffl = None
    ffr = None
    ffs = None
    fft = None
    ffta = None

    def show_layout(self):
        self.pg = Page('pg', 'Forms')
        self.form = Form('form',
                         header="Form Example",
                         submit_callback=self.form_submitted,
                         app=app)
        self.ffa = FormFieldAlpha('ffa', caption='AlphaNumeric:')
        self.ffc = FormFieldCheckbox('ffc', caption="CheckBox:")
        self.ffd = FormFieldDate('ffd', caption="Date:")
        self.ffe = FormFieldEnum('ffe',
                                 caption="Enum:",
                                 items=['ABC', 'DEF', 'GHI'],
                                 options=True)
        self.fff = FormFieldFloat('fff', caption="Float:")
        self.ffi = FormFieldInt('ffi', caption="Int:")
        self.ffl = FormFieldList('ffl',
                                 caption="List:",
                                 items=['ABC', 'DEF', 'GHI'],
                                 options=True)
        self.ffr = FormFieldRadio('ffr',
                                  caption="Radio:",
                                  items=['ABC', 'DEF'],
                                  options=True)
        self.ffs = FormFieldSelect('ffs',
                                   caption="Select:",
                                   items=['ABC', 'DEF', 'GHI'],
                                   options=True)
        self.fft = FormFieldText('fft', caption="Text:")
        self.ffta = FormFieldTextArea('ffta', caption="TextArea:")
        self.form.add(self.ffa)
        self.form.add(self.ffc)
        self.form.add(self.ffd)
        self.form.add(self.ffe)
        self.form.add(self.fff)
        self.form.add(self.ffi)
        self.form.add(self.ffl)
        self.form.add(self.ffr)
        self.form.add(self.ffs)
        self.form.add(self.fft)
        self.form.add(self.ffta)
        self.pg.add(self.form)
        return self.pg.render()

    def form_submitted(self, form_data):
        print("Form Data:" + str(form_data))
class W2UIPage:

    pg = None
    sb = None
    sb_node1 = None
    sb_node11 = None
    sb_node12 = None
    sb_node13 = None
    sb_node2 = None
    sb_node21 = None
    sb_node22 = None
    sb_node23 = None
    actions = None
    add_item = None
    ins_item = None
    rm_item = None
    shw_item = None
    hide_item = None
    enb_item = None
    dsbl_item = None
    expnd_item = None
    clsp_item = None
    sel_item = None
    unsel_item = None
    clk_item = None

    def show_layout(self):
        self.pg = Page('myPage', 'My Page')
        self.sb = Sidebar('sb',
                          app=app,
                          topHTML="Top Conttent",
                          bottomHTML="Bottom Content",
                          onclick_callback=self.sidebar_clicked)
        self.sb.add_style("height", "500px")
        self.sb.add_style("width", "200px")
        self.actions = SidebarNode('actions', 'Actions')
        self.add_item = SidebarNode('add_item', 'Add')
        self.ins_item = SidebarNode('ins_item', 'Insert')
        self.rm_item = SidebarNode('rm_item', 'Remove')
        self.shw_item = SidebarNode('shw_item', 'Show')
        self.hide_item = SidebarNode('hide_item', 'Hide')
        self.enb_item = SidebarNode('enb_item', 'Enable')
        self.dsbl_item = SidebarNode('dsbl_item', 'Disable')
        self.expnd_item = SidebarNode('expnd_item', 'Expand')
        self.clsp_item = SidebarNode('clsp_item', 'Collapse')
        self.sel_item = SidebarNode('sel_item', 'Select')
        self.unsel_item = SidebarNode('unsel_item', 'Unselect')
        self.clk_item = SidebarNode('clk_item', 'Click')
        self.actions.add(self.add_item)
        self.actions.add(self.ins_item)
        self.actions.add(self.rm_item)
        self.actions.add(self.shw_item)
        self.actions.add(self.hide_item)
        self.actions.add(self.enb_item)
        self.actions.add(self.dsbl_item)
        self.actions.add(self.expnd_item)
        self.actions.add(self.clsp_item)
        self.actions.add(self.sel_item)
        self.actions.add(self.unsel_item)
        self.actions.add(self.clk_item)
        self.sb.add(self.actions)
        self.sb_node1 = SidebarNode('sb_node1', 'Node 1')
        self.sb_node11 = SidebarNode('sb_node11', 'Node 11')
        self.sb_node12 = SidebarNode('sb_node12', 'Node 12')
        self.sb_node13 = SidebarNode('sb_node13', 'Node 13')
        self.sb_node1.add(self.sb_node11)
        self.sb_node1.add(self.sb_node12)
        self.sb_node1.add(self.sb_node13)
        self.sb_node2 = SidebarNode('sb_node2', 'Node 2')
        self.sb_node21 = SidebarNode('sb_node21', 'Node 21')
        self.sb_node22 = SidebarNode('sb_node22', 'Node 22')
        self.sb_node23 = SidebarNode('sb_node23', 'Node 23')
        self.sb_node2.add(self.sb_node21)
        self.sb_node2.add(self.sb_node22)
        self.sb_node2.add(self.sb_node23)
        self.sb.add(self.sb_node1)
        self.sb.add(self.sb_node2)
        self.pg.add(self.sb)
        return self.pg.render()

    def sidebar_clicked(self):  # noqa
        if self.sb.clicked_item == 'add_item':
            new_item = SidebarNode('new_item', 'New Item')
            self.sb.add_items([new_item])
        if self.sb.clicked_item == 'ins_item':
            new_ins_item = SidebarNode('new_ins_item', 'New Inserted Item')
            self.sb.insert_items([new_ins_item], 'sb_node1')
        if self.sb.clicked_item == 'rm_item':
            self.sb.remove_items(['new_ins_item'])
        if self.sb.clicked_item == 'shw_item':
            self.sb.show_items(['new_item'])
        if self.sb.clicked_item == 'hide_item':
            self.sb.hide_items(['new_item'])
        if self.sb.clicked_item == 'enb_item':
            self.sb.enable_item('new_item')
        if self.sb.clicked_item == 'dsbl_item':
            self.sb.disable_item('new_item')
        if self.sb.clicked_item == 'expnd_item':
            self.sb.expand_item('sb_node2')
        if self.sb.clicked_item == 'clsp_item':
            self.sb.collapse_item('sb_node2')
        if self.sb.clicked_item == 'sel_item':
            self.sb.select_item('new_item')
        if self.sb.clicked_item == 'unsel_item':
            self.sb.unselect_item('new_item')
        if self.sb.clicked_item == 'clk_item':
            self.sb.click_item('new_item')
 def show_layout(self):
     pg = Page('pg', 'Websocket')
     sg = SimpleGridLayout('sg', 25, 2)
     self.bt = Button('bt',
                      'Button',
                      socketio,
                      click_callback=self.btn_clicked)
     self.bt1 = Button('bt1',
                       'Button 1',
                       socketio,
                       click_callback=self.btn1_clicked)
     self.txt = TextBox('txt', socketio, change_callback=self.txt_changed)
     self.chk = CheckBox('chk',
                         socketio,
                         title='My Checkbox',
                         click_callback=self.chk_clicked)
     self.clr = Color('clr', socketio, change_callback=self.color_changed)
     self.dt = Date('dt', socketio, change_callback=self.dt_changed)
     self.dtl = DateTimeLocal('dtl',
                              socketio,
                              change_callback=self.dt_changed)
     self.eml = Email('eml', socketio, change_callback=self.txt_changed)
     self.fl = File('fl',
                    socketio,
                    change_callback=self.fl_changed,
                    click_callback=self.fl_clicked)
     self.img = Image('img', '', socketio, click_callback=self.btn_clicked)
     self.mth = Month('mth', socketio, change_callback=self.dt_changed)
     self.num = Number('num', socketio, change_callback=self.txt_changed)
     self.pswd = Password('pswd',
                          socketio,
                          change_callback=self.txt_changed)
     self.rd = Radio('rd',
                     socketio,
                     click_callback=self.chk_clicked,
                     title="My Radio")
     self.rng = Range('rng',
                      socketio,
                      min=0,
                      max=100,
                      change_callback=self.dt_changed)
     self.rst = Reset('rst',
                      socketio,
                      title='Cancel',
                      click_callback=self.btn_clicked)
     self.srch = Search('srch', socketio, change_callback=self.txt_changed)
     self.sbmt = Submit('sbmt',
                        socketio,
                        title='Save',
                        click_callback=self.btn_clicked)
     self.tel = Telephone('tel', socketio, change_callback=self.txt_changed)
     self.time = Time('time', socketio, change_callback=self.dt_changed)
     self.url = URL('url', socketio, change_callback=self.txt_changed)
     self.week = Week('week', socketio, change_callback=self.dt_changed)
     self.frm = Form('frm',
                     socketio,
                     use_fieldset=True,
                     legend="My Form",
                     submit_callback=self.frm_submitted)
     self.frm_text = TextBox('frm_text', socketio)
     self.lbox = ListBox('lbox',
                         socketio,
                         change_callback=self.dd_changed,
                         multiselect=True)
     self.lbox.add_option('abc', 'ABC', False)
     self.lbox.add_option('def', 'DEF', True)
     self.lbox.add_option('ghi', 'GHI', False)
     self.lbox.add_option('jkl', 'JKL', False)
     self.lbox.add_option('mno', 'MNO', False)
     self.lbox.add_option('pqr', 'PQR', False)
     self.lbl = Label('lbl', 'My Label', self.lbox, socketio)
     sg.add(Label('lb1', 'Button', self.bt, socketio))
     sg.add(self.bt)
     sg.add(Label('lb2', 'Button', self.bt1, socketio))
     sg.add(self.bt1)
     sg.add(Label('lb3', 'TextBox', self.txt, socketio))
     sg.add(self.txt)
     sg.add(Label('lb4', 'CheckBox', self.chk, socketio))
     sg.add(self.chk)
     sg.add(Label('lb5', 'Color', self.clr, socketio))
     sg.add(self.clr)
     sg.add(Label('lb6', 'Date', self.dt, socketio))
     sg.add(self.dt)
     sg.add(Label('lb7', 'DateTimeLocal', self.dtl, socketio))
     sg.add(self.dtl)
     sg.add(Label('lb8', 'Email', self.eml, socketio))
     sg.add(self.eml)
     sg.add(Label('lb9', 'File', self.fl, socketio))
     sg.add(self.fl)
     sg.add(Label('lb10', 'Image', self.img, socketio))
     sg.add(self.img)
     sg.add(Label('lb11', 'Month', self.mth, socketio))
     sg.add(self.mth)
     sg.add(Label('lb12', 'Number', self.num, socketio))
     sg.add(self.num)
     sg.add(Label('lb13', 'Password', self.pswd, socketio))
     sg.add(self.pswd)
     sg.add(Label('lb14', 'Radio', self.rd, socketio))
     sg.add(self.rd)
     sg.add(Label('lb15', 'Range', self.rng, socketio))
     sg.add(self.rng)
     sg.add(Label('lb16', 'Reset', self.rst, socketio))
     sg.add(self.rst)
     sg.add(Label('lb17', 'Search', self.srch, socketio))
     sg.add(self.srch)
     sg.add(Label('lb18', 'Submit', self.sbmt, socketio))
     sg.add(self.sbmt)
     sg.add(Label('lb19', 'Telephone', self.tel, socketio))
     sg.add(self.tel)
     sg.add(Label('lb20', 'Time', self.time, socketio))
     sg.add(self.time)
     sg.add(Label('lb21', 'URL', self.url, socketio))
     sg.add(self.url)
     sg.add(Label('lb22', 'Week', self.week, socketio))
     sg.add(self.week)
     sg.add(Label('lb23', 'Form', self.frm, socketio))
     self.frm.add(self.frm_text)
     sg.add(self.frm)
     sg.add(Label('lb24', 'ListBox', self.lbox, socketio))
     sg.add(self.lbox)
     sg.add(Label('lb25', 'Label', self.lbl, socketio))
     sg.add(self.lbl)
     pg.add(sg)
     return pg.render()