Пример #1
0
 def updatebitmap(self, parameters, src1, src2, tmp, dst, dstrgn):
     """Called by the engine when the parameters have changed and the
     destination bitmap has to be recomputed. Also called for other redraw reasons."""
     Qd.CopyBits(src1, dst, self.ltrb, self.ltrb, QuickDraw.srcCopy, dstrgn)
     if self.SHOW_UNIMPLEMENTED_TRANSITION_NAME:
         x0, y0, x1, y1 = self.ltrb
         Qd.MoveTo(x0, y0)
         Qd.LineTo(x1, y1)
         Qd.MoveTo(x0, y1)
         Qd.LineTo(x1, y0)
         Qd.MoveTo(x0, (y0 + y1) / 2)
         Qd.DrawString(
             "%s %s" %
             (self.dict.get('trtype', '???'), self.dict.get('subtype', '')))
Пример #2
0
import Printing
from Carbon import Qd
from Carbon import Fm
from Carbon import Res
# some constants
PostScriptBegin = 190	# Set driver state to PostScript	
PostScriptEnd = 191	# Restore QuickDraw state	
PostScriptHandle = 192	# PostScript data referenced in handle
CHUNK_SIZE = 0x8000 # max size of PicComment
def PostScript(text):
	"""embed text as plain PostScript in print job."""
	handle = Res.Resource('')
	Qd.PicComment(PostScriptBegin, 0, handle)
	while text:
		chunk = text[:CHUNK_SIZE]
		text = text[CHUNK_SIZE:]
		handle.data = chunk
		Qd.PicComment(PostScriptHandle, len(chunk), handle)
	handle.data = ''
	Qd.PicComment(PostScriptEnd, 0, handle)
# create a new print record
printrecord = Printing.NewTPrintRecord()
# open the printer
Printing.PrOpen()
try:
	# initialize print record with default values
	Printing.PrintDefault(printrecord)
	
	# page setup, ok is 0 when user cancelled
	ok = Printing.PrStlDialog(printrecord)