PyANGGui.GAnyObjectChooser

class GAnyObjectChooser

A widget to select one or many object/s from a particular type.

Details

The selector widget allows the application to ask either for one object ( eOneObject or eOneObjectList ) or for many ( eManyObjects ) from a particular type.

If you ask for one object, use the getObject call to get the selected object (if any, can be NULL). If you ask for many, use the GAnyObjectChooser::getObjects call (if any, the list can be empty).

Example:

GAnyObjectChooser                       widget( gui );
GKCentroidConfiguration         *centroids = nullptr;

widget.setType( gui->getModel()->getType( "GKCentroidConfiguration" ), ChooserMode::eOneObject );
widget.show();
...
centroids = dynamic_cast<GKCentroidConfiguration*>( widget.getObject() );
if( centroids  ){
        ... do something with the selected object ...
}

It is possible to set a filter to control which objects will be added. In the next example only objects with ID lower than the filterData will be considered:

bool myFilter( GKObject * object, void * filterData )
{
        return object->getId() < (int)(filterData);
}

And, to use the filter:

GAnyObjectChooser                       widget( gui );
GKCentroidConfiguration         *centroids = nullptr;

widget.setFilter( myFilter, (void *)10 );
widget.setType( gui->getModel()->getType( "GKCentroidConfiguration" ), ChooserMode::eOneObject );
...
centroids = dynamic_cast<GKCentroidConfiguration*>( widget.getObject() );
if( centroids  ){
        ... do something with the selected object ...
}

Inheritance diagram of PyANGGui.GAnyObjectChooser

Synopsis

Methods

Signals

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

class ChooserMode

Select one or many objects?

__init__([parent=None])
Parameters:

parentQWidget

clear()

Clears the selection

considersEmptyAsNew()
Return type:

bool

See setConsidersEmptyAsNew .

getAvailableTypes()
Return type:

.list of GKType

Returns the available types.

getObject()
Return type:

GKObject

Returns the selected object or None if none was selected.

getSelectedObjects()
Return type:

.std.vectorGKObject

Returns the list of selected objects or an empty list if none was selected.

getType()
Return type:

GKType

Returns the type currently selected

getTypeLabel()
Return type:

str

hideSelectionTools()
insertWidget(index, widget, stretch)
Parameters:
  • index – int

  • widgetQWidget

  • stretch – int

isEmpty()
Return type:

bool

Returns true if there’s no available objects for the specified filter and type.

selectOneOf(options, windowTitle)
Parameters:
  • options – .QSetGKObject

  • windowTitle – str

selectOneOrManyOf(options, windowTitle)
Parameters:
  • options – .QSetGKObject

  • windowTitle – str

selectionChanged(arg__1)
Parameters:

arg__1GKType

setConsidersEmptyAsNew(value)
Parameters:

value – bool

By default the None object is labelled as None. Pass true to label it as New

setFilterText(filterText)
Parameters:

filterText – str

Additionally to setFilter , a text filter can be set. Only objects whose Name/ID/ExtendedID matches this filter will be shown.

setFlat()

Removes the group box border and title

setManyTitle(title)
Parameters:

title – str

Title for the Many object selection box

setOneObjectTitle(title)
Parameters:

title – str

setSelectedObjects(objects)
Parameters:

objects – .list of const GKObject

Sets the list of selected objects (and not the list of _selectable_ objects !).

setType(atype[, amode=GAnyObjectChooser.ChooserMode.eOneObject[, listSubTypes=true]])
Parameters:

Sets the model from where objects will be read and the type of the objects to consider. If only objects of the specified type want to be listed (and not the ones inheriting from it) the listSubTypes should be False.

setTypeLabel(typeLabel)
Parameters:

typeLabel – str

When selecting one object ww list the objects with label with the object’s type. Use this call to * change the label from, for example, GKObject to Originator.

setTypes(amodel, someTypes[, amode=GAnyObjectChooser.ChooserMode.eOneObject[, listSubTypes=true]])
Parameters:
  • amodelGKModel

  • someTypes – list of strings

  • amodeChooserMode

  • listSubTypes – bool

Sets the model from where objects will be read and only some types will be considered. Parameter someTypes must contain the internal type names. If someTypes QStringList is empty, then all possible types available in the model will be considered. If only objects of the specified types want to be listed (and not the ones inheriting from it) the listSubTypesm should be False.

typeChanged()