def get_example_display(my): div = DivWdg() # ----------------------------- Smart Menu data ---------------------------------------------------------- menus = [ my.get_smart_menu_main_menu_details(), my.get_smart_menu_submenu_one_details(), my.get_smart_menu_submenu_two_details() ] # ----------------------------- Smart Context Menu example ----------------------------------------------- my.setup_next_example(div, "Smart Context Menu example ...") ctx_click_div = DivWdg() ctx_click_div.add_styles("background: orange; color: white; border: 1px solid black; " \ "padding: 10px; width: 100px;") ctx_click_div.add("Right Click") SmartMenu.attach_smart_context_menu(ctx_click_div, menus) div.add(ctx_click_div) # ----------------------------- Smart Drop-down Button Menu example -------------------------------------- my.setup_next_example(div, "Smart Drop-down Button Menu example ...") btn_dd = SmartMenu.get_smart_button_dropdown_wdg("Hello", menus, 150) div.add(btn_dd) # ----------------------------- Original Context Menu examples ------------------------------------------- my.setup_next_example(div, "Original Context Menu examples ...") # Create the element to right click on for the given main context menu ... activator = DivWdg() activator.add_style("width: 300px") activator.add_style("height: 50px") activator.add_style("background: #660000") activator.add_style("text-align: center") activator.add( "<br/>Right click on me!<br/>(this widget creates the context menus)" ) s_menu_2 = my.get_ctx_sub_menu_two_details() s_menu_3 = {} s_menu_3.update(s_menu_2) s_menu_3.update({'menu_id': "CtxMenu_Mike_Submenu_Three"}) ctx_menu = my.get_ctx_menu_details() menus = [ctx_menu, my.get_ctx_sub_menu_details(), s_menu_2, s_menu_3] attach_ctx_menu_wdg = AttachContextMenuWdg(activator_wdg=activator, menus=menus) div.add(attach_ctx_menu_wdg) div.add(activator) div.add("<br/><br/>") # Create second context menu activator, but one that attaches to the already created context menus that # were generated above for the first activator. This allows for efficient use of context menus -- e.g. # you only need to actually generate one set, but still be able to use that same set of context menus # for all, say, edit cells of a DG table ... # activator2 = DivWdg() activator2.add_style("width: 300px") activator2.add_style("height: 50px") activator2.add_style("background: #000066") activator2.add_style("text-align: center") activator2.add( "<br/>Right click on me!<br/>(this widget attaches to already created context menus)" ) AttachContextMenuWdg.attach_by_menu_id(activator2, ctx_menu.get('menu_id')) div.add(activator2) # -------------------- Drop-down Button Menu example ------------------------------------------------------ my.setup_next_example(div, "Original Drop-down Menu Button example ...") menus = [my.get_dd_plain_menu(), my.get_dd_plain_submenu_1()] dd_button = ButtonForDropdownMenuWdg(id="MikeDropDownBtn", title="LMB on Me For Menu", menus=menus, width=150, match_width=True) div.add(dd_button) return div
def get_example_display(self): div = DivWdg() # ----------------------------- Smart Menu data ---------------------------------------------------------- menus = [ self.get_smart_menu_main_menu_details(), self.get_smart_menu_submenu_one_details(), self.get_smart_menu_submenu_two_details() ] # ----------------------------- Smart Context Menu example ----------------------------------------------- self.setup_next_example( div, "Smart Context Menu example ..." ) ctx_click_div = DivWdg() ctx_click_div.add_styles("background: orange; color: white; border: 1px solid black; " \ "padding: 10px; width: 100px;") ctx_click_div.add( "Right Click" ) SmartMenu.attach_smart_context_menu( ctx_click_div, menus ) div.add(ctx_click_div) # ----------------------------- Smart Drop-down Button Menu example -------------------------------------- self.setup_next_example( div, "Smart Drop-down Button Menu example ..." ) btn_dd = SmartMenu.get_smart_button_dropdown_wdg( "Hello", menus, 150 ) div.add(btn_dd) # ----------------------------- Original Context Menu examples ------------------------------------------- self.setup_next_example( div, "Original Context Menu examples ..." ) # Create the element to right click on for the given main context menu ... activator = DivWdg() activator.add_style( "width: 300px" ) activator.add_style( "height: 50px" ) activator.add_style( "background: #660000" ) activator.add_style( "text-align: center" ) activator.add( "<br/>Right click on me!<br/>(this widget creates the context menus)" ) s_menu_2 = self.get_ctx_sub_menu_two_details() s_menu_3 = {} s_menu_3.update( s_menu_2 ) s_menu_3.update( { 'menu_id': "CtxMenu_Mike_Submenu_Three" } ) ctx_menu = self.get_ctx_menu_details() menus = [ ctx_menu, self.get_ctx_sub_menu_details(), s_menu_2, s_menu_3 ] attach_ctx_menu_wdg = AttachContextMenuWdg( activator_wdg=activator, menus=menus ) div.add( attach_ctx_menu_wdg ) div.add( activator ) div.add( "<br/><br/>" ) # Create second context menu activator, but one that attaches to the already created context menus that # were generated above for the first activator. This allows for efficient use of context menus -- e.g. # you only need to actually generate one set, but still be able to use that same set of context menus # for all, say, edit cells of a DG table ... # activator2 = DivWdg() activator2.add_style( "width: 300px" ) activator2.add_style( "height: 50px" ) activator2.add_style( "background: #000066" ) activator2.add_style( "text-align: center" ) activator2.add( "<br/>Right click on me!<br/>(this widget attaches to already created context menus)" ) AttachContextMenuWdg.attach_by_menu_id( activator2, ctx_menu.get('menu_id') ) div.add( activator2 ) # -------------------- Drop-down Button Menu example ------------------------------------------------------ self.setup_next_example( div, "Original Drop-down Menu Button example ..." ) menus = [ self.get_dd_plain_menu(), self.get_dd_plain_submenu_1() ] dd_button = ButtonForDropdownMenuWdg( id="MikeDropDownBtn", title="LMB on Me For Menu", menus=menus, width=150, match_width=True) div.add( dd_button ) return div