def _set_card_image(self, box, image, card):
"""Helper function to set card box's background color and image according to
the specified image path."""
#get appropriate color/image
if card.rank == None:
color = DARK_SLATE_BLUE
img_path = FACE_DOWN
else:
color = GHOST_WHITE
img_path = 'art_assets/' + RankStrings[card.rank] + SuitStrings[card.suit] + '.png'
#change background color of widget
box.modify_bg(gtk.STATE_NORMAL, color)
#assign (presumably transparent) image to widget
pixbuf = gtk.gdk.pixbuf_new_from_file(img_path)
scaled_pixbuf = pixbuf.scale_simple(100, 150, gtk.gdk.INTERP_BILINEAR)
image.set_from_pixbuf(scaled_pixbuf)
评论列表
文章目录