source: __main__.py

Last change on this file was 5ee3950, checked in by Agnibho Mondal <mail@…>, 4 years ago

Added licensing information

  • Property mode set to 100644
File size: 1.7 KB
Line 
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
21import sys
22import Board
23
24width=50
25depth=50
26filename=""
27app=Board.Board()
28app.master.title("Conway's Game of Life - Agnibho.com")
29
30if(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()
43if(width<10 or depth<10):
44  width=50
45  depth=50
46  print "Dimensions must be more than 10x10"
47  sys.exit()
48elif(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
54app.render(width, depth)
55if(len(filename)>0):
56  app.parsefile(filename)
57app.mainloop()
Note: See TracBrowser for help on using the repository browser.