Extend time progress bar displays message

前端 未结 1 1981
时光说笑
时光说笑 2021-01-27 08:08

Is there any way to extend the amount of time a progress bar message is displayed? Say extend it so that it is posted for about 1.5 seconds?

1条回答
  •  北恋
    北恋 (楼主)
    2021-01-27 08:51

    you can use functionality from shinyIncubator package. I set the sleep for 1.5 seconds as per your example, so when the task is finished the message will remain visible for 1.5 seconds.

    rm(list = ls())
    library(shiny)
    library(shinyIncubator)
    
    server <- function(input, output, session) {
      observe({
        if(input$aButton==0) return(NULL)
        withProgress(session, min=1, max=15, expr={
          for(i in 1:10) {
            setProgress(message = 'Finished...',detail = paste0('Number ',i, ':10'))
            Sys.sleep(0.1)
          }
          Sys.sleep(1.5)
        })
      })
    }
    
    ui <- pageWithSidebar(
      headerPanel("Testing"),
      sidebarPanel(actionButton("aButton", "Let's go!"), width=2),
      mainPanel(progressInit())
    )
    
    shinyApp(ui = ui, server = server)
    

    0 讨论(0)
提交回复
热议问题