通过闪亮的应用程序运行 bat 文件时的进度条

时间:2021-02-25 06:33:39

标签: r batch-file shiny

我正在一个闪亮的应用程序中运行一个带有操作按钮的冗长 .bat 文件。我能够显示进度条,但是,进度条(蓝色)打印了大约 10% 并在那里停留了很长时间。 .bat 文件完成后,进度条会快速移动到 100%。我的问题是:如何在 .bat 文件执行时始终显示进度条移动。我使用的代码如下,但我无法提供我正在运行的 .bat 文件,因为它依赖于其他大文件。

library(shiny)
library(shinyWidgets)
library(ggplot2)
library(shinycssloaders)

ui <- fluidPage(titlePanel(h1("Progress Bar Test",align="center")),
                mainPanel(
                  sidebarPanel(
                    actionButton("buttonId", "Create exe file"))))
                   

server <- function(input, output, session) {
  
  observeEvent(input$buttonId, {
    withProgress(message = 'Creating executable',
                 detail = 'It takes about 30 seconds per year...',{
                   bat <- shell("mybatchfile.bat,wait=TRUE")
                   for (i in 1:length(bat)){
                     incProgress(setProgress(i/length(bat)))             
                     Sys.sleep(2)
                     
                   }
                 }    )}
           )}
  
         # Run the application 
         shinyApp(ui = ui, server = server)

0 个答案:

没有答案