Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New input_switch() example #641

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions shiny/api-examples/input_switch/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from shiny import App, Inputs, Outputs, Session, render, ui

app_ui = ui.page_fluid(
ui.input_switch("somevalue", "Some value", False),
ui.output_ui("value"),
ui.h2("Keyboard Settings"),
ui.input_switch("auto_capitalization", "Auto-Capitalization", True),
ui.input_switch("auto_correction", "Auto-Correction", True),
ui.input_switch("check_spelling", "Check Spelling", True),
ui.input_switch("smart_punctuation", "Smart Punctuation"),
ui.output_text_verbatim("preview"),
)


def server(input: Inputs, output: Outputs, session: Session):
@output
@render.ui
def value():
return input.somevalue()
@render.text
def preview():
return f"""Keyboard Settings
==========================
auto_capitalization: {input.auto_capitalization()}
auto_correction: {input.auto_correction()}
check_spelling: {input.check_spelling()}
smart_punctuation: {input.smart_punctuation()}"""


app = App(app_ui, server)
Loading