mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-07 11:46:51 +08:00
* changes * changes * revert changes * changes * add changeset * notebooks script * changes * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
17 lines
501 B
Python
17 lines
501 B
Python
import gradio as gr
|
|
|
|
with gr.Blocks() as demo:
|
|
cart = gr.State([])
|
|
items_to_add = gr.CheckboxGroup(["Cereal", "Milk", "Orange Juice", "Water"])
|
|
|
|
def add_items(new_items, previous_cart):
|
|
cart = previous_cart + new_items
|
|
return cart
|
|
|
|
gr.Button("Add Items").click(add_items, [items_to_add, cart], cart)
|
|
|
|
cart_size = gr.Number(label="Cart Size")
|
|
gr.Button("Get Cart Size").click(lambda cart: len(cart), cart, cart_size)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch() |