Fxcore
Wrapper around the QtCore module for fxgui.
This module provides core functionality and custom classes to enhance the use
of QtCore within the fxgui framework.
Classes:
| Name | Description |
|---|---|
|
A filter model using fuzzy matching based on SequenceMatcher similarity ratios. |
Examples:
Using FXSortFilterProxyModel with a search bar:
>>> from fxgui.fxcore import FXSortFilterProxyModel
>>> proxy = FXSortFilterProxyModel(ratio=0.6)
>>> proxy.setSourceModel(my_model)
>>> search_bar.textChanged.connect(proxy.set_filter_text)
FXSortFilterProxyModel
¶
Bases:
A filter model that uses SequenceMatcher to filter items based on
a similarity ratio. The similarity ratio is a value between 0 and 1,
where 1 indicates a perfect match.
Examples:
Filter a list of items using the FXSortFilterProxyModel
>>> items = ["apple", "banana", "cherry", "date"]
>>> search_bar = QLineEdit()
>>> view = QListView()
>>> model = QStringListModel()
>>> model.setStringList(items)
>>> proxy = FXSortFilterProxyModel()
>>> proxy.setSourceModel(model)
>>> view.setModel(proxy)
>>> search_bar.textChanged.connect(proxy.set_filter_text)
Notes
Base code from Alex Telford: LinkedIn post
Methods:
| Name | Description |
|---|---|
|
Initialize the FXSortFilterProxyModel. |
|
Get the data for a given role and index. |
|
Determine whether a row should be accepted by the filter. |
|
Compare two indices to determine their order. |
|
Set whether to enable color matching. |
|
Set the filter text. |
|
Set the ratio threshold for filtering. |
|
Set whether to show all items regardless of the filter. |
__init__
¶
data
¶
filterAcceptsRow
¶
lessThan
¶
set_color_match
¶
Set whether to enable color matching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Whether to enable color matching. |
required |