feat(ui): 画面 Tab 刷新机制由自动改为手动
This commit is contained in:
parent
71170e5c0c
commit
2469fc09df
|
@ -1504,6 +1504,7 @@ class KotoneBotUI:
|
|||
def _create_screen_tab(self) -> None:
|
||||
with gr.Tab("画面"):
|
||||
gr.Markdown("## 当前设备画面")
|
||||
refresh_btn = gr.Button("刷新画面", variant="primary")
|
||||
WIDTH = 720 // 3
|
||||
HEIGHT = 1280 // 3
|
||||
last_update_text = gr.Markdown("上次更新时间:无数据")
|
||||
|
@ -1512,14 +1513,14 @@ class KotoneBotUI:
|
|||
def update_screenshot():
|
||||
ctx = ContextStackVars.current()
|
||||
if ctx is None:
|
||||
return [None, last_update_text.value]
|
||||
return [None, "上次更新时间:无上下文数据"]
|
||||
screenshot = ctx._screenshot
|
||||
if screenshot is None:
|
||||
return [None, last_update_text.value]
|
||||
return [None, "上次更新时间:无截图数据"]
|
||||
screenshot = cv2.cvtColor(screenshot, cv2.COLOR_BGR2RGB)
|
||||
return screenshot, f"上次更新时间:{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
||||
|
||||
gr.Timer(0.3).tick(
|
||||
refresh_btn.click(
|
||||
fn=update_screenshot,
|
||||
outputs=[screenshot_display, last_update_text]
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue