schrodinger.ui.qt.propertyselector module¶
This module provides a PropertySelector GUI class for viewing and selecting properties. Pass the widget a list of properties (via the constructor or the setProperties() method), and then extract properties selected by the user with the getSelected() method.
PropertySelector will display properties without the type (e.g., i_
,
s_
) or owner/family (e.g., mmod_
, sd_
) tags, for readability. The
list of properties displayed can be limited to a single family.
The listbox component can be set to multiple or single selection with the boolean “multi” initialization option.
Copyright Schrodinger, LLC. All rights reserved.
- class schrodinger.ui.qt.propertyselector.PropertySelector(parent, proplist=None, multi=False, presort=True, show_family_menu=True, show_family_name=True, show_alpha_toggle=False, show_filter_field=False, show_aux_listbox=False, move_to_aux=False)¶
Bases:
object
Class for selecting properties, with features to organize by family/owner, filter by name, and/or sort items in the list. The PropertySelector displays a list of property user names, specified as structure.PropertyName objects.
Duplicate user names are distinguished by creating a PropertyName.user_name attribute to with a unique numerical id suffix. e.g. foo, foo-1, foo-2. The name checking is done once, at __init__.
- Variables
propfamiles – Family name keys for a list of structure.PropertyName instances in that group.
displayed_aux_proplist (list) – List of PropertyNames currently displayed in the auxilary listbox, in the order they appear in the list. This is typically a subset of self.proplist.
move_to_aux (bool) – If True, items will be moved from main table to auxilary table when they are selected. If false, they will be duplicated in both tables if selected (default False)
- __init__(parent, proplist=None, multi=False, presort=True, show_family_menu=True, show_family_name=True, show_alpha_toggle=False, show_filter_field=False, show_aux_listbox=False, move_to_aux=False)¶
PropertySelector requires <parent> argument, which should be a Qt Widget into which this frame should be added.
- Parameters
proplist (list(str) or list(structure.PropertyName)) – The order of data name items in the list is the default order of items in the list box.
multi (bool) – True allows selecting multiple properties. Default is False, single item selection.
show_family_menu (bool) – True add property family menu to control visible list items. Default is True.
show_family_name (bool) – True displays the family/owner in parentheses after each name.
show_alpha_toggle (bool) – True displays the alphabetize checkbox toggle.
show_filter_field (bool) – True displays the string filter controls.
show_aux_listbox (bool) – True displays the auxilary listbox, add and remove buttons, and decrement/increment buttons. self.getSelected() returns all the items in the auxilary list box, in the order they appear.
presort (bool) – True orders the properties alphabetically by PropertyName.userName() values.
move_to_aux (bool) – If True, items will be moved from main table to auxilary table when they are selected. If false, they will be duplicated in both tables if selected.
- setupUi(Form)¶
- updateButtonStates()¶
Enable or disable buttons as needed. Called when selection in the tables changes.
- sortAlphabetically(proplist)¶
- sortByInitialOrder(proplist)¶
- alphabetizeNames(is_toggled)¶
Alternate order the displayed list items, either alphabetically or in the native order depending on the value of self.alpha_toggle.
- Parameters
is_toggled (bool) – whether to alphabetize the property names
- checkUserNames()¶
Assigns PropertyName.user_name attributes, for all members in self.proplist. The user_names are unique within the PropertySelector instance.
The user_name strings are typically just the PropertyName.userName(), but may be modified with a numerical suffix to make them unique, or decorated with the family name (which does not garuntee uniqeness, but may make the items easier for the end user to visually group).
- filteringChanged(ignored)¶
Called when value of the family pull-down menu is changed.
- filterProperties(props)¶
Limit the specified list items to those items that match the self.filter_field filter regex and family option menu.
- createFamilies()¶
Create a dictionary of families. PropertyName.family keys for a list of PropertyNames in that family.
- setProperties(proplist, selected_indexes=None)¶
Set the listbox items to the structure.PropertyName.user_name attributes for the PropertyName instances in proplist.
- Parameters
proplist (list of str (data names) or
structure.PropertyName
.) – A list of properties to show.selected_indexes (list of int) – List of indexes of <proplist> that should be initially selected.
- displayProperties(display_list, selected_list=None)¶
Adjust the display state and selection states to specified lists of PropertyName objects. Use only when selection or display state changes. Use setProperties() to use different properties.
- display_list (list)
A list of PropertyName objects to display.
- selected_list (list)
A list of PropertyName objects to select.
- getSelected()¶
Return a list of selected PropertyName objects.
- selectAll()¶
Select all properties in the listbox.
- deselectAll()¶
Clear property selection
- setEnabled(enabled)¶
Enable/disable the PropertySelector widget
- getListboxSelection()¶
- getAuxListboxSelection()¶
- moveAuxSelectedDown()¶
Reorders the displayed list items in self.aux_listbox such that the selected item moves down one rung in the listbox.
- moveAuxSelectedUp()¶
Reorders the displayed list items in self.aux_listbox such that the selected item moves up one rung in the listbox.
- addToAuxListbox()¶
Adds items selected in self.listbox to self.aux_listbox.
- delFromAuxListbox()¶
Removes selected item from self.aux_listbox.
- showAuxProperties(proplist, selected_indexes=None)¶
Display the auxilary listbox items to the structure.PropertyName.user_name attributes for the PropertyName instances in proplist.
- proplist (list)
List of structure.PropertyName instances.
- selected_indexes (list)
List of indexes of <proplist> that should be selected.
- class schrodinger.ui.qt.propertyselector.PropertySelectorMenu(optionmenu, command=None, proplist=None)¶
Bases:
object
Pull-down menu style property selected widget. Used by VSW and Generate Phase DB GUIs
- __init__(optionmenu, command=None, proplist=None)¶
- getSelected()¶
Return PropertyName object for the selected property, or None.
- select(property)¶
Select the specified property. <property> must be a data name string or a PropertyName object.
- setProperties(proplist)¶
Change the list of properties. ‘proplist’ must be a list of PropertyName objects (from the ‘structure.py’ module) or data names
- Parameters
proplist (list of str (data names) or
structure.PropertyName
.) – A list of properties to show.
- clear()¶
- class schrodinger.ui.qt.propertyselector.PropertySelectorDialog(parent, type_filter=None, allow_empty=False, title='Choose Property', accept_text='Select', **kwargs)¶
Bases:
PyQt6.QtWidgets.QDialog
A popup window that allows the user to grab a property. Use chooseFromPT() or chooseFromList() method to execute/show the dialog.
- __init__(parent, type_filter=None, allow_empty=False, title='Choose Property', accept_text='Select', **kwargs)¶
Create a dialog that allows the user to choose property(ies).
- Parameters
parent (QWidget) – the parent widget for this dialog
type_filter (list) – List of property types (first character of property name) to accept. Should be one or more of i, r, b and s.
allow_empty – Whether to allow the user to accept the dialog when no property is selected. By default a warning dialog will appear in such case.
title (str) – Title to use for the dialog window
All keyword arguments supported by PropertySelector class can also be used. For example, set “multi=True” to allow selection of more than one property.
- accept(self)¶
- chooseFromPT()¶
Ask the user to choose from the available Project Table properties.
- :return list of PropertyName objects for properties that were selected.
Returns None if the user cancelled. NOTE: If allow_empty is True, the returned list may be empty.
- chooseFromList(proplist, selected_indexes=None)¶
Ask the user to choose from the given list of properties.
- Parameters
proplist (list of str (data names) or
structure.PropertyName
.) – A list of properties to show.selected_indexes (list of int) – List of indexes of <proplist> that should be initially selected, if desired.
- :return list of PropertyName objects for properties that were selected.
Returns None if the user cancelled. NOTE: If allow_empty is True, the returned list may be empty.
- class schrodinger.ui.qt.propertyselector.MyWindow(*args)¶
Bases:
PyQt6.QtWidgets.QWidget
- __init__(*args)¶
- propsDialog()¶
- class schrodinger.ui.qt.propertyselector.PropertySelectorList(parent=None, proplist=None, multi=False, reorderable=False)¶
Bases:
PyQt6.QtWidgets.QFrame
A widget for showing properties in a QListWidget, and letting the user select a property (or multiple properties) in it. Above the list widget there is a field for searching for properties.
- __init__(parent=None, proplist=None, multi=False, reorderable=False)¶
- Parameters
parent (QObject) – The parent of this widget.
proplist (list) – list of property data names to show.
multi (bool) – Whether multiple properties can be selected. Default is False.
reorderable (bool) – True if items can be dragged around to reorder.
- selectProperty(prop)¶
Selects the given property data name.
- getSelected()¶
Return the list of selected property data names.
- getAllProperties()¶
Return the list of all property data names.
- filterList(filtervalue)¶
Filter the items in the list widget according to the contents of the LineEdit and our filter rules
- Parameters
filtervalue (str) – The current value to filter the ListWidget by
- setProperties(proplist)¶
Add specified properties to the list widget.
- Parameters
proplist (list of str (data names) or
structure.PropertyName
.) – A list of properties to show.
- clear()¶
Removes all items from the ListWidget