-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add cmap and QSearchableTreeWidget to docs (#199)
- Loading branch information
1 parent
bace50f
commit df2034d
Showing
11 changed files
with
193 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Colormap utilities | ||
|
||
See also: | ||
|
||
- [`superqt.QColormapComboBox`](../widgets/qcolormap.md) | ||
- [`superqt.cmap.CmapCatalogComboBox`](../widgets/colormap_catalog.md) | ||
|
||
::: superqt.cmap.draw_colormap | ||
|
||
::: superqt.cmap.QColormapLineEdit | ||
|
||
::: superqt.cmap.QColormapItemDelegate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# CmapCatalogComboBox | ||
|
||
Searchable `QComboBox` variant that contains the | ||
[entire cmap colormap catalog](https://cmap-docs.readthedocs.io/en/latest/catalog/) | ||
|
||
!!! note "requires cmap" | ||
|
||
This widget uses the [cmap](https://cmap-docs.readthedocs.io/) library | ||
to provide colormaps. You can install it with: | ||
|
||
```shell | ||
# use the `cmap` extra to include colormap support | ||
pip install superqt[cmap] | ||
``` | ||
|
||
You can limit the colormaps shown by setting the `categories` or | ||
`interpolation` keyword arguments. | ||
|
||
```python | ||
from qtpy.QtWidgets import QApplication | ||
|
||
from superqt.cmap import CmapCatalogComboBox | ||
|
||
app = QApplication([]) | ||
|
||
catalog_combo = CmapCatalogComboBox(interpolation="linear") | ||
catalog_combo.setCurrentText("viridis") | ||
catalog_combo.show() | ||
|
||
app.exec() | ||
``` | ||
|
||
{{ show_widget(130) }} | ||
|
||
{{ show_members('superqt.cmap.CmapCatalogComboBox') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# QColorComboBox | ||
|
||
`QComboBox` designed to select from a specific set of colors. | ||
|
||
```python | ||
from qtpy.QtWidgets import QApplication | ||
|
||
from superqt import QColorComboBox | ||
|
||
app = QApplication([]) | ||
|
||
colors = QColorComboBox() | ||
colors.addColors(['red', 'green', 'blue']) | ||
|
||
# show an "Add Color" item that opens a QColorDialog when clicked | ||
colors.setUserColorsAllowed(True) | ||
|
||
# emits a QColor when changed | ||
colors.currentColorChanged.connect(print) | ||
colors.show() | ||
|
||
app.exec_() | ||
``` | ||
|
||
{{ show_widget(100) }} | ||
|
||
{{ show_members('superqt.QColorComboBox') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# QColormapComboBox | ||
|
||
`QComboBox` variant to select from a specific set of colormaps. | ||
|
||
!!! note "requires cmap" | ||
|
||
This widget uses the [cmap](https://cmap-docs.readthedocs.io/) library | ||
to provide colormaps. You can install it with: | ||
|
||
```shell | ||
# use the `cmap` extra to include colormap support | ||
pip install superqt[cmap] | ||
``` | ||
|
||
### ColorMapLike objects | ||
|
||
Colormaps may be specified in a variety of ways, such as by name (string), an iterable of a color/color-like objects, or as | ||
a [`cmap.Colormap`][] instance. See [cmap documentation for details on | ||
all ColormapLike types](https://cmap-docs.readthedocs.io/en/latest/colormaps/#colormaplike-objects) | ||
|
||
### Example | ||
|
||
```python | ||
from cmap import Colormap | ||
from qtpy.QtWidgets import QApplication | ||
|
||
from superqt import QColormapComboBox | ||
|
||
app = QApplication([]) | ||
|
||
cmap_combo = QColormapComboBox() | ||
# see note above about colormap-like objects | ||
# as names from the cmap catalog | ||
cmap_combo.addColormaps(["viridis", "plasma", "magma", "gray"]) | ||
# as a sequence of colors, linearly interpolated | ||
cmap_combo.addColormap(("#0f0", "slateblue", "#F3A003A0")) | ||
# as a `cmap.Colormap` instance with custom name: | ||
cmap_combo.addColormap(Colormap(("green", "white", "orange"), name="MyMap")) | ||
|
||
cmap_combo.show() | ||
app.exec() | ||
``` | ||
|
||
{{ show_widget(200) }} | ||
|
||
### Style Customization | ||
|
||
Note that both the LineEdit and the dropdown can be styled to have the colormap | ||
on the left, or fill the entire width of the widget. | ||
|
||
To make the CombBox label colormap fill the entire width of the widget: | ||
|
||
```python | ||
from superqt.cmap import QColormapLineEdit | ||
cmap_combo.setLineEdit(QColormapLineEdit()) | ||
``` | ||
|
||
To make the CombBox dropdown colormaps fill | ||
less than the entire width of the widget: | ||
|
||
```python | ||
from superqt.cmap import QColormapItemDelegate | ||
delegate = QColormapItemDelegate(fractional_colormap_width=0.33) | ||
cmap_combo.setItemDelegate(delegate) | ||
``` | ||
|
||
{{ show_members('superqt.QColormapComboBox') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# QSearchableTreeWidget | ||
|
||
`QSearchableTreeWidget` combines a | ||
[`QTreeWidget`](https://doc.qt.io/qt-6/qtreewidget.html) and a `QLineEdit` for showing a mapping that can be searched by key. | ||
|
||
This is intended to be used with a read-only mapping and be conveniently created | ||
using `QSearchableTreeWidget.fromData(data)`. If the mapping changes, the | ||
easiest way to update this is by calling `setData`. | ||
|
||
|
||
```python | ||
from qtpy.QtWidgets import QApplication | ||
|
||
from superqt import QSearchableTreeWidget | ||
|
||
app = QApplication([]) | ||
|
||
data = { | ||
"none": None, | ||
"str": "test", | ||
"int": 42, | ||
"list": [2, 3, 5], | ||
"dict": { | ||
"float": 0.5, | ||
"tuple": (22, 99), | ||
"bool": False, | ||
}, | ||
} | ||
tree = QSearchableTreeWidget.fromData(data) | ||
tree.show() | ||
|
||
app.exec_() | ||
``` | ||
|
||
{{ show_widget() }} | ||
|
||
{{ show_members('superqt.QSearchableTreeWidget') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters