color_picker
The module containing the ColorPicker widget, as well as some helpers it needs.
To test out the widget, run ptg --color
!
ColorPicker
Bases: Container
A simple ColorPicker widget.
This is used to visualize xterm-255 colors. RGB colors are not included here, as it is probably easier to use a web-based picker for those anyways.
Source code in pytermgui/widgets/color_picker.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
selectables_length: int
property
Returns either the button count or 1.
__init__(show_output=True, **attrs)
Initializes a ColorPicker.
Attrs
show_output: Decides whether the output Container should be added. If not set, the widget will only display the PixelMatrix of colors.
Source code in pytermgui/widgets/color_picker.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
get_lines()
Updates self._output and gets widget lines.
Source code in pytermgui/widgets/color_picker.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
handle_mouse(event)
Handles mouse events.
On hover, the widget will display the currently hovered color and some testing text.
On click, it will add a _FadeInButton for the currently hovered color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
MouseEvent
|
The event to handle. |
required |
Source code in pytermgui/widgets/color_picker.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
Joiner
Bases: Container
A Container that stacks widgets horizontally, without filling up the available space.
This works slightly differently to Splitter, as that applies padding & custom widths to any Widget it finds. This works much more simply, and only joins their lines together as they come.
Source code in pytermgui/widgets/color_picker.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
get_lines()
Does magic
Source code in pytermgui/widgets/color_picker.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|