documentation indexreference manualfunction index

ui.viewport

Function: ui.viewport (child_size=(None, None), xadjustment=None, yadjustment=None, set_adjustments=True, mousewheel=False, draggable=False, style='viewport', **properties):

Displays a viewport on the screen. A viewport restricts the size of its child, and allows the child to be displayed at an offset.

child_size - The x and y size of the area the child is asked to render. If either is None, defaults to the size of this viewport.

xadjustment - A ui.adjustment that's used for the x-axis of the viewpoert.

yadjustment - A ui.adjustment that's used for the y-axis of the viewport.

set_adjustments - If true, the range and page size of the adjustments will be set by this viewport.

mousewheel - If true, the mouse wheel can be used to scroll the viewport.

draggable - If true, the mouse can be used to drag around the viewport.

If xadjustment or yadjustment are None, adjustments are created automatically. These adjustments are available through the xadjustment and yadjustment properies of a viewport.

In general, viewports are only useful when the xmaximum and ymaximum properties are specified. You'll also want to set clipping=True on the style, although this is part of the default viewport style.

Example

    python hide:
        ui.side(['c', 'b', 'r'], spacing=5)
        vp = ui.viewport(draggable=True, mousewheel=True, xmaximum=400, ymaximum=400, xalign=.5, yalign=.1)
        ui.image("mainmenu.jpg")
        ui.bar(adjustment=vp.xadjustment, style='scrollbar')
        ui.bar(adjustment=vp.yadjustment, style='vscrollbar')
        ui.close()

        ui.textbutton("Dismiss", clicked=ui.returns(True), xalign=0.5, yalign=.9)

        ui.interact()



documentation indexreference manualfunction index