documentation index ◦ reference manual ◦ function index

# ui.adjustment

Function: | ui.adjustment | (range=1, value=0, step=None, page=0, changed=None, adjustable=False, ranged=None):

Adjustment objects are used to represent a numeric value that can vary between 0 and a defined number. They also contain information on the steps the value can be adjusted by.

range is the limit of the range of the value. This may be an integer or a float.

value is the initial value of the adjustment.

step is the size of the steps the value can be adjusted by. The default for this value depends on page and range. If page is set, this defaults to 1/10 page. If range is a float, it defaults to 1/20th of the range, otherwise it defaults to 1 pixel.

page is the size of a page, used when the bar is in paging mode. If not set, defaults to 1/10th of the range.

These four arguments correspond to fields on the adjustment object. The fields can be safely set before anything using the adjustment has been rendered. After that, they should be treated as read-only.

changed is a function that's called when the adjustment is changed. The function is called with one argument, the new value of the adjustment. This should be present for the bar to be adjustable.

adjustable controls whether bars without any changed functions are adjustable. If changed is not None, the bar is always adjustable, and this argument is ignored.

ranged is a function that is called with this adjustment as an argument when the adjustment's range has is set. (new in 6.6.0)

Adjustment objects have one method:

Method: | Adjustment.change | (value):

Call this to set the value of the adjustment to value. This will redraw all displayables affected by this change.

## Example

    init python:
        def store_value(x):
             global value
             value = x

    python hide:
        store.value = 50
        adj = ui.adjustment(100, store.value, changed)

        # These two bars adjust together.
        ui.bar(adjustment=adj, xalign=0, yalign=0)
        ui.bar(adjustment=adj, xalign=1.0, yalign=0)

        # Let the user indicate he's done.
        ui.textbutton("Done.", clicked=ui.returns(True), xalign=0.5, yalign=0.5)

    "The value chosen was %(value)d."

documentation index ◦ reference manual ◦ function index