def test_render_sizer_children(nodes_count): """should render all xml children for every item""" render_mock = Mock() add_singleton(render, render_mock) with patch(sizers.__name__ + '.InheritedDict') as inherited_dict_mock: inherited_dict_mock.side_effect = lambda p: {'source': p} if p else p xml_node = Mock(children=[Mock() for _ in range(nodes_count)]) parent, node = Mock(), SizerNode(Mock(), xml_node) context = WxRenderingContext({'node': node, 'parent': parent}) render_sizer_children(node, context) for actual_call, child_xml_node in zip(render_mock.call_args_list, xml_node.children): child_context = WxRenderingContext({ 'parent_node': node, 'parent': parent, 'node_globals': inherited_dict_mock(node.node_globals), 'sizer': node.instance, 'xml_node': child_xml_node }) assert actual_call == call(child_context)
def use_wx_pipelines(): """Returns resolver for RenderingPipeline""" add_singleton(get_child_context, get_wx_child_context) use_pipeline(get_wx_pipeline(), 'wx') use_pipeline(get_app_pipeline(), 'wx.App') use_pipeline(get_frame_pipeline(), 'wx.Frame') use_pipeline(get_container_pipeline(), 'wxviews.Container') use_pipeline(get_view_pipeline(), 'wxviews.View') use_pipeline(get_for_pipeline(), 'wxviews.For') use_pipeline(get_if_pipeline(), 'wxviews.If') use_pipeline(get_sizer_pipeline(), 'wx.GridSizer') use_pipeline(get_sizer_pipeline(), 'wx.FlexGridSizer') use_pipeline(get_sizer_pipeline(), 'wx.GridBagSizer') use_pipeline(get_sizer_pipeline(), 'wx.BoxSizer') use_pipeline(get_sizer_pipeline(), 'wx.StaticBoxSizer') use_pipeline(get_growable_row_pipeline(), 'wxviews.GrowableRow') use_pipeline(get_growable_col_pipeline(), 'wxviews.GrowableCol') use_pipeline(get_menu_bar_pipeline(), 'wx.MenuBar') use_pipeline(get_menu_pipeline(), 'wx.Menu') use_pipeline(get_menu_item_pipeline(), 'wx.MenuItem') use_pipeline(get_style_pipeline(), 'wxviews.Style') use_pipeline(get_styles_view_pipeline(), 'wxviews.StylesView') use_pipeline(RenderingPipeline(pipes=[run_code]), 'wxviews.Code') use_pipeline(get_presenter_pipeline(), 'wxviews.PresenterNode')
def use_tkviews_pipelines(): """Adds rendering pipelines for tkviews""" add_singleton(get_child_context, get_tk_child_context) use_pipeline(get_root_pipeline(), 'tkviews.Root') use_pipeline(get_widget_pipeline(), 'tkinter') use_pipeline(get_widget_pipeline(), 'tkinter.ttk') use_pipeline(get_presenter_pipeline(), 'tkviews.PresenterNode') use_pipeline(get_container_pipeline(), 'tkviews.Container') use_pipeline(get_view_pipeline(), 'tkviews.View') use_pipeline(get_for_pipeline(), 'tkviews.For') use_pipeline(get_if_pipeline(), 'tkviews.If') use_pipeline(get_style_pipeline(), 'tkviews.Style') use_pipeline(get_styles_view_pipeline(), 'tkviews.StylesView') use_pipeline(get_ttk_style_pipeline(), 'tkviews.TtkStyle') use_pipeline(get_canvas_pipeline(), 'tkviews.canvas') use_pipeline(RenderingPipeline(pipes=[run_code]), 'tkviews.Code')
def run_demo(): """Entry point""" register_dependencies() add_singleton('views_folder', abspath('.')) launch('app/demo')