]> Softwares of Agnibho - life.git/blob - __main__.py
Added licensing information
[life.git] / __main__.py
1 #! /usr/bin/python
2
3 # Agnibho's Game of Life - Python implementation of Conway's Game of Life
4 # Copyright (C) 2014 Agnibho Mondal
5
6 # This file is part of Agnibho's Game of Life
7
8 # Agnibho's Game of Life is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12
13 # Agnibho's Game of Life is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with Agnibho's Game of Life. If not, see <http://www.gnu.org/licenses/>.
20
21 import sys
22 import Board
23
24 width=50
25 depth=50
26 filename=""
27 app=Board.Board()
28 app.master.title("Conway's Game of Life - Agnibho.com")
29
30 if(len(sys.argv)>1):
31 if(len(sys.argv)==3):
32 try:
33 width=int(sys.argv[1])
34 depth=int(sys.argv[2])
35 except Exception:
36 print "Dimensions must be integer"
37 sys.exit()
38 elif(len(sys.argv)==2):
39 filename=sys.argv[1]
40 else:
41 print "Argument not recognized"
42 sys.exit()
43 if(width<10 or depth<10):
44 width=50
45 depth=50
46 print "Dimensions must be more than 10x10"
47 sys.exit()
48 elif(width>app.winfo_screenwidth()/10 or depth>(app.winfo_screenheight()-150)/10):
49 width=50
50 depth=50
51 print "Dimensions are too large to fit in the screen. Maximum allowed dimension "+str(app.winfo_screenwidth()/10)+"x"+str((app.winfo_screenheight()-150)/10)
52 sys.exit()
53
54 app.render(width, depth)
55 if(len(filename)>0):
56 app.parsefile(filename)
57 app.mainloop()