Module albow.choices.ImageMultiChoice
Source code
from pygame import Surface
from pygame import Rect
from albow.utils import blit_in_rect
from albow.choices.MultiChoice import MultiChoice
class ImageMultiChoice(MultiChoice):
"""
ImageMultichoice is a Multichoice control that displays its values in the form of images.
"""
highlight_style = 'fill'
sel_color = (255, 192, 19)
margin = 5
def __init__(self, images, values, **kwds):
"""
Initialises the control with the given images and corresponding values.
Args:
images: The images we want displayed
values: The values to return when the image is selected
**kwds:
"""
image0 = images[0]
w, h = image0.get_size()
d = 2 * self.predict(kwds, 'margin')
cell_size = w + d, h + d
#
# Python 3 update
#
super().__init__(cell_size, values, **kwds)
self.images = images
def draw_item(self, surface: Surface, imageIndex: int, rect: Rect):
image = self.images[imageIndex]
blit_in_rect(surface, image, rect, self.align, self.margin)
def draw_prehighlight(self, surf: Surface, theItemNumber: int, theRect: Rect):
color = self.sel_color
surf.fill(color, theRect)
Classes
class ImageMultiChoice (images, values, **kwds)-
ImageMultichoice is a Multichoice control that displays its values in the form of images.
Initialises the control with the given images and corresponding values.
Args
images- The images we want displayed
values- The values to return when the image is selected
**kwds:
Source code
class ImageMultiChoice(MultiChoice): """ ImageMultichoice is a Multichoice control that displays its values in the form of images. """ highlight_style = 'fill' sel_color = (255, 192, 19) margin = 5 def __init__(self, images, values, **kwds): """ Initialises the control with the given images and corresponding values. Args: images: The images we want displayed values: The values to return when the image is selected **kwds: """ image0 = images[0] w, h = image0.get_size() d = 2 * self.predict(kwds, 'margin') cell_size = w + d, h + d # # Python 3 update # super().__init__(cell_size, values, **kwds) self.images = images def draw_item(self, surface: Surface, imageIndex: int, rect: Rect): image = self.images[imageIndex] blit_in_rect(surface, image, rect, self.align, self.margin) def draw_prehighlight(self, surf: Surface, theItemNumber: int, theRect: Rect): color = self.sel_color surf.fill(color, theRect)Ancestors
Methods
def draw_item(self, surface, imageIndex, rect)-
Source code
def draw_item(self, surface: Surface, imageIndex: int, rect: Rect): image = self.images[imageIndex] blit_in_rect(surface, image, rect, self.align, self.margin)
Inherited members
MultiChoice:addadd_anchoradd_centeredanchorattention_lostaugment_mouse_eventbg_colorbg_imageborder_colorborder_widthcall_handlercall_parent_handlercell_margincell_rectclick_itemdefer_drawingdismissdrawdraw_item_and_highlightdraw_overdraw_posthighlightdraw_prehighlightenableenabledfg_colorfocusfocus_switchfontget_cursorget_focusget_margin_rectget_rootget_top_widgetget_visibleglobal_to_localhas_focushighlight_colorhighlight_stylehighlightedinheritedinvalidateis_gl_containeritem_is_selectedkey_downkey_uplocal_to_globalmarginmenu_barnum_colsnum_rowsparentparent_resizedpresentrectrefrelative_moderemoveremove_anchorresizedscale_bgscroll_button_colorscroll_button_sizesel_colorsel_widthset_parentset_size_for_textvaluevisible
PaletteView: