示例#1
0
	def show_card(self, cardid):
		"""Show a card picture and information"""
		self.hbuttonbox_transform.hide()
		if cardid is not None:
			try:
				self.cardpic.set_from_pixbuf(pics.get(cardid))
			except RuntimeError:
				pass # If there is not picture, continue anyways
			card = cards.get(cardid)
			self._enlarged_card = card
			self.carddetails.set_markup(card.markup())
			if cardid[-1] in ("a", "b"):
				self.hbuttonbox_transform.show()
		else:
			self.cardpic.set_from_pixbuf(pics.get("deckmaster"))
示例#2
0
def export(filename, cardlist, papersize=A4):
	surface = cairo.PDFSurface(filename, *papersize)
	cr = cairo.Context(surface)
	for i in range(len(cardlist)):
		card = cardlist[i]
		
		# Get card picture
		pixbuf = pics.get(card.id)
		picsurface, w, h = pics.surface_from_pixbuf(pixbuf)
		
		# Translate and scale
		border_x = (papersize[0] - 3 * _cardsize[0]) / 2
		border_y = (papersize[1] - 3 * _cardsize[1]) / 2
		cr.save()
		cr.translate(border_x + (i % 3) * _cardsize[0],
			border_y + (i % 9 / 3) * _cardsize[1])
		cr.scale(_cardsize[0] / float(w), _cardsize[1] / float(h))
		
		# Draw
		cr.set_source_surface(picsurface)
		cr.paint()
		cr.restore()
		
		if i % 9 == 8:
			cr.show_page() # new page
	surface.finish()
示例#3
0
	def show_enlarged_card(self, cardid=None, flipped=False):
		"""Show the large version of a card"""
		if cardid is None:
			if self.enlarged_card is not None:
				self.repaint_enlarged_card()
				self.enlarged_card = None
				self.enlarged_card_last_pos = None
		else:
			self.repaint_enlarged_card()
			cardpic = pics.surface_from_pixbuf(pics.get(cardid))[0]
			self.enlarged_card = cardpic, flipped
			self.enlarged_card_last_pos = self._get_enlarged_card_pos()
			self.repaint_enlarged_card()