• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /macosx-10.9.5/pyobjc-42/pyobjc/pyobjc-framework-Quartz/Examples/Core Graphics/Quartz2DBasics/
1from Cocoa import *
2from CoreFoundation import *
3import AppDrawing
4
5from PyObjCTools import NibClassBuilder
6
7def getURLToExport(suffix):
8    savePanel = NSSavePanel.savePanel()
9
10    initialFileName = u"Quartz2DBasics.%s"%(suffix,)
11
12    if savePanel.runModalForDirectory_file_(None, initialFileName) == NSFileHandlingPanelOKButton:
13        return savePanel.URL()
14
15    return None
16
17class MyAppController (NibClassBuilder.AutoBaseClass):
18    def print_(self, sender):
19        self.theView.print_(sender)
20
21    def exportAsPNG_(self, sender):
22        url = getURLToExport("png")
23        if url:
24            AppDrawing.myExportCGDrawingAsPNG(url, self.theView.currentPrintableCommand())
25
26    def exportAsPDF_(self, sender):
27        url = getURLToExport("pdf")
28        if url:
29            AppDrawing.myCreatePDFDocument(url, self.theView.currentPrintableCommand())
30