Skip to content

Example #2 Display an image

CH4MPi edited this page Nov 7, 2021 · 6 revisions
# import the guiflash module
from gambiter import g_guiFlash
from gambiter.flash import COMPONENT_ALIGN, COMPONENT_TYPE

# create an image component
data = {             'image': '../../gui/tankmen/role/big/commander.png',
                     'imageAlt': '../../gui/tankmen/role/big/gunner.png',
                     'alpha': 1.0,
                     'x': 0,
                     'y': 0,
                     'alignX': COMPONENT_ALIGN.LEFT,
                     'alignY': COMPONENT_ALIGN.TOP
        }

g_guiFlash.createComponent('labelAlias', COMPONENT_TYPE.IMAGE, data)

Explanation:

  • image: relative path to the image to display
  • imageAlt: relative path to an alternate image to be displayed if the file defined under ‘image’ cannot be found
  • alpha: float value that set the transparent. 0 means not visible, 1.0 is fully visible
  • x: the x-position on the GUI where the image will be displayed related to the alignX-value.
  • y: the y-position on the GUI where the image will be displayed related to the alignY-value
  • alignX: the X-alignment of the text
  • alignY: the Y-alignment of the text

Clone this wiki locally