class wpilib.SendableChooser

Bases: SendableChooserBase

The SendableChooser class is a useful tool for presenting a selection of options to the SmartDashboard.

For instance, you may wish to be able to select between multiple autonomous modes. You can do this by putting every possible Command you want to run as an autonomous into a SendableChooser and then put it into the SmartDashboard to have a list of options appear on the laptop. Once autonomous starts, simply ask the SendableChooser what the selected value is.

@tparam T The type of values to be stored @see SmartDashboard

addOption(name: str, object: object) None

Adds the given object to the list of options.

On the SmartDashboard on the desktop, the object will appear as the given name.

  • name – the name of the option

  • object – the option

getSelected() object

Returns a copy of the selected option (a std::weak_ptr<U> if T = std::shared_ptr<U>).

If there is none selected, it will return the default. If there is none selected and no default, then it will return a value-initialized instance. For integer types, this is 0. For container types like std::string, this is an empty string.


The option selected

initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
onChange(param0: Callable[[object], None]) None

Bind a listener that’s called when the selected value changes. Only one listener can be bound. Calling this function will replace the previous listener.


listener – The function to call that accepts the new value

setDefaultOption(name: str, object: object) None

Add the given object to the list of options and marks it as the default.

Functionally, this is very close to AddOption() except that it will use this as the default option if none other is explicitly selected.

  • name – the name of the option

  • object – the option