]> Softwares of Agnibho - life.git/commitdiff
Speed adjustment added
authorAgnibho Mondal <mail@agnibho.com>
Sat, 6 Dec 2014 22:09:04 +0000 (03:39 +0530)
committerAgnibho Mondal <mail@agnibho.com>
Sat, 6 Dec 2014 22:09:04 +0000 (03:39 +0530)
Board.py
README.TXT

index 1cd75f995091ffb39478c0fd35d776b91d94eeb9..4c155fb3ac240d50f42387399bba1ad664bffcec 100644 (file)
--- a/Board.py
+++ b/Board.py
@@ -5,6 +5,7 @@ import tkMessageBox
 import Cell
   
 class Board(tk.Frame):
+  TIME=1000
   cells=[]
   SIZE=10
   WIDTH=50
@@ -40,6 +41,9 @@ class Board(tk.Frame):
     self.openbtn=tk.Button(self.toolbar, text="Open", command=self.openfile)
     self.savebtn=tk.Button(self.toolbar, text="Save", command=self.savefile)
     self.aboutbtn=tk.Button(self.toolbar, text="About", command=self.about)
+    self.slider=tk.Scale(self.toolbar, orient="horizontal", command=self.speed, from_=0, to=900, resolution=100, showvalue=0, length=150)
+    self.spdlbl1=tk.Label(self.toolbar, text="Slow")
+    self.spdlbl2=tk.Label(self.toolbar, text="Fast")
     self.statusbar.grid(row=0)
     self.steplbl.grid(row=0, column=0)
     self.poplbl.grid(row=0, column=1)
@@ -53,6 +57,9 @@ class Board(tk.Frame):
     self.savebtn.grid(row=1, column=1)
     self.revertbtn.grid(row=1, column=2)
     self.aboutbtn.grid(row=1, column=3)
+    self.spdlbl1.grid(row=2, column=0)
+    self.slider.grid(row=2, column=1, columnspan=2)
+    self.spdlbl2.grid(row=2, column=3)
     
     for i in range(0, self.WIDTH):
       self.cells.append([])
@@ -64,9 +71,9 @@ class Board(tk.Frame):
     self.cells=[]
     self.WIDTH=width
     self.DEPTH=depth
-    if(self.SIZE*self.WIDTH>self.winfo_screenwidth()-100 or self.SIZE*self.DEPTH>self.winfo_screenheight()-150):
+    if(self.SIZE*self.WIDTH>self.winfo_screenwidth() or self.SIZE*self.DEPTH>self.winfo_screenheight()-150):
       self.SIZE=5
-      self.WIDTH=(self.winfo_screenwidth()-100)/self.SIZE
+      self.WIDTH=self.winfo_screenwidth()/self.SIZE
       self.DEPTH=(self.winfo_screenheight()-150)/self.SIZE
     else:
       self.SIZE=10
@@ -123,7 +130,7 @@ class Board(tk.Frame):
       self.stepnum.set(str("Gen:"+str(self.Num)))
       self.steppop.set("Pop:"+str(self.Pop))
     if(self.mode=="auto"):
-      self.timer=self.after(1000, self.step)
+      self.timer=self.after(self.TIME, self.step)
        
   def auto(self):
     self.startbtn["state"]="disabled"
@@ -132,7 +139,7 @@ class Board(tk.Frame):
     if(self.mode=="edit"):
       self.run()
     self.mode="auto"
-    self.timer=self.after(1000, self.step)
+    self.timer=self.after(self.TIME, self.step)
       
   def pause(self):
     self.startbtn["state"]="normal"
@@ -257,7 +264,7 @@ class Board(tk.Frame):
        self.cells[i][j].revert()
     
   def about(self):
-    tkMessageBox.showinfo("About Life", "Life 1.03 by Agnibho Mondal\nBased on Conway's Game of Life\nhttp://code.agnibho.com/life")
+    tkMessageBox.showinfo("About Life", "Life 1.04 by Agnibho Mondal\nBased on Conway's Game of Life\nhttp://code.agnibho.com/life")
     
   def count(self, i, j):
     z=0
@@ -275,4 +282,7 @@ class Board(tk.Frame):
       y=self.DEPTH-1
     elif(y>=self.DEPTH):
       y=0
-    return self.cells[x][y]
\ No newline at end of file
+    return self.cells[x][y]
+  
+  def speed(self, val):
+    self.TIME=1000-int(val)
\ No newline at end of file
index a622fbecffbc4b41dd91f92bbd9cf8ff748865ab..9032982c7f9ba775a631c10332f4e9d3ed43902e 100644 (file)
@@ -1,5 +1,5 @@
 =============
-Agnibho's Game of Life 1.3.0
+Agnibho's Game of Life 1.4.0
 =============
 
 General Usage Notes
@@ -16,6 +16,7 @@ General Usage Notes
 -Save the current pattern to your computer by clicking <Save> and choosing the target file to save.
 -Click <Revert> to go back to the initial pattern from which the current patterns have been generated.
 -Click <About> to get a short description of the program.
+-Use the slider bar at the bottom to adjust the speed of automatic emulation.
 -The program supports Life 1.06 file format only. To use other file formats you need to convert them to Life 1.06 first.
 
 Program Notes