else/Asciix/text_to_ps.py

30 lines
844 B
Python
Raw Normal View History

2015-03-06 08:29:43 +00:00
import os
from PIL import Image
import subprocess
import tkinter
filename_noext = input(']>> ')
2015-03-16 02:55:13 +00:00
filename_text = filename_noext.replace('.txt', '')
2015-03-06 08:29:43 +00:00
filename_text = filename_noext + '.txt'
filename_ghost = filename_noext + '_render.ps'
filea = open(filename_text, 'r')
lines = filea.read()
lines_split = lines.split('\n')
lines_height = len(lines_split)
lines_width = len(lines_split[0])
print('%d x %d' % (lines_width, lines_height))
lines_height *= 17
lines_width *= 7
filea.close()
t = tkinter.Tk()
c = tkinter.Canvas(t, width=lines_width, height=lines_height)
c.pack()
c.create_text(0, 0, text=lines, anchor="nw", font=("Courier New", 12))
print('Writing Postscript')
c.postscript(file=filename_ghost, width=lines_width, height=lines_height)
t.destroy()
print('Writing PNG')
2015-03-16 02:55:13 +00:00
subprocess.Popen('PNGCREATOR.bat', shell=True, cwd=os.getcwd())