Web Analytics Made Easy - Statcounter
Skip to content

Spin

Spin call reference

An up/down spinner control. One value at a time is shown. The The valid values are passed in as a list. Default also allows custom values to be typed in by user.

layout = [[sg.Spin([1, 2, 3, 4, 5], size=(10, 1))]]

Events

If enable_events is set to True then an event will be generated when one of the arrow buttons is clicked or the arrow keys are typed on the keyboard.

Values Dictionary

The entry in the Values Dictionary will be the same as the item from the list you used to initialize the element or supplied by calling update. This is the same design as the Listbox Element.

The List of values

The list of items to be chosen from can be many different types, including specific object. In the window, the list is shown using the __str__ method. If you cast a float 3.14 to a string, then it will be "3.14". It will appear of course the same when printed/changed into a string. When the entry is returned in the values dictionary it will have the original float value of 3.14, not the string "3.14".

This allows you to more easily implement applications in multiple languages. The visual representation of the item is decoupled from the identification of that item.

Size

Like the Input element, the height parameter has no meaning because this element is always 1 row high. You can thus also use an integer rather than a tuple. size=20 is the same as size=(20,1) and will produce a Spin element that is 20 characters wide.