Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/cca/diff/082f39cbee45/Interface.py
Дата изменения: Unknown
Дата индексирования: Sun Feb 3 10:49:01 2013
Кодировка:
cca: Interface.py diff

cca

diff Interface.py @ 16:082f39cbee45

little corrections
author Ilia
date Sat, 04 Dec 2010 22:35:30 +0300
parents b9d58d90c534
children d2705c3ee7a7
line diff
     1.1 --- a/Interface.py	Sat Dec 04 22:03:22 2010 +0300
     1.2 +++ b/Interface.py	Sat Dec 04 22:35:30 2010 +0300
     1.3 @@ -1,24 +1,15 @@
     1.4  from Tkinter import *
     1.5  
     1.6 -from State import *
     1.7 -from Automata import *
     1.8 -
     1.9 -
    1.10  class Handlers(object):
    1.11  	
    1.12 -	def __init__(self, cell_size=5, line_width=1 ,delay=10, offset_x=0, offset_y=0):# cell_size is size of cell, including line width, if there is it
    1.13 +	def __init__(self, cell_size=5, delay=10, offset_x=0, offset_y=0):# cell_size is size of cell, including line width, if there is it
    1.14  		self.cell_size = cell_size
    1.15 -		self.line_width = line_width
    1.16  		self.delay = delay
    1.17  		self.offset_x = offset_x
    1.18  		self.offset_y = offset_y
    1.19  		self.after_id = 0
    1.20 -		self.mouse_x = 0
    1.21 -		self.mouse_y = 0
    1.22 -		self.mouse_zoom = 0
    1.23 -		self.zoom_divisor = 10
    1.24  		self.is_started = False
    1.25 -		self.keys = dict()
    1.26 +	
    1.27  	def start(self):
    1.28  		if not self.is_started:
    1.29  			self.is_started = True
    1.30 @@ -42,7 +33,7 @@
    1.31  	def help():
    1.32  		pass
    1.33  	
    1.34 -	def close_help_window():
    1.35 +	def close_help_window
    1.36  		pass
    1.37  	
    1.38  	def zoom_in(self, zoom_rate=1):
    1.39 @@ -71,14 +62,14 @@
    1.40  			elif position == 1 or position == 4 or position == 7:
    1.41  				automata.change_size(dx / 2, 3)
    1.42  				automata.change_size(dx - dx / 2, 1)
    1.43 -			else:
    1.44 +			else 
    1.45  				automata.change_size(dx, 1)
    1.46  			if position == 0 or position == 1 or position == 2:
    1.47  				automata.change_size(dy, 0)
    1.48  			elif position == 3 or position == 4 or position == 5:
    1.49  				automata.change_size(dy / 2, 0)
    1.50  				automata.change_size(dy - dy / 2, 2)
    1.51 -			else:
    1.52 +			else 
    1.53  				automata.change_size(dy, 2)
    1.54  			self.draw()
    1.55  	
    1.56 @@ -86,70 +77,28 @@
    1.57  		pass
    1.58  	
    1.59  	def press1(self, event):# drawer
    1.60 -		column = (event.x - self.offset_x) / (self.cell_size + self.line_width)
    1.61 -		row = (event.y - self.offset_y) / (self.cell_size + self.line_width)
    1.62 -		index = (automata.symbols[automata.field[row][column]] + 1) % len(automata.states)
    1.63 -		automata.field[row][column] = automata.states[index].symbol
    1.64 -		self.draw()
    1.65 +		pass
    1.66  	
    1.67  	def motion1(self, event):# drawer
    1.68 -		column = (event.x - self.offset_x) / (self.cell_size + self.line_width)
    1.69 -		row = (event.y - self.offset_y) / (self.cell_size + self.line_width)
    1.70 -		index = (automata.symbols[automata.field[row][column]] + 1) % len(automata.states)
    1.71 -		automata.field[row][column] = automata.states[index].symbol
    1.72 -		self.draw()
    1.73 +		pass
    1.74  	
    1.75  	def press3(self, event):# drawer
    1.76 -		column = (event.x - self.offset_x) / (self.cell_size + self.line_width)
    1.77 -		row = (event.y - self.offset_y) / (self.cell_size + self.line_width)
    1.78 -		index = (automata.symbols[automata.field[row][column]] + len(automata.states) - 1) % len(automata.states)
    1.79 -		automata.field[row][column] = automata.states[index].symbol
    1.80 -		self.draw()
    1.81 +		pass
    1.82  	
    1.83  	def motion3(self, event):# drawer
    1.84 -		column = (event.x - self.offset_x) / (self.cell_size + self.line_width)
    1.85 -		row = (event.y - self.offset_y) / (self.cell_size + self.line_width)
    1.86 -		index = (automata.symbols[automata.field[row][column]] + len(automata.states) - 1) % len(automata.states)
    1.87 -		automata.field[row][column] = automata.states[index].symbol
    1.88 -		self.draw()
    1.89 +		pass
    1.90  	
    1.91 -	def press1_key(self, event):# drawer
    1.92 -		if keys.has_key(event.char):
    1.93 -			column = (event.x - self.offset_x) / (self.cell_size + self.line_width)
    1.94 -			row = (event.y - self.offset_y) / (self.cell_size + self.line_width)
    1.95 -			automata.field[row][column] = automata.states[keys[event.char]].symbol
    1.96 -			self.draw()
    1.97 +	def press_key1(self, event):# drawer+change_scale (B1+ctrl)
    1.98 +		pass
    1.99  	
   1.100 -	def motion1_key(self, event):# drawer
   1.101 -		if keys.has_key(event.char):
   1.102 -			column = (event.x - self.offset_x) / (self.cell_size + self.line_width)
   1.103 -			row = (event.y - self.offset_y) / (self.cell_size + self.line_width)
   1.104 -			automata.field[row][column] = automata.states[keys[event.char]].symbol
   1.105 -			self.draw()
   1.106 -	
   1.107 -	def press1_ctrl(self, event):# change_scale (B1+ctrl)
   1.108 -		self.mouse_x = event.x
   1.109 -		self.mouse_y = event.y
   1.110 -	
   1.111 -	def motion1_ctrl(self, event):# change_scale (B1+ctrl)
   1.112 -		self.offset_x = event.x - self.mouse_x
   1.113 -		self.offset_y = event.y - self.mouse_y
   1.114 -		self.mouse_x = event.x
   1.115 -		self.mouse_y = event.y
   1.116 -		self.draw()
   1.117 +	def motion_key1(self, event):# drawer+change_scale (B1+ctrl)
   1.118 +		pass
   1.119  	
   1.120  	def press12(self, event):# zoom
   1.121 -		self.mouse_zoom = event.y
   1.122 +		pass
   1.123  	
   1.124  	def motion12(self, event):# zoom
   1.125 -		delta = (event.y - self.mouse_zoom) / self.zoom_divisor
   1.126 -		self.cell_size = self.cell_size + delta
   1.127 -		if self.cell_size > 50:
   1.128 -			self.cell_size = 50
   1.129 -		if self.cell_size < 1:
   1.130 -			self.cell_size = 1
   1.131 -		self.mouse_zoom = event.y
   1.132 -		self.draw()
   1.133 +		pass
   1.134  	
   1.135  	def automata_frame(self):# show automata_frame
   1.136  		automata_frame.pack(side="right", fill="y", expand="no", before=canvas)
   1.137 @@ -187,10 +136,7 @@
   1.138  	
   1.139  	def change():# change chosen state
   1.140  		pass
   1.141 -	def show_size_window(self):
   1.142 -		size_window.deiconify()
   1.143 -	def hide_size_window(self):
   1.144 -		size_window.withdraw()
   1.145 +	
   1.146  
   1.147  
   1.148  root = Tk()
   1.149 @@ -207,7 +153,7 @@
   1.150  symboles = dict()
   1.151  
   1.152  #infoPanel=Frame
   1.153 -automata_frame=Frame(root, background="grey")
   1.154 +automata_frame=Frame(root, background="white")
   1.155  
   1.156  headline_frame=Frame(automata_frame, background="white")
   1.157  head = Label(headline_frame, text= "Automata Panel", font=16)
   1.158 @@ -222,15 +168,15 @@
   1.159  for state in states:
   1.160  	state_list.insert("end", state)
   1.161  state_list.pack(side="top", fill="y")
   1.162 -up = Button(automata_frame, text="Up", state="DISABLED")
   1.163 +up = Button(automata_frame, text="Up", state="disabled")
   1.164  up.config(bg="red")
   1.165 -down = Button(automata_frame, text="Down", state="DISABLED")
   1.166 +down = Button(automata_frame, text="Down", state="disabled")
   1.167  down.config(bg="orange")
   1.168 -to_top = Button(automata_frame, text="To Top", state="DISABLED")
   1.169 +to_top = Button(automata_frame, text="To Top", state="disabled")
   1.170  to_top.config(bg="yellow")
   1.171 -to_bottom = Button(automata_frame, text="To Bottom", state="DISABLED")
   1.172 +to_bottom = Button(automata_frame, text="To Bottom", state="disabled")
   1.173  to_bottom.config(bg="green")
   1.174 -delete = Button(automata_frame, text="Delete", state="DISABLED")
   1.175 +delete = Button(automata_frame, text="Delete", state="disabled")
   1.176  delete.config(bg="cyan")
   1.177  up.pack(side="top", fill="x")
   1.178  down.pack(side="top", fill="x")
   1.179 @@ -290,9 +236,9 @@
   1.180  condition_frame.pack(side="top")
   1.181  
   1.182  
   1.183 -add_state = Button(automata_frame, text="ADD", state="DISABLED")
   1.184 +add_state = Button(automata_frame, text="ADD", state="disabled")
   1.185  add_state.config(bg="blue")
   1.186 -change_state = Button(automata_frame, text="Change", state="DISABLED")
   1.187 +change_state = Button(automata_frame, text="Change", state="disabled")
   1.188  change_state.config(bg="violet")
   1.189  add_state.pack(side="top", fill="x")
   1.190  change_state.pack(side="top", fill="x")
   1.191 @@ -308,7 +254,8 @@
   1.192  size_window.withdraw()
   1.193  size_window.protocol("WM_DELETE_WINDOW", handlers.hide_size_window)
   1.194  Label(size_window, text= "Current size of window:").pack(side="top", fill="x")
   1.195 -Label(size_window, text= "X x Y").pack(side="top", fill="x")
   1.196 +size = Label(size_window, text= str(len(automata.field)) + " x " + str(len(automata.field[0])))
   1.197 +size.pack(side="top", fill="x")
   1.198  Label(size_window, text= "New size:").pack(side="top", fill="x")
   1.199  new_size = Frame(size_window)
   1.200  size_x = Entry(new_size, width=5)