gpt4 book ai didi

R Shiny 书签按钮

转载 作者:行者123 更新时间:2023-12-05 02:43:36 24 4
gpt4 key购买 nike

我尝试更改书签按钮弹出窗口中的文本(其他语言),但我不知道该怎么做?有没有人有线索:

library(shiny)
enableBookmarking(store = "url")

ui <- fluidPage(
selectInput("test", label = "option", choices = c("opt A", "opt B"))
, bookmarkButton(label = "")
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

Change the text in the red rounds

最佳答案

正如@Tschösi 所说,这些值是硬编码在函数中的,这给您留下了 2 个选项:

  1. 您创建自己的函数副本,替换硬编码版本。
  2. 您应用一些 Javascript 来动态更改文本。

就我个人而言,我更喜欢选项 2。

这是一个如何做到这一点的工作示例:

library(shiny)
js <- HTML(paste("$(function() {",
"$('body').on('shown.bs.modal', function() {",
"$('.modal-dialog .modal-header > .modal-title').text('Speicher Lesezeichen')",
"$('.modal-dialog .modal-body > span:first').text('Dieser Link speichert den aktuellen Status der Applikation.')",
"$('#shiny-bookmark-copy-text').text('Drücken Sie Ctrl-C um den Link zu kopieren.')",
"$('.modal-dialog .modal-footer > button').text('Schließen')",
"})",
"})",
sep = "\n"))
ui <- function(request) {
fluidPage(
tags$head(tags$script(js, type = "text/javascript")),
tabsetPanel(id = "tabs",
tabPanel("One",
checkboxInput("chk1", "Checkbox 1"),
bookmarkButton(id = "bookmark1")
),
tabPanel("Two",
checkboxInput("chk2", "Checkbox 2"),
bookmarkButton(id = "bookmark2")
)
)
)
}
server <- function(input, output, session) {
# Need to exclude the buttons from themselves being bookmarked
setBookmarkExclude(c("bookmark1", "bookmark2"))

# Trigger bookmarking with either button
observeEvent(input$bookmark1, {
session$doBookmark()
})
observeEvent(input$bookmark2, {
session$doBookmark()
})
}
enableBookmarking(store = "url")
shinyApp(ui, server)

Modal with changed text

关于R Shiny 书签按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66855064/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com