在文本输入框中显示实时

时间:2019-01-16 21:06:09

标签: r date time shiny

我有一个使用Sys.time()作为其值的文本输入框,但是随着正常时间的流逝,它保持静态,我一直在尝试刷新时间以显示一个新值,但这是我唯一的方法能够通过重新启动应用程序来更新时间。

我尝试使用textoutput()和invalidate Later()函数,但是这仅显示可以说出的“滴答声”的当前时间,但仍需要用户输入,这是多余的,因为要点在于它们不输入时间。此输入和其他一些输入最终会通过googlesheets包上传到google表格中。

这是我当前的代码:

Stime <- as.character(format(Sys.time(), "%H:%M", "EST"))

textInput(
          inputId = "Time",
          label = "Today's Time",
          value = Stime)

what it looks like now (via imgur) except it is static

我唯一要做的就是增加时间!任何帮助表示赞赏!

2 个答案:

答案 0 :(得分:0)

从R Shiny网站:

here

from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select


driver = webdriver.Chrome(r"C:\Users\Sumit.Kumar\Desktop\chromedriver_win32\sumit\chromedriver.exe")
#driver.set_page_load_timeout(10)
driver.get("https://trends.google.com/trends/?geo=DE")
driver.maximize_window()


val = "Football"

driver.find_element_by_id("input-254").send_keys(val)

time.sleep(1)
val1 = "Cricket"

driver.find_element_by_xpath("""//*[@id="explorepage-content-header"]/explore-pills/div/button""").send_keys(val1)

答案 1 :(得分:0)

我已对http://shiny.rstudio.com/gallery/current-time.htmlshiny示例进行了稍许修改,以根据要求帮助在textInput框中显示时间:

library(shiny)
ui <- shiny::fluidPage(shiny::uiOutput("ui"))

server <- function(input, output, session) {  
  output$ui <- shiny::renderUI({
    invalidateLater(1000, session)
    shiny::textInput(
      inputId = "time",
      label = "Today's Time",
      value = as.character(format(Sys.time(), "%H:%M", "EST"))
    )
  })
}

shiny::shinyApp(ui = ui, server = server)