コード例 #1
0
 def saveAs(self):
     if self.scriptPath is not None:
         doc = self.getPageBotDocument()
         putFile(messageText='Save PDF',
                 title='Save PDF as...',
                 fileName='%s.pdf' % self.scriptName,
                 parentWindow=self.window,
                 resultCallback=self.saveDoCallback)
コード例 #2
0
    def callback(self, sender):
        w = CurrentFontWindow()
        if w:
            f = CurrentFont()
            fileName = None
            if f.path:
                fileName, ext = os.path.splitext(os.path.basename(f.path))
                stamp = datetime.datetime.now().strftime("(%Y%m%d_%H%M%S)")
                fileName = "%s-%s%s" % (fileName, stamp, ext)

            dialogs.putFile(title="Save a Copy as..", fileName=fileName, fileTypes=["ufo"], parentWindow=w.window(), resultCallback=self.saveCopy)
コード例 #3
0
 def saveHangulModuleDataCallback(self, sender):
     data = self.hangulModule.concatenateData()
     path = putFile()
     if not path.endswith(".json"):
         path += ".json"
     with open(path, 'w', encoding='utf-8') as file:
         file.write(json.dumps(data))
コード例 #4
0
 def exportPDFCallback(self, sender):
     path = putFile("pdf")
     self.draw(self.pdf.pages, export=True)
     outputPath = "%s.pdf" % path
     if path.endswith(".pdf"):
         outputPath = "%s.pdf" % path[:-4]
     db.saveImage(outputPath)
コード例 #5
0
    def exportTableCallback(self, sender):
        savingPath = putFile("")
        if savingPath is None:
            return None

        with open(savingPath, 'w') as linksTable:
            for eachRow in self.w.linksList:
                if eachRow['lft'] != '' or eachRow['rgt'] != '':
                    linksTable.write(
                        '{lft}\t{lftActive}\t{servant}\t{rgtActive}\t{rgt}\n'.
                        format(**eachRow))
 def saveMatrix(self, sender):
     pathToSave = putFile(title='Save interpolation matrix', fileName='matrix.txt', fileTypes=['txt'])
     if pathToSave is not None:
         masters = self.masters
         axesGrid = self.axesGrid
         matrixTextValues = []
         for master in masters:
             matrixTextValues.append(':'.join([master.getFlatSpot(), master.getPath()]))
         posSize = self.w.getPosSize()
         matrixTextValues = ['Matrix Interpolation File\n','%s,%s\n'%(axesGrid['horizontal'], axesGrid['vertical']), ','.join([str(value) for value in posSize]),'\n', str(self.currentGlyph),'\n',','.join(matrixTextValues)]
         matrixTextForm = ''.join(matrixTextValues)
         f = open(pathToSave, 'w')
         f.write(matrixTextForm)
コード例 #7
0
    def saveButtonCallback(self, sender):
        statusDict = {
            'kerningWordsDB': self.kerningWordsDB,
            'kerningTextBaseNames': self.kerningTextBaseNames,
            'activeKerningTextBaseName': self.activeKerningTextBaseName,
            'wordsWorkingList': self.wordsWorkingList,
            'wordsDisplayList': self.wordsDisplayList,
            'activeWord': self.activeWord,
            'wordFilter': self.wordFilter}

        kerningStatusPath = putFile(title='Save Kerning Status JSON file',
                                    fileName='kerningStatus.json',
                                    canCreateDirectories=True)

        jsonFile = open(kerningStatusPath, 'w')
        json.dump(statusDict, jsonFile, indent=4)
        jsonFile.write('\n')
        jsonFile.close()
コード例 #8
0
    def __init__(self):
        w, h = 550, 250
        self.view = vanilla.Group((0, 0, w, h))
        self.view.relative = vanilla.CheckBox((0, 3, 300, 22), "Use Relative Paths")
        self.view.info = vanilla.TextBox((0, 33, 300, 22), "Execute on load:")
        self.view.editor = CodeEditor((0, 60, w, h-70))

        view = self.view.getNSView()
        view.setFrame_(((0, 0), (w, h)))

        path = dialogs.putFile("Save RoboFont Project..", fileTypes=["roboFontProject"], accessoryView=view)

        if path:
            data = self.getData(path)

            writePlist(data, path)

            icon = NSImage.alloc().initByReferencingFile_(os.path.join(os.path.dirname(__file__), "roboFontProjectIcon.png"))
            ws = NSWorkspace.sharedWorkspace()
            ws.setIcon_forFile_options_(icon, path, 0)
コード例 #9
0
 def generateCallback(self, sender):
     font = CurrentFont()
     d,f = os.path.split(font.path)
     f = f[:-3] + self.format
     putFile(messageText="Save Font", directory=d, fileName=f, parentWindow=self.w, resultCallback=self.processGenerateCallback)
コード例 #10
0
 def btnRightSaveSetCallback(self, sender):
     filename = putFile(messageText='Save glyphs set file', title='title')
     if filename:
         self.saveSetOfGlyphs(filename=filename, direction='R')
コード例 #11
0
 def save(self, sender):
     if self.pdf:
         fileSavePath = putFile(title="Save Image", fileName="Image.pdf")
         if fileSavePath:
             db.saveImage(fileSavePath)
コード例 #12
0
# See https://github.com/robotools/vanilla/blob/master/Lib/vanilla/dialogs.py
from vanilla.dialogs import getFile, putFile

# Get a gif or png image
filePath = getFile(messageText="Get a file", fileTypes=['gif', 'png'])
print("filePath:")
print(filePath)

# Draw image on canvas (dumb I know)
image(filePath[0], (0, 0))

# Save the file, only allow it to be a PDF or Gif, if no file extension is
# given, defaults to PDF as it's first in the fileTypes list
savePath = putFile(messageText="Select a spot to save a file",
                   fileTypes=['pdf', 'gif'])
print("savePath:")
print(savePath)

saveImage(savePath)
コード例 #13
0
import os
from PIL import Image, ImageChops
import tempfile

from testSupport import compareImages, testDataDir

import drawBot
import sys

if len(sys.argv) == 3:
    root = sys.argv[1]
    dest = sys.argv[2]
else:
    from vanilla import dialogs
    root = dialogs.getFolder()[0]
    dest = dialogs.putFile(["pdf"])

tests = [
    os.path.join(root, filename) for filename in os.listdir(root)
    if os.path.splitext(filename)[-1].lower() == ".png"
]

drawBot.newDrawing()
for path in tests:
    fileName = os.path.basename(path)
    if not fileName.startswith("example_"):
        fileName = "expected_" + fileName

    localPath = os.path.join(testDataDir, fileName)
    if not os.path.exists(localPath):
        continue