Example #1
0
	def export( self ):
		"Export the canvas as a postscript file."
		postscriptFileName = gcodec.getFilePathWithUnderscoredBasename( self.skein.fileName, self.suffix )
		boundingBox = self.canvas.bbox( preferences.Tkinter.ALL ) # tuple (w, n, e, s)
		boxW = boundingBox[ 0 ]
		boxN = boundingBox[ 1 ]
		boxWidth = boundingBox[ 2 ] - boxW
		boxHeight = boundingBox[ 3 ] - boxN
		print( 'Exported postscript file saved as ' + postscriptFileName )
		self.canvas.postscript( file = postscriptFileName, height = boxHeight, width = boxWidth, pageheight = boxHeight, pagewidth = boxWidth, x = boxW, y = boxN )
		fileExtension = self.tableauPreferences.exportFileExtension.value
		postscriptProgram = self.tableauPreferences.exportPostscriptProgram.value
		if postscriptProgram == '':
			return
		postscriptFilePath = '"' + os.path.normpath( postscriptFileName ) + '"' # " to send in file name with spaces
		shellCommand = postscriptProgram + ' ' + postscriptFilePath
		print( '' )
		if fileExtension == '':
			print( 'Sending the shell command:' )
			print( shellCommand )
			commandResult = os.system( shellCommand )
			if commandResult != 0:
				print( 'It may be that the system could not find the %s program.' % postscriptProgram )
				print( 'If so, try installing the %s program or look for another one, like the Gnu Image Manipulation Program (Gimp) which can be found at:' % postscriptProgram )
				print( 'http://www.gimp.org/' )
			return
		convertedFileName = gcodec.getFilePathWithUnderscoredBasename( postscriptFilePath, '.' + fileExtension + '"' )
		shellCommand += ' ' + convertedFileName
		print( 'Sending the shell command:' )
		print( shellCommand )
		commandResult = os.system( shellCommand )
		if commandResult != 0:
			print( 'The %s program could not convert the postscript to the %s file format.' % ( postscriptProgram, fileExtension ) )
			print( 'Try installing the %s program or look for another one, like Image Magick which can be found at:' % postscriptProgram )
			print( 'http://www.imagemagick.org/script/index.php' )
Example #2
0
 def execute(self):
     "Convert to postscript button has been clicked."
     "Export the canvas as a postscript file."
     postscriptFileName = gcodec.getFilePathWithUnderscoredBasename(
         self.fileName, self.suffix)
     boundingBox = self.canvas.bbox(
         settings.Tkinter.ALL)  # tuple (w, n, e, s)
     boxW = boundingBox[0]
     boxN = boundingBox[1]
     boxWidth = boundingBox[2] - boxW
     boxHeight = boundingBox[3] - boxN
     print('Exported postscript file saved as ' + postscriptFileName)
     self.canvas.postscript(file=postscriptFileName,
                            height=boxHeight,
                            width=boxWidth,
                            pageheight=boxHeight,
                            pagewidth=boxWidth,
                            x=boxW,
                            y=boxN)
     fileExtension = self.fileExtension.value
     postscriptProgram = self.postscriptProgram.value
     if postscriptProgram == '':
         return
     postscriptFilePath = '"' + os.path.normpath(
         postscriptFileName) + '"'  # " to send in file name with spaces
     shellCommand = postscriptProgram + ' ' + postscriptFilePath
     print('')
     if fileExtension == '':
         print('Sending the shell command:')
         print(shellCommand)
         commandResult = os.system(shellCommand)
         if commandResult != 0:
             print(
                 'It may be that the system could not find the %s program.'
                 % postscriptProgram)
             print(
                 'If so, try installing the %s program or look for another one, like the Gnu Image Manipulation Program (Gimp) which can be found at:'
                 % postscriptProgram)
             print('http://www.gimp.org/')
         return
     convertedFileName = gcodec.getFilePathWithUnderscoredBasename(
         postscriptFilePath, '.' + fileExtension + '"')
     shellCommand += ' ' + convertedFileName
     print('Sending the shell command:')
     print(shellCommand)
     commandResult = os.system(shellCommand)
     if commandResult != 0:
         print(
             'The %s program could not convert the postscript to the %s file format.'
             % (postscriptProgram, fileExtension))
         print(
             'Try installing the %s program or look for another one, like Image Magick which can be found at:'
             % postscriptProgram)
         print('http://www.imagemagick.org/script/index.php')
Example #3
0
	def execute( self ):
		"Export the canvas as an svg file."
		svgFileName = gcodec.getFilePathWithUnderscoredBasename( self.fileName, self.suffix )
		boundingBox = self.canvas.bbox( settings.Tkinter.ALL ) # tuple (w, n, e, s)
		self.boxW = boundingBox[ 0 ]
		self.boxN = boundingBox[ 1 ]
		boxWidth = boundingBox[ 2 ] - self.boxW
		boxHeight = boundingBox[ 3 ] - self.boxN
		print( 'Exported svg file saved as ' + svgFileName )
		svgTemplateText = gcodec.getFileTextInFileDirectory( settings.__file__, 'svg_canvas.template' )
		output = cStringIO.StringIO()
		lines = gcodec.getTextLines( svgTemplateText )
		firstWordTable = {}
		firstWordTable[ 'height="999px"' ] = '		height="%spx"' % int( round( boxHeight ) )
		firstWordTable[ '<!--replaceLineWith_coloredLines-->' ] = self.getCanvasLinesOutput()
		firstWordTable[ 'replaceLineWithTitle' ] = gcodec.getSummarizedFileName( self.fileName )
		firstWordTable[ 'width="999px"' ] = '		width="%spx"' % int( round( boxWidth ) )
		for line in lines:
			parseLineReplace( firstWordTable, line, output )
		gcodec.writeFileText( svgFileName, output.getvalue() )
		fileExtension = self.fileExtension.value
		svgProgram = self.svgProgram.value
		if svgProgram == '':
			return
		if svgProgram == 'webbrowser':
			settings.openWebPage( svgFileName )
			return
		svgFilePath = '"' + os.path.normpath( svgFileName ) + '"' # " to send in file name with spaces
		shellCommand = svgProgram + ' ' + svgFilePath
		print( '' )
		if fileExtension == '':
			print( 'Sending the shell command:' )
			print( shellCommand )
			commandResult = os.system( shellCommand )
			if commandResult != 0:
				print( 'It may be that the system could not find the %s program.' % svgProgram )
				print( 'If so, try installing the %s program or look for another one, like the Gnu Image Manipulation Program (Gimp) which can be found at:' % svgProgram )
				print( 'http://www.gimp.org/' )
			return
		convertedFileName = gcodec.getFilePathWithUnderscoredBasename( svgFilePath, '.' + fileExtension + '"' )
		shellCommand += ' ' + convertedFileName
		print( 'Sending the shell command:' )
		print( shellCommand )
		commandResult = os.system( shellCommand )
		if commandResult != 0:
			print( 'The %s program could not convert the svg to the %s file format.' % ( svgProgram, fileExtension ) )
			print( 'Try installing the %s program or look for another one, like Image Magick which can be found at:' % svgProgram )
			print( 'http://www.imagemagick.org/script/index.php' )
Example #4
0
def writeOutput(fileName=""):
    "Carve a GNU Triangulated Surface file."
    startTime = time.time()
    print("File " + gcodec.getSummarizedFilename(fileName) + " is being carved.")
    carveGcode = getCraftedText(fileName)
    if carveGcode == "":
        return
    suffixFilename = gcodec.getFilePathWithUnderscoredBasename(fileName, "_carve.svg")
    gcodec.writeFileText(suffixFilename, carveGcode)
    print("The carved file is saved as " + gcodec.getSummarizedFilename(suffixFilename))
    print("It took " + str(int(round(time.time() - startTime))) + " seconds to carve the file.")
    preferences.openWebPage(suffixFilename)
Example #5
0
def writeOutput( fileName = '' ):
	"Carve a GNU Triangulated Surface file."
	startTime = time.time()
	print( 'File ' + gcodec.getSummarizedFileName( fileName ) + ' is being carved.' )
	carveGcode = getCraftedText( fileName )
	if carveGcode == '':
		return
	suffixFileName = gcodec.getFilePathWithUnderscoredBasename( fileName, '_carve.svg' )
	gcodec.writeFileText( suffixFileName, carveGcode )
	print( 'The carved file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to carve the file.' )
	settings.openWebPage( suffixFileName )
Example #6
0
def writeOutput(fileName=''):
    "Carve a GNU Triangulated Surface file."
    startTime = time.time()
    print('File ' + gcodec.getSummarizedFileName(fileName) +
          ' is being carved.')
    carveGcode = getCraftedText(fileName)
    if carveGcode == '':
        return
    suffixFileName = gcodec.getFilePathWithUnderscoredBasename(
        fileName, '_carve.svg')
    gcodec.writeFileText(suffixFileName, carveGcode)
    print('The carved file is saved as ' +
          gcodec.getSummarizedFileName(suffixFileName))
    print('It took ' + str(int(round(time.time() - startTime))) +
          ' seconds to carve the file.')
    settings.openWebPage(suffixFileName)