def test_pn_navigation_button(): """# Manual Test of the Navigation Buttons - Ordinary Button - Button With Font Awesome """ # Given: pnx.fontawesome.extend() page = pnx.Header("Button Page", name="Button") page_font_awesome = pnx.Header("Font Awesome Page", name=" Font Awesome") page_outlet = pn.Column(page) button = pnx.NavigationButton(page=page, page_outlet=page_outlet) button_font_awesome = pnx.NavigationButton( page=page_font_awesome, page_outlet=page_outlet, css_classes=["pab", "pa-twitter"]) app = pn.Column( pnx.Markdown(test_pn_navigation_button.__doc__), button, button_font_awesome, page_outlet, width=400, ) # When app.servable("test_pn_navigation")
def test_headings(): """We test that we can show - headers: title, header, subheader - aligned: left, center """ return TestApp( test_headings, pnx.Title("Title Left"), pnx.Header("Header Left"), pnx.SubHeader("SubHeader Left"), pnx.Title("Title Center", text_align="center",), pnx.Header("Header Center", text_align="center",), pnx.SubHeader("SubHeader Center", text_align="center",), sizing_mode="stretch_width", )
def test_with_url(): """We test that we can show a Title with a link """ return TestApp( test_with_url, pnx.Title("Title with url", url="https://awesome-panel.org",), pnx.Header("Header with url", url="https://awesome-panel.org",), pnx.SubHeader("SubHeader with url", url="https://awesome-panel.org",), sizing_mode="stretch_width", )
def test_title_centered_white(): """We test that we can show a centered Title, Header and SubHeader with a white text color""" return TestApp( test_title_centered_white, pnx.Title("Title Center", text_align="center", style={"color": "white"},), pnx.Header("Header Center", text_align="center", style={"color": "white"},), pnx.SubHeader("SubHeader Center", text_align="center", style={"color": "white"},), sizing_mode="stretch_width", background="lightgray", )
def test_headings(): """## test_headings We test that we can show - headers: title, header, subheader - aligned: left, center """ app = pn.Column( pn.pane.Markdown(test_headings.__doc__), pnx.Title("Title Left"), pnx.Header("Header Left"), pnx.SubHeader("SubHeader Left"), pnx.Title("Title Center", text_align="center"), pnx.Header("Header Center", text_align="center"), pnx.SubHeader("SubHeader Center", text_align="center"), sizing_mode="stretch_width", background="lightgray", ) app.servable(test_headings.__name__)
def plotly_view(*args, **kwargs) -> pn.Column: """## Dashboard Orders Chart View based on Plotly""" fig = plotly_chart() return pn.Column( pnx.Header("Plotly"), pn.Row(pn.layout.HSpacer(), pn.pane.Plotly(fig), pn.layout.HSpacer(),), pnx.InfoAlert("Plotly cannot currently auto size to full width and be responsive"), pnx.Code(code=inspect.getsource(plotly_chart)), sizing_mode="stretch_width", name="Plotly", *args, **kwargs, )
def test_with_url(): """## test_with_url We test that we can show a Title with a link """ app = pn.Column( pn.pane.Markdown(test_with_url.__doc__), pnx.Title("Title with url", url="https://awesome-streamlit.org"), pnx.Header("Header with url", url="https://awesome-streamlit.org"), pnx.SubHeader("SubHeader with url", url="https://awesome-streamlit.org"), sizing_mode="stretch_width", background="lightgray", ) app.servable(test_with_url.__name__)
def holoviews_view() -> pn.Column: """## Dashboard Orders Chart View based on HoloViews""" fig = holoviews_chart() text = """ The [HoloViews](http://holoviews.org/) and [hvplot](https://hvplot.pyviz.org/) I had not used before. Their APIs are different than what I'm used to be also seems powerfull. I'm used to Plotly but it does not work well in Panel yet. """ return pn.Column( pnx.Header("Holoviews"), fig, pn.pane.Markdown(text), pnx.Code(inspect.getsource(holoviews_chart)), name="Holoviews", sizing_mode="stretch_both", )
def dataframe_view(*args, **kwargs) -> pn.Column: """## Dashboard Orders Table View""" table = pn.widgets.DataFrame(services.get_table_data(), sizing_mode="stretch_width") text = """I did not use the [DataFrame widget](https://panel.pyviz.org/reference/widgets/DataFrame.html#gallery-dataframe) in the dashboard because it would not look like the GetBootstrap example. But I would always use this power full DataFrame widget in practice because it's so powerfull and nice. It's based on [SlickGrid](https://slickgrid.net/). """ return pn.Column( pnx.Header("DataFrame"), pnx.InfoAlert(text), pn.layout.VSpacer(height=20), # Hack table, sizing_mode="stretch_width", name="DataFrame", *args, **kwargs, )
def test_title_centered_white(): """## test_title_centered_white We test that we can show a centered Title, Header and SubHeader with a white text color """ app = pn.Column( pn.pane.Markdown(test_title_centered_white.__doc__), pnx.Title("Title Center", text_align="center", style={"color": "white"}), pnx.Header("Header Center", text_align="center", style={"color": "white"}), pnx.SubHeader("SubHeader Center", text_align="center", style={"color": "white"}), sizing_mode="stretch_width", background="lightgray", ) app.servable(test_title_centered_white.__name__)
def view(): """Run this to run the application""" set_environ() image_classifier_app = ImageClassifierApp() app = pn.Column( pnx.Header( "Image Classification with Keras and Tensorflow.", height=40, ), pn.pane.Markdown(__doc__), image_classifier_app.resources_view, pnx.SubHeader("Classifier"), pn.Param( image_classifier_app.param["model"], widgets={ "model": { "type": pn.widgets.RadioButtonGroup, "button_type": "primary", } }, ), pnx.SubHeader("Image"), pn.Param( image_classifier_app.param["image_file"], widgets={ "image_file": { "type": pn.widgets.FileInput, "accept": ".jpg", } }, ), image_classifier_app.image_view, image_classifier_app.predictions_view, sizing_mode="stretch_width", ) return app