-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfe7dfc
commit cf7d304
Showing
7 changed files
with
137 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,42 @@ | ||
""" | ||
Purpose: Use Python to create a continuous intelligence and | ||
interactive analytics dashboard using Shiny for Python. | ||
|
||
Each Shiny app has two parts: | ||
from shiny.express import input, render, ui | ||
from shinyswatch import theme | ||
|
||
ui.page_opts(title="Case Dashboard", fillable=True) | ||
# theme.minty() | ||
# theme.cerulean() | ||
|
||
with ui.sidebar(open="desktop"): | ||
ui.h2("Sidebar") | ||
ui.tags.hr() | ||
ui.h3("Interaction") | ||
ui.input_text("name_input", "Enter your name", placeholder="Your Name") | ||
ui.input_text("language_input", "Enter your favorite language(s)", placeholder="Favorite Programming Language(s)") | ||
ui.tags.hr() | ||
ui.h3("Links") | ||
ui.a("PyShiny", href="https://shiny.posit.co/py/", target="_blank") | ||
ui.a("Examples", href="https://shinylive.io/py/examples/", target="_blank") | ||
ui.a("Themes", href="https://posit-dev.github.io/py-shinyswatch/", target="_blank") | ||
ui.a("Deploy", href="https://docs.posit.co/shinyapps.io/getting-started.html#working-with-shiny-for-python", target="_blank") | ||
ui.a("GitHub", href="https://github.com/denisecase", target="_blank") | ||
ui.a("GitHub Repository", href="https://github.com/denisecase/cintel-02-app", target="_blank") | ||
ui.a("Shinylive.io App", href="https://denisecase.shinyapps.io/cintel-02-app/", target="_blank") | ||
|
||
with ui.layout_columns(fill=False): | ||
ui.h2("Main Area with Reactive Output") | ||
|
||
|
||
@render.text | ||
def welcome_output(): | ||
user = input.name_input(); | ||
welcome_string = f'Greetings {user}!'; | ||
return welcome_string | ||
|
||
|
||
@render.text | ||
def insights_output(): | ||
answer = input.language_input() | ||
count = len(answer) | ||
language_string = f'You like {answer}. That takes {count} characters' | ||
return language_string | ||
|
||
- a user interface app_ui object (similar to the HTML in a web page) | ||
- a server function that provides the logic for the app (similar to JS in a web page). | ||
""" | ||
import shinyswatch | ||
from shiny import * | ||
|
||
|
||
# TODO: Change the shinyswatch theme to morph, cosmo, darkly, flatly, sketchy (or other shinyswatch theme) | ||
# Preview at https://bootswatch.com/ | ||
app_ui = ui.page_navbar( | ||
shinyswatch.theme.minty(), | ||
ui.nav( | ||
"Home", | ||
ui.layout_sidebar( | ||
ui.panel_sidebar( | ||
ui.h2("Sidebar Panel"), | ||
ui.tags.hr(), | ||
ui.h3("User Interaction Here"), | ||
ui.input_text("name_input", "Enter your name", placeholder="Your Name"), | ||
ui.input_text("language_input", "Enter your favorite language(s)", placeholder="Favorite Programming Language(s)"), | ||
ui.tags.hr(), | ||
), | ||
ui.panel_main( | ||
ui.h2("Main Panel with Reactive Output"), | ||
ui.output_text_verbatim("welcome_output"), | ||
ui.output_text_verbatim("insights_output"), | ||
), | ||
), | ||
), | ||
# TODO: Update the links to reflect your own about, GitHub repo, and app | ||
ui.nav(ui.a("About", href="https://github.com/denisecase")), | ||
ui.nav(ui.a("GitHub", href="https://github.com/denisecase/cintel-02-app")), | ||
ui.nav(ui.a("App", href="https://denisecase.github.io/cintel-02-app/")), | ||
ui.nav(ui.a("Shiny", href="https://shiny.posit.co/py/")), | ||
ui.nav(ui.a("Examples", href="https://shinylive.io/py/examples/")), | ||
ui.nav(ui.a("Themes", href="https://rstudio.github.io/py-shinyswatch/")), | ||
ui.nav(ui.a("Deploy", href="https://docs.posit.co/shinyapps.io/getting-started.html#working-with-shiny-for-python")), | ||
# TODO: Update the title to reflect yourname Dashboard | ||
title=ui.h1("Case Dashboard"), | ||
) | ||
|
||
|
||
def server(input, output, session): | ||
""" | ||
This is the required server function. | ||
@param input: a dictionary of input values | ||
@param output: a dictionary of output functions | ||
@param session: a dictionary of session values (not used) | ||
""" | ||
|
||
# Define the reactive outputs. Tell what to render and how to render it | ||
# TODO: Customize the reactive greeting. | ||
|
||
@output | ||
@render.text | ||
def welcome_output(): | ||
user = input.name_input(); | ||
welcome_string = f'Greetings {user}!'; | ||
return welcome_string | ||
|
||
@output | ||
@render.text | ||
def insights_output(): | ||
answer = input.language_input() | ||
count = len(answer) | ||
language_string = f'You like {answer}. That takes {count} characters' | ||
return language_string | ||
|
||
# Create a Shiny App by passing in the two parts defined above. | ||
app = App(app_ui, server, debug=True) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
faicons | ||
htmltools | ||
pandas | ||
ipywidgets | ||
rsconnect-python | ||
shiny | ||
shinyswatch | ||
shinywidgets |