FilterSortWidgetTable
- class pcdswidgets.table.FilterSortWidgetTable(*args, **kwargs)[source]
Displays repeated widgets that are sortable and filterable.
This will allow you to sort or filter based on macros and based on the values in each pydm widget.
- activate_filter(active: bool, filter_name: str) None[source]
Activate or deactivate a filter by name.
- Parameters:
active (bool) – True if we want to activate a filter, False if we want to deactivate it.
filter_name (str) – The name associated with the filter, chosen when we add the filter to the table.
Distribute the context menu to child widgets.
This makes it so you can right click to configure the table from within any of the contained widgets.
- add_filter(filter_name: str, filter_func: Callable[[dict[str, Any]], bool], active: bool = True) None[source]
Add a new visibility filter to the table.
Filters are functions with the following signature:
filt(values: dict[str, Any]) -> boolWhere values is the output from get_row_values, and the boolean return value is True if the row should be displayed. If we have multiple filters, we need all of them to be True to display the row.- Parameters:
filter_name (str) – A name assigned to the filter to help us keep track of it.
filter_func (func) – A callable with the correct signature.
active (bool, optional.) – True if we want the filter to start as active. An inactive filter does not act on the table until the user requests it from the right-click context menu. Defaults to True.
- add_row(macros: dict[str, str]) None[source]
Adds a single row to the table.
Each row will be created from the same UI file template. The macros used must have the same keys as all the previously added rows, or else the table will not work correctly.
- Parameters:
macros (dict of str) – The macro substitutions for the UI file. These must be strings because we’re effectively substituting them into the file’s text.
- channels() list[PyDMChannel][source]
Tell PyDM about our table channels so it knows to close them at exit.
- get_row_values(row: int) dict[str, Any][source]
Get the current values for a specific numbered row of the table.
- Parameters:
row (int) – The row index to inspect. 0 is the current top row.
- Returns:
values – A mapping from str to value for each named widget in the template that has a PyDM channel. There is one additional special str, which is the ‘connected’ str, which is True if all channels are connected.
- Return type:
dict
- handle_item_changed(row: int, col: int) None[source]
Slot that is run when any element in the table changes.
Currently, this updates the filters for the row that changed.
sort_table wrapped to recieve the checked bool from a signal.
Ignore the checked boolean.
- remove_filter(filter_name: str) None[source]
Remove a specific named visibility filter from the table.
This is a filter that was previously added using add_filter.
- Parameters:
filter_name (str) – A name assigned to the filter to help us keep track of it.
- set_macros(macros_list: list[dict[str, str]]) None[source]
Change the PyDM macros we use to load the table widgets.
This causes the table to be rebuilt.
- Parameters:
macros_list (list of dict) – A list where each element is a dictionary that defines the macros to pass in to one instance of the repeated widget. All dicts must have the same keys or this will not work properly.
- sort_table(header: str, ascending: bool) None[source]
Rearrange the ordering of the table based on any of the value fields.
- Parameters:
header (str) – The name of any of the value fields to use to sort on. Valid headers are ‘index’, which is the original sort order, strings that match the macro keys, and strings that match widget names in the template.
ascending (bool) – If True, we’ll sort in ascending order. If False, we’ll sort in descending order.