{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# `Color Picker`\n", "\n", "`Color Picker` 元素是基于Quasar的 [QMenu](https://quasar.dev/vue-components/menu) 和 [QColor](https://quasar.dev/vue-components/color) 组件。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- `on_pick`: 当选择颜色时执行的回调函数\n", "- `value`: 菜单是否已经打开(默认:`False`)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from nicegui import ui\n", "\n", "with ui.button(icon='colorize') as button:\n", " ui.color_picker(on_pick=lambda e: button.style(f'background-color:{e.color}!important'))\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 }