{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 单选按钮\n", "\n", "这个元素是基于Quasar的[QRadio](https://quasar.dev/vue-components/radio)组件。\n", "\n", "选项可以指定为值的列表,或者作为映射值到标签的字典。在操作选项后,调用 `update()` 来更新UI中的选项。\n", "\n", "- `options`:一个列表 `['value1', ...]` 或字典 `{'value1':'label1', ...}` 指定选项\n", "- `value`:初始值\n", "- `on_change`:选择改变时执行的回调函数" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from nicegui import ui\n", "\n", "radio1 = ui.radio([1, 2, 3], value=1).props('inline')\n", "radio2 = ui.radio({1: 'A', 2: 'B', 3: 'C'}).props('inline').bind_value(radio1, 'value')\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 }