Created
March 1, 2010 05:53
-
-
Save jfhbrook/318113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
''' | |
generates a pdf with a bunch of randomized bingo cards using entries from bingo.txt | |
Having issues getting formatting to work exactly how I want, though, | |
and, of course, it'd be a lot more useful if it could run on windows without | |
depending on latex and tikz and everything else... >_< | |
making it a webapp would be nice, but that sounds like a lot of work. :P | |
''' | |
gamestream = open('bingo.txt', 'r') | |
gametitle=gamestream.readline() | |
events=gamestream.readlines() | |
pages=5 ## pages to print | |
print r'\documentclass[10pt, letterpaper]{article}' | |
print r'\usepackage{tikz}' | |
print r'\usepackage{fullpage}' | |
print r'\begin{document}' | |
print r'\pagestyle{empty}' | |
print r'\begin{center}' | |
for i in range(pages): | |
random.shuffle(events) | |
fields=events[0:12]+[r'YOU\\ SHOWED\\ UP']+events[12:24] | |
print r'\Huge %(title)s \normalsize' % {'title': gametitle} | |
print r'' | |
print r'\bigskip' | |
print r'' | |
print r'\begin{tikzpicture}' | |
print r'[bsquare/.style={rectangle,draw,minimum size=1.25in,text width=1.0in}]' | |
for x in xrange(5): | |
for y in xrange(5): | |
print '\\node [bsquare] at (%(x)2f in,%(y)2f in) {%(event)s };' % \ | |
{'x':x*1.25,'y':y*1.25,'event': fields[5*x+y]} | |
print r'\end{tikzpicture}' | |
print '' | |
print r'\pagebreak' | |
print '' | |
print r'\end{center}' | |
print r'\end{document}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment