documentation index ◦ reference manual ◦ function index

# ui.imagebutton

Function: | ui.imagebutton | (idle_image, hover_image, clicked=None, image_style='image_button_image', **properties):

This creates a button that contains two images. The first is the idle image, which is used when the mouse is not over the image, while the second is the hover image, which is used when the mouse is over the image. If the button is clicked or otherwise selected, then the clicked argument is called. If it returns a value, that value is returned from ui.interact.

idle_image - The file name of the image used when this button is idle (doesn't have the mouse pointer over it, or focus from keyboard or joystick). Must be specified.

hover_image - The file name of the image used when this button is hovered (the mouse pointer is over it, or the user has focused it with keyboard or joystick). Must be specified.

clicked - The function that is called when this button is clicked.

hovered - A function that is called with no arguments when this button is clicked. If it returns a non-None value, then that value is returned from ui.interact.

unhovered - A function that is called with no arguments when this button loses focus.

image_style - The style that is applied to the images that are used as part of the imagebutton.

role - The role this button undertakes. This can be the empty string, or "selected_".

insensitive_image - If specified, the file name of the image used when this button is disabled (clicked is None).

activate_image - If specified, the file name of the image used when this button is activated (the mouse button is being held down over it, or equivalents for keyboard and joystick).

selected_idle_image, selected_hover_image, selected_insensitive_image and selected_activate_image also exist. They are the equivalents of idle_image, hover_image, insensitive_image and activate_image which are used when this button is selected (represents the current state, like the "Save Game" button on the save game screen).

## Example

    python:
        ui.frame(xalign=.5,yalign=.5)
        ui.imagebutton("button.png", "button_hover.png", clicked=ui.returns(1))
        ui.interact()
        # Tip : You can use the same image twice if you don't want any hover effect.
    #

documentation index ◦ reference manual ◦ function index