{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 环形进度条\n", "\n", "环形进度条,包装了Quasar的[QCircularProgress](https://quasar.dev/vue-components/circular-progress)。\n", "\n", "- `value`: 字段的初始值\n", "- `min`: 最小值(默认:`0.0`)\n", "- `max`: 最大值(默认:`1.0`)\n", "- `size`: 进度圈的大小(默认:`\"xl\"`)\n", "- `show_value`: 是否在中心显示值标签(默认:`True`)\n", "- `color`: 颜色(可以是Quasar、Tailwind或CSS颜色,或者None,默认:`\"primary\"`)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from nicegui import ui\n", "\n", "slider = ui.slider(min=0, max=1, step=0.01, value=0.5)\n", "ui.circular_progress().bind_value_from(slider, 'value')\n", "\n", "# ui.run()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 嵌套元素\n", "\n", "您可以使用 `with` 语句,在环形进度条中放置任何元素,如图标、按钮等。只需确保它适应边界并禁用显示值的默认行为。" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from nicegui import ui\n", "\n", "with ui.row().classes('items-center m-auto'):\n", " with ui.circular_progress(value=0.1, show_value=False) as progress:\n", " ui.button(\n", " icon='star',\n", " on_click=lambda: progress.set_value(progress.value + 0.1)\n", " ).props('flat round')\n", " ui.label('click to increase progress')\n", "\n", "# ui.run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }