Skip to content

pyguiadapter.widgets.colorpicker

控件配置类

ColorPickerConfig dataclass

Bases: CommonParameterWidgetConfig

ColorPicker的配置类

Source code in pyguiadapter\widgets\extend\colorpicker.py
@dataclasses.dataclass(frozen=True)
class ColorPickerConfig(CommonParameterWidgetConfig):
    """ColorPicker的配置类"""

    default_value: Optional[ColorType] = "white"
    """默认颜色值,可以为颜色名称,RGB(或RGBA)字符串,QColor,或颜色元组(列表)"""

    initial_color: ColorType = "white"

    alpha_channel: bool = True
    """是否显示Alpha通道"""

    display_color_name: bool = True
    """颜色标签上是否显示颜色名称"""

    width: Optional[int] = None
    """颜色标签的宽度"""

    height: Optional[int] = 45
    """颜色标签的高度"""

    return_type: Literal["tuple", "QColor", "str"] = "tuple"
    """返回值类型,即从控件获取值时得到的值的类型,可以为“tuple”(返回RGB或RGBA元组),“QColor”(返回QColor对象),
    或“str”(返回RGB或RGBA十六进制字符串)"""

    @classmethod
    def target_widget_class(cls) -> Type["ColorPicker"]:
        return ColorPicker

alpha_channel: bool = True class-attribute instance-attribute

是否显示Alpha通道

default_value: Optional[ColorType] = 'white' class-attribute instance-attribute

默认颜色值,可以为颜色名称,RGB(或RGBA)字符串,QColor,或颜色元组(列表)

display_color_name: bool = True class-attribute instance-attribute

颜色标签上是否显示颜色名称

height: Optional[int] = 45 class-attribute instance-attribute

颜色标签的高度

return_type: Literal['tuple', 'QColor', 'str'] = 'tuple' class-attribute instance-attribute

返回值类型,即从控件获取值时得到的值的类型,可以为“tuple”(返回RGB或RGBA元组),“QColor”(返回QColor对象), 或“str”(返回RGB或RGBA十六进制字符串)

width: Optional[int] = None class-attribute instance-attribute

颜色标签的宽度

控件类

ColorHexPicker

Bases: ColorPicker

ColorTuplePicker

Bases: ColorPicker

对应参数数据类型

  • color_hex_t
  • color_tuple_t