Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/cca/raw-rev/cda6324b8518
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 04:31:37 2012
Кодировка:

# HG changeset patch
# User is_rusinov
# Date 1291469162 -10800
# Node ID cda6324b8518da50fec1d656b40d3e938a37ccc7
# Parent e56a5e838f37c4ea5d2f0333dcb47cc437891121
+ change_size

diff -r e56a5e838f37 -r cda6324b8518 Interface.py
--- a/Interface.py Sat Dec 04 00:50:50 2010 +0300
+++ b/Interface.py Sat Dec 04 16:26:02 2010 +0300
@@ -2,7 +2,7 @@

class Handlers(object):

- def __init__(self, cell_size, delay, offset_x, offset_y):# cell_size is size of cell, including line width, if there is it
+ 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
self.cell_size = cell_size
self.delay = delay
self.offset_x = offset_x
@@ -11,7 +11,7 @@
self.is_started = False

def start(self):
- if ! self.is_started:
+ if not self.is_started:
self.is_started = True
self.next_step()
self.after_id = canvas.after(self.delay, self.start)
@@ -34,29 +34,44 @@
pass

def close_help_window
-
- def zoom_in(self):
+ pass
+
+ def zoom_in(self, zoom_rate=1):
if self.cell_size < 50:
- self.cell_size ++
+ self.cell_size = self.cell_size + zoom_rate
self.draw()

- def zoom_out(self):
+ def zoom_out(self, zoom_rate=1):
if self.cell_size > 1:
- self.cell_size --
+ self.cell_size = self.cell_size - zoom_rate
self.draw()

- def slower(self, speed_rate):
+ def slower(self, speed_rate=1):
self.delay = self.delay + speed_rate

- def faster(self, speed_rate):
+ def faster(self, speed_rate=1):
if self.speed > speed_rate:
self.delay = self.delay - speed_rate
else:
self.delay = 0

- def change_size(x, y):
- automata.change_size(x, y)
- self.draw()
+ def change_size(dx, dy, position=0):
+ if position < 9:
+ if position == 0 or position == 3 or position == 6:
+ automata.change_size(dx, 3)
+ elif position == 1 or position == 4 or position == 7:
+ automata.change_size(dx / 2, 3)
+ automata.change_size(dx - dx / 2, 1)
+ else
+ automata.change_size(dx, 1)
+ if position == 0 or position == 1 or position == 2:
+ automata.change_size(dy, 0)
+ elif position == 3 or position == 4 or position == 5:
+ automata.change_size(dy / 2, 0)
+ automata.change_size(dy - dy / 2, 2)
+ else
+ automata.change_size(dy, 2)
+ self.draw()

def draw():
pass
@@ -85,34 +100,34 @@
def motion12(self, event):# zoom
pass

- def automata_frame():# show automata_frame
+ def automata_frame(self):# show automata_frame
frame1.pack(side="right", fill="y", expand="no", before=canvas)

- def to_top():# replace choosen state to top
+ def to_top(self):# replace choosen state to top
index = symbols.get(state_list.get("active").split()[1])
state = states[index]
del states[index]
states.insert(0, state)

- def to_bottom():# replace choosen state to botton
+ def to_bottom(self):# replace choosen state to botton
index = symbols.get(state_list.get("active").split()[1])
state = states[index]
del states[index]
states.append(state)

- def upwards():
+ def upwards(self):
index = symbols.get(state_list.get("active").split()[1])
state = states[index]
del states[index]
states.insert(index - 1, state)

- def downwards():
+ def downwards(self):
index = symbols.get(state_list.get("active").split()[1])
state = states[index]
del states[index]
states.insert(index + 1, state)

- def delete_state():# delete choosen state
+ def delete_state(self):# delete choosen state
index = symbols.get(state_list.get("active").split()[1])
del states[index]