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
:add
add_anchor
add_centered
anchor
attention_lost
augment_mouse_event
bg_color
bg_image
border_color
border_width
call_handler
call_parent_handler
cell_margin
cell_rect
click_item
defer_drawing
dismiss
draw
draw_item_and_highlight
draw_over
draw_posthighlight
draw_prehighlight
enable
enabled
fg_color
focus
focus_switch
font
get_cursor
get_focus
get_margin_rect
get_root
get_top_widget
get_visible
global_to_local
has_focus
highlight_color
highlight_style
highlighted
inherited
invalidate
is_gl_container
item_is_selected
key_down
key_up
local_to_global
margin
menu_bar
num_cols
num_rows
parent
parent_resized
present
rect
ref
relative_mode
remove
remove_anchor
resized
scale_bg
scroll_button_color
scroll_button_size
sel_color
sel_width
set_parent
set_size_for_text
value
visible
PaletteView
: