我想使用反应值来加载控制 selectizeInput 小部件。我可以使用一个简单的闪亮应用程序来做到这一点,但是当我尝试在模块中重新组织它时,我似乎无法复制它。
在下面的代码中,我有一个带有输入小部件和按钮的简单应用程序。按下按钮后,我希望使用selectizeInput()反应变量中存储的值更新小部件。
library(shiny)
# GLOBAL VAR TO BE LOADED after pressing the button
# -------------
STORED <- reactiveValues(choices = c("a", "b", "c")
, selected = c("c"))
# UI
# -------------
ui <- fixedPage(
wellPanel(
# input widget
selectInput("widget1"
, "label"
,choices = c("WRONG A","WRONG B","WRONG C")
,selected="WRONG A"
)
# update button
, actionButton("plotBtn"
, "update"
, class = "btn-primary")
)
)
# SERVER
# -------------
server <- function(input, output, session) {
observeEvent(input$plotBtn,{
message("update button was …Run Code Online (Sandbox Code Playgroud) 在 jupyter 笔记本中,我有一个 bash jupyter 单元,如下所示:
%%bash
export MYVAR="something"
Run Code Online (Sandbox Code Playgroud)
我想$MYVAR在不同的 python 单元中访问。例如
print(MYVAR)
Run Code Online (Sandbox Code Playgroud)
我希望单元格打印“东西”,但我收到一条 NameError 消息。