From d786a00698ab539038d203727cba1c5e250d0788 Mon Sep 17 00:00:00 2001 From: yinsumirage <2840369457@qq.com> Date: Tue, 19 Nov 2024 17:02:15 +0800 Subject: [PATCH] add gr.datetime a param 'interactive:bool' --- gradio/components/datetime.py | 2 ++ js/datetime/Index.svelte | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gradio/components/datetime.py b/gradio/components/datetime.py index 8fe26e13ea949..eb3e3a01ab08d 100644 --- a/gradio/components/datetime.py +++ b/gradio/components/datetime.py @@ -38,6 +38,7 @@ def __init__( scale: int | None = None, min_width: int = 160, visible: bool = True, + interactive: bool = True, elem_id: str | None = None, elem_classes: list[str] | str | None = None, render: bool = True, @@ -76,6 +77,7 @@ def __init__( ) self.type = type self.include_time = include_time + self.interactive = interactive self.time_format = "%Y-%m-%d %H:%M:%S" if include_time else "%Y-%m-%d" self.timezone = timezone diff --git a/js/datetime/Index.svelte b/js/datetime/Index.svelte index d4630456c06bc..17cd975ad500d 100644 --- a/js/datetime/Index.svelte +++ b/js/datetime/Index.svelte @@ -14,6 +14,7 @@ export let label = "Time"; export let show_label = true; export let info: string | undefined = undefined; + export let interactivate = true; export let elem_id = ""; export let elem_classes: string[] = []; export let visible = true; @@ -68,6 +69,7 @@ $: valid = date_is_valid_format(entered_value); const submit_values = (): void => { + if (!interactivate) return; if (entered_value === value) return; if (!date_is_valid_format(entered_value)) return; old_value = value = entered_value; @@ -87,18 +89,21 @@