当前位置: 首页 > article >正文

241006-Gradio中Chatbot通过CSS自适应调整高度

A. 最终效果

在这里插入图片描述

B. 参考代码

import gradio as gr

CSS = """
.contain { display: flex; flex-direction: column; }
.gradio-container { height: 100vh !important; } 
#component-0 { height: 100%; }
#chatbot { flex-grow: 1; overflow: auto;}
#tab_item_4 { height: calc(100vh - 83px);}
#tab_item_4 .gap { height: 100%; }
#tab_item_4 .gap #chatbot1 { flex-grow: 1; height: auto !important;}

#tab_item_5 { height: calc(100vh - 83px);}
#tab_item_5 .gap { height: 100%; }
#tab_item_5 .gap #chatbot2 { flex-grow: 1; height: auto !important;}
"""

with gr.Blocks(css=CSS) as demo:
    # with gr.Blocks() as demo:
    with gr.Tabs(elem_classes="tab_id_123"):
        with gr.Tab('I want this tap', elem_id="tab_item_4"):
            chatbot = gr.Chatbot(elem_id="chatbot1")
            msg = gr.Textbox()
            clear = gr.Button("Clear")

        with gr.Tab('I want this ta2p', elem_id="tab_item_5"):
            chatbot = gr.Chatbot(elem_id="chatbot2")
            msg = gr.Textbox()
            clear = gr.Button("Clear")


# with gr.Blocks(css=CSS) as demo:
#     chatbot = gr.Chatbot(elem_id="chatbot")
#     msg = gr.Textbox()
#     clear = gr.Button("Clear")

demo.launch(inbrowser=True, server_name='0.0.0.0', server_port=5001)


http://www.kler.cn/news/336708.html

相关文章:

  • 黑名单与ip禁令是同一个东西吗
  • CSS中的class与id
  • VirtulBOX Ubuntu22安装dpdk23.11
  • 计算机网络——p2p
  • Prometheus监控MySQL主从数据库
  • simple c++ 无锁队列
  • Mybatis测试案例
  • 什么是 Angular 的 @HostBinding 注解
  • VMware Tools 安装和配置
  • Python Kivy库学习路线
  • 如何在国内线上开通国外银行帐户
  • 毕设 基于大数据情感分析的网络舆情分析系统(源码+论文)
  • 5.人员管理模块(以及解决运行Bug)——帝可得管理系统
  • 谱减法和维纳滤波的关系
  • SpringCloud学习记录|day1
  • Cocos_鼠标滚轮放缩地图
  • [运维]6.github 本地powershell登录及设置ssh连接
  • Golang 进阶4—— 网络编程
  • ASK, PSK, FSK, DPSK
  • 代码随想录--字符串--重复的子字符串