Skip to content

Commit 597d836

Browse files
committed
Merge branch 'main' into shiny-create-bugs
* main: Use dynamic version of py-shiny for deploy tests (#970) Add underscores to hide some imports (#978) Add rsconnect json files(shinyapps.io tests) and folium tests (#928) Express' `value_box()` no longer includes named positional args (#966) Include `tooltip()` and `popover()` in express (#949)
2 parents d952d71 + 6ed505b commit 597d836

File tree

45 files changed

+470
-54
lines changed

Some content is hidden

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

45 files changed

+470
-54
lines changed

.github/workflows/pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
with:
120120
python-version: ${{ matrix.python-version }}
121121

122-
- name: Run example app tests
122+
- name: Run tests for deploys
123123
env:
124124
DEPLOY_CONNECT_SERVER_URL: "https://rsc.radixu.com/"
125125
DEPLOY_CONNECT_SERVER_API_KEY: "${{ secrets.DEPLOY_CONNECT_SERVER_API_KEY }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@ docs/source/reference/
113113

114114
# Developer scratch area
115115
_dev/
116+
tests/playwright/deploys/apps/*/requirements.txt

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ test =
8383
missingno
8484
rsconnect-python
8585
scikit-learn
86+
folium
8687

8788
dev =
8889
black>=23.1.0
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import datetime
2+
3+
from shiny import render, ui
4+
from shiny.express import input, layout
5+
6+
with layout.card(id="card"):
7+
ui.input_slider("val", "slider", 0, 100, 50)
8+
"Text outside of render display call"
9+
ui.tags.br()
10+
f"Rendered time: {str(datetime.datetime.now())}"
11+
12+
@render.display
13+
def render_display():
14+
"Text inside of render display call"
15+
ui.tags.br()
16+
"Dynamic slider value: "
17+
input.val()
18+
ui.tags.br()
19+
f"Display's rendered time: {str(datetime.datetime.now())}"

shiny/express/__init__.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from __future__ import annotations
22

3-
from ..session import Inputs, Outputs, Session
3+
# Import these with underscore names so they won't show in autocomplete from the Python
4+
# console.
5+
from ..session import Inputs as _Inputs, Outputs as _Outputs, Session as _Session
46
from ..session import _utils as _session_utils
5-
from . import app, ui
7+
from . import ui
68
from ._is_express import is_express_app
79
from ._output import output_args, suspend_display
810
from ._run import wrap_express_app
@@ -16,15 +18,14 @@
1618
"output_args",
1719
"suspend_display",
1820
"wrap_express_app",
19-
"app",
2021
"ui",
2122
"display_body",
2223
)
2324

2425
# Add types to help type checkers
25-
input: Inputs
26-
output: Outputs
27-
session: Session
26+
input: _Inputs
27+
output: _Outputs
28+
session: _Session
2829

2930

3031
# Note that users should use `from shiny.express import input` instead of `from shiny
@@ -50,8 +51,8 @@ def __init__(self):
5051

5152
from .._namespaces import Root
5253

53-
self.input = Inputs({})
54-
self.output = Outputs(cast(Session, self), Root, {}, {})
54+
self.input = _Inputs({})
55+
self.output = _Outputs(cast(_Session, self), Root, {}, {})
5556

5657
# This is needed so that Outputs don't throw an error.
5758
def _is_hidden(self, name: str) -> bool:
@@ -61,15 +62,15 @@ def _is_hidden(self, name: str) -> bool:
6162
_current_mock_session: _MockSession | None = None
6263

6364

64-
def _get_current_session_or_mock() -> Session:
65+
def _get_current_session_or_mock() -> _Session:
6566
from typing import cast
6667

6768
session = _session_utils.get_current_session()
6869
if session is None:
6970
global _current_mock_session
7071
if _current_mock_session is None:
7172
_current_mock_session = _MockSession()
72-
return cast(Session, _current_mock_session)
73+
return cast(_Session, _current_mock_session)
7374

7475
else:
7576
return session

shiny/express/ui/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@
133133
panel_conditional,
134134
panel_fixed,
135135
panel_absolute,
136+
tooltip,
137+
popover,
136138
)
137139

138140
from ._page import (
@@ -269,6 +271,8 @@
269271
"panel_conditional",
270272
"panel_fixed",
271273
"panel_absolute",
274+
"popover",
275+
"tooltip",
272276
# Imports from ._page
273277
"page_opts",
274278
)
@@ -294,11 +298,9 @@
294298
"panel_main", # Deprecated
295299
"panel_sidebar", # Deprecated
296300
"panel_title",
297-
"popover",
298301
"showcase_bottom",
299302
"showcase_left_center",
300303
"showcase_top_right",
301-
"tooltip",
302304
),
303305
# Items from shiny.express.ui that don't have a counterpart in shiny.ui
304306
"shiny.express.ui": ("page_opts",),

shiny/express/ui/_cm_components.py

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,8 +1115,6 @@ def nav_menu(
11151115
# Value boxes
11161116
# ======================================================================================
11171117
def value_box(
1118-
title: TagChild,
1119-
value: TagChild,
11201118
*,
11211119
showcase: Optional[TagChild] = None,
11221120
showcase_layout: ui._valuebox.SHOWCASE_LAYOUTS_STR
@@ -1134,16 +1132,14 @@ def value_box(
11341132
11351133
This function wraps :func:`~shiny.ui.value_box`.
11361134
1137-
An opinionated (:func:`~shiny.ui.card`-powered) box, designed for
1138-
displaying a `value` and `title`. Optionally, a `showcase` can provide for context
1139-
for what the `value` represents (for example, it could hold an icon, or even a
1135+
An opinionated (:func:`~shiny.ui.card`-powered) box, designed for displaying a title
1136+
(the 1st child), value (the 2nd child), and other explanation text (other children,
1137+
if any). Optionally, a `showcase` can provide for context for what the `value`
1138+
represents (for example, it could hold an icon, or even a
11401139
:func:`~shiny.ui.output_plot`).
11411140
11421141
Parameters
11431142
----------
1144-
title,value
1145-
A string, number, or :class:`~htmltools.Tag` child to display as
1146-
the title or value of the value box. The `title` appears above the `value`.
11471143
showcase
11481144
A :class:`~htmltools.Tag` child to showcase (e.g., an icon, a
11491145
:func:`~shiny.ui.output_plot`, etc).
@@ -1184,7 +1180,6 @@ def value_box(
11841180
"""
11851181
return RecallContextManager(
11861182
ui.value_box,
1187-
args=(title, value),
11881183
kwargs=dict(
11891184
showcase=showcase,
11901185
showcase_layout=showcase_layout,
@@ -1400,3 +1395,90 @@ def panel_absolute(
14001395
**kwargs,
14011396
),
14021397
)
1398+
1399+
1400+
# ======================================================================================
1401+
# Tooltips and popovers
1402+
# ======================================================================================
1403+
1404+
1405+
def tooltip(
1406+
*,
1407+
id: Optional[str] = None,
1408+
placement: Literal["auto", "top", "right", "bottom", "left"] = "auto",
1409+
options: Optional[dict[str, object]] = None,
1410+
**kwargs: TagAttrValue,
1411+
) -> RecallContextManager[Tag]:
1412+
"""
1413+
Context manager for a tooltip
1414+
1415+
This function wraps :func:`~shiny.ui.tooltip`.
1416+
1417+
Display additional information when focusing (or hovering over) a UI element.
1418+
1419+
Parameters
1420+
----------
1421+
id
1422+
A character string. Required to reactively respond to the visibility of the
1423+
tooltip (via the `input[id]` value) and/or update the visibility/contents of the
1424+
tooltip.
1425+
placement
1426+
The placement of the tooltip relative to its trigger.
1427+
options
1428+
A list of additional [Bootstrap
1429+
options](https://getbootstrap.com/docs/5.3/components/tooltips/#options).
1430+
"""
1431+
1432+
return RecallContextManager(
1433+
ui.tooltip,
1434+
kwargs=dict(
1435+
id=id,
1436+
placement=placement,
1437+
options=options,
1438+
**kwargs,
1439+
),
1440+
)
1441+
1442+
1443+
def popover(
1444+
*,
1445+
title: Optional[TagChild] = None,
1446+
id: Optional[str] = None,
1447+
placement: Literal["auto", "top", "right", "bottom", "left"] = "auto",
1448+
options: Optional[dict[str, object]] = None,
1449+
**kwargs: TagAttrValue,
1450+
) -> RecallContextManager[Tag]:
1451+
"""
1452+
Context manager for a popover
1453+
1454+
This function wraps :func:`~shiny.ui.popover`.
1455+
1456+
Display additional information when clicking on a UI element (typically a
1457+
button).
1458+
1459+
Parameters
1460+
----------
1461+
title
1462+
A title to display in the popover. Can be a character string or UI elements
1463+
(i.e., tags).
1464+
id
1465+
A character string. Required to reactively respond to the visibility of the
1466+
popover (via the `input[id]` value) and/or update the visibility/contents of the
1467+
popover.
1468+
placement
1469+
The placement of the popover relative to its trigger.
1470+
options
1471+
A list of additional [Bootstrap
1472+
options](https://getbootstrap.com/docs/5.3/components/popovers/#options).
1473+
"""
1474+
1475+
return RecallContextManager(
1476+
ui.popover,
1477+
kwargs=dict(
1478+
title=title,
1479+
id=id,
1480+
placement=placement,
1481+
options=options,
1482+
**kwargs,
1483+
),
1484+
)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pandas
22
plotly
3-
git+https://github.com/posit-dev/py-shiny.git#egg=shiny
43
git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools
54
git+https://github.com/posit-dev/py-shinywidgets.git#egg=shinywidgets
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
2-
"https://rsc.radixu.com/": {
3-
"server_url": "https://rsc.radixu.com/",
4-
"filename": "/Users/karangathani/Documents/GitHub/py-shiny/tests/playwright/deploys/apps/plotly_app",
5-
"app_url": "https://rsc.radixu.com/content/fc82dde5-c4ba-4748-971b-aacc09613faa/",
6-
"app_id": "fc82dde5-c4ba-4748-971b-aacc09613faa",
7-
"app_guid": "fc82dde5-c4ba-4748-971b-aacc09613faa",
2+
"https://api.shinyapps.io": {
3+
"server_url": "https://api.shinyapps.io",
4+
"app_url": "https://testing-apps.shinyapps.io/example_deploy_app_a1/",
5+
"app_id": 10800241,
6+
"app_guid": null,
87
"title": "example_deploy_app_A",
98
"app_mode": "python-shiny",
109
"app_store_version": 1
1110
}
12-
}
11+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
git+https://github.com/posit-dev/py-shiny.git#egg=shiny
21
git+https://github.com/posit-dev/py-htmltools.git#egg=htmltools

0 commit comments

Comments
 (0)