Skip to content

Commit 996798f

Browse files
authored
More API changes (#69)
1 parent 3403372 commit 996798f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+764
-571
lines changed

examples/bind_event/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from shiny import *
3-
from htmltools import tags
3+
from shiny.ui import tags
44

55
app_ui = ui.page_fluid(
66
tags.p(

examples/download/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Any
66

77
from shiny import *
8-
from htmltools import div, p
8+
from shiny.ui import div, p
99

1010
import matplotlib.pyplot as plt
1111
import numpy as np

examples/inputs-update/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import date
22

33
from shiny import *
4-
from htmltools import tags, h2
4+
from shiny.ui import tags, h2
55

66
app_ui = ui.page_fluid(
77
ui.panel_title("Changing the values of inputs from the server"),

examples/inputs/app.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from shiny import *
2-
from htmltools import tags, HTML, Tag
2+
from shiny.types import ImgData
3+
from shiny.ui import tags, HTML, Tag
34
from fontawesome import icon_svg
45

56
app_ui = ui.page_fluid(
@@ -128,7 +129,8 @@ def image():
128129
from pathlib import Path
129130

130131
dir = Path(__file__).resolve().parent
131-
return {"src": dir / "rstudio-logo.png", "width": "150px"}
132+
img: ImgData = {"src": str(dir / "rstudio-logo.png"), "width": "150px"}
133+
return img
132134

133135
@reactive.effect()
134136
def _():
@@ -146,8 +148,8 @@ def _():
146148
def _():
147149
link = input.link()
148150
if link and link > 0:
149-
notification_show("A notification!")
150-
p = Progress()
151+
ui.notification_show("A notification!")
152+
p = ui.Progress()
151153
import time
152154

153155
for i in range(30):

examples/dynamic_ui/app.py renamed to examples/insert_ui/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from shiny import *
2-
from htmltools import tags
2+
from shiny.ui import tags
33

44
# For plot rendering
55
import numpy as np
@@ -54,9 +54,9 @@ def _():
5454
def _():
5555
btn = input.btn()
5656
if btn % 2 == 1:
57-
ui_insert(tags.p("Thanks for clicking!", id="thanks"), "body")
57+
ui.insert_ui(tags.p("Thanks for clicking!", id="thanks"), "body")
5858
elif btn > 0:
59-
ui_remove("#thanks")
59+
ui.remove_ui("#thanks")
6060

6161

6262
app = App(app_ui, server)

examples/moduleapp/app.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
from typing import Callable
12
from shiny import *
3+
from shiny.modules import *
4+
25

36
# ============================================================
47
# Counter module
58
# ============================================================
6-
def counter_module_ui(
9+
def counter_ui(
710
ns: Callable[[str], str], label: str = "Increment counter"
8-
) -> TagChildArg:
11+
) -> ui.TagChildArg:
912
return ui.div(
1013
{"style": "border: 1px solid #ccc; border-radius: 5px; margin: 5px 0;"},
1114
ui.h2("This is " + label),
@@ -14,9 +17,7 @@ def counter_module_ui(
1417
)
1518

1619

17-
def counter_module_server(
18-
input: InputsProxy, output: OutputsProxy, session: SessionProxy
19-
):
20+
def counter_server(input: ModuleInputs, output: ModuleOutputs, session: ModuleSession):
2021
count: reactive.Value[int] = reactive.Value(0)
2122

2223
@reactive.effect()
@@ -30,7 +31,7 @@ def out() -> str:
3031
return f"Click count is {count()}"
3132

3233

33-
counter_module = ShinyModule(counter_module_ui, counter_module_server)
34+
counter_module = Module(counter_ui, counter_server)
3435

3536

3637
# =============================================================================

examples/myapp/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from shiny import *
2-
from shiny.fileupload import FileInfo
2+
from shiny.types import FileInfo
33
import matplotlib.pyplot as plt
44
import numpy as np
55

examples/req/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from shiny import *
2+
from shiny.types import SafeException
23

34
app_ui = ui.page_fluid(
45
ui.input_action_button("safe", "Throw a safe error"),

shiny/__init__.py

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,47 @@
1-
"""Top-level package for Shiny."""
1+
"""A package for building reactive web applications."""
22

3-
__author__ = """Winston Chang"""
4-
__email__ = "[email protected]"
5-
__version__ = "0.0.0.9001"
6-
7-
# All objects imported into this scope will be available as shiny.foo
8-
from .decorators import *
9-
from .dynamic_ui import *
10-
from .notifications import *
11-
from .progress import *
3+
# User-facing subpackages that should be available on `from shiny import *`
4+
from . import reactive
125
from .render import *
13-
from .app import *
146
from .session import *
15-
from .shinymodule import *
16-
from .validation import *
17-
18-
from . import reactive
197
from . import ui
8+
9+
# Private submodules that have some user-facing functionality
10+
from ._app import App
11+
from ._decorators import event
12+
from ._main import run as run_app
13+
from ._validation import req
14+
15+
# User-facing submodules that should *not* be available on `from shiny import *`
16+
from . import modules
17+
from . import types
18+
19+
# N.B.: we intentionally don't import 'developer-facing' submodules (e.g.,
20+
# html_dependencies) so that they aren't super visible when you `import shiny`, but
21+
# developers who know what they're doing can import them directly.
22+
23+
24+
__all__ = (
25+
# public sub-packages
26+
"reactive",
27+
"render",
28+
"session",
29+
"ui",
30+
# _app.py
31+
"App",
32+
# _decorators.py
33+
"event",
34+
# _main.py
35+
"run_app",
36+
# _render.py
37+
"render_text",
38+
"render_plot",
39+
"render_image",
40+
"render_ui",
41+
# _session.py
42+
"Session",
43+
"Inputs",
44+
"Outputs",
45+
# _validation.py
46+
"req",
47+
)

shiny/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .main import main
1+
from ._main import main
22

33
if __name__ == "__main__":
44
main()

0 commit comments

Comments
 (0)