Changeset 8:cda6324b8518
- Timestamp:
- 12/04/10 16:26:02 (5 years ago)
- Branch:
- default
- Children:
- 9:2b99826c4d29, 14:9d820c8401c0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface.py
r7 r8 ˆà 3 3 class Handlers(object):ˆà 4 4 ˆà 5 ˆà def __init__(self, cell_size , delay, offset_x, offset_y):# cell_size is size of cell, including line width, if there is itˆàˆà 5 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ˆà 6 6 self.cell_size = cell_sizeˆà 7 7 self.delay = delayˆà òÀæ òÀæ ˆà 12 12 ˆà 13 13 def start(self):ˆà 14 ˆà if !self.is_started:ˆàˆà 14 if not self.is_started:ˆà 15 15 self.is_started = Trueˆà 16 16 self.next_step()ˆà òÀæ òÀæ ˆà 35 35 ˆà 36 36 def close_help_windowˆà 37 ˆà ˆà 38 ˆà def zoom_in(self):ˆà ˆà 37 passˆà ˆà 38 ˆà ˆà 39 def zoom_in(self, zoom_rate=1):ˆà 39 40 if self.cell_size < 50:ˆà 40 ˆà self.cell_size ++ˆàˆà 41 self.cell_size = self.cell_size + zoom_rateˆà 41 42 self.draw()ˆà 42 43 ˆà 43 ˆà def zoom_out(self ):ˆàˆà 44 def zoom_out(self, zoom_rate=1):ˆà 44 45 if self.cell_size > 1:ˆà 45 ˆà self.cell_size --ˆàˆà 46 self.cell_size = self.cell_size - zoom_rateˆà 46 47 self.draw()ˆà 47 48 ˆà 48 ˆà def slower(self, speed_rate ):ˆàˆà 49 def slower(self, speed_rate=1):ˆà 49 50 self.delay = self.delay + speed_rateˆà 50 51 ˆà 51 ˆà def faster(self, speed_rate ):ˆàˆà 52 def faster(self, speed_rate=1):ˆà 52 53 if self.speed > speed_rate:ˆà 53 54 self.delay = self.delay - speed_rateˆà òÀæ òÀæ ˆà 55 56 self.delay = 0ˆà 56 57 ˆà 57 ˆà def change_size(x, y):ˆà 58 ˆà automata.change_size(x, y)ˆà 59 ˆà self.draw()ˆà ˆà 58 def change_size(dx, dy, position=0):ˆà ˆà 59 if position < 9:ˆà ˆà 60 if position == 0 or position == 3 or position == 6:ˆà ˆà 61 automata.change_size(dx, 3)ˆà ˆà 62 elif position == 1 or position == 4 or position == 7:ˆà ˆà 63 automata.change_size(dx / 2, 3)ˆà ˆà 64 automata.change_size(dx - dx / 2, 1)ˆà ˆà 65 else ˆà ˆà 66 automata.change_size(dx, 1)ˆà ˆà 67 if position == 0 or position == 1 or position == 2:ˆà ˆà 68 automata.change_size(dy, 0)ˆà ˆà 69 elif position == 3 or position == 4 or position == 5:ˆà ˆà 70 automata.change_size(dy / 2, 0)ˆà ˆà 71 automata.change_size(dy - dy / 2, 2)ˆà ˆà 72 else ˆà ˆà 73 automata.change_size(dy, 2)ˆà ˆà 74 self.draw()ˆà 60 75 ˆà 61 76 def draw():ˆà òÀæ òÀæ ˆà 86 101 passˆà 87 102 ˆà 88 ˆà def automata_frame( ):# show automata_frameˆàˆà 103 def automata_frame(self):# show automata_frameˆà 89 104 frame1.pack(side="right", fill="y", expand="no", before=canvas)ˆà 90 105 ˆà 91 ˆà def to_top( ):# replace choosen state to topˆàˆà 106 def to_top(self):# replace choosen state to topˆà 92 107 index = symbols.get(state_list.get("active").split()[1])ˆà 93 108 state = states[index]ˆà òÀæ òÀæ ˆà 95 110 states.insert(0, state)ˆà 96 111 ˆà 97 ˆà def to_bottom( ):# replace choosen state to bottonˆàˆà 112 def to_bottom(self):# replace choosen state to bottonˆà 98 113 index = symbols.get(state_list.get("active").split()[1])ˆà 99 114 state = states[index]ˆà òÀæ òÀæ ˆà 101 116 states.append(state)ˆà 102 117 ˆà 103 ˆà def upwards( ):ˆàˆà 118 def upwards(self):ˆà 104 119 index = symbols.get(state_list.get("active").split()[1])ˆà 105 120 state = states[index]ˆà òÀæ òÀæ ˆà 107 122 states.insert(index - 1, state)ˆà 108 123 ˆà 109 ˆà def downwards( ):ˆàˆà 124 def downwards(self):ˆà 110 125 index = symbols.get(state_list.get("active").split()[1])ˆà 111 126 state = states[index]ˆà òÀæ òÀæ ˆà 113 128 states.insert(index + 1, state)ˆà 114 129 ˆà 115 ˆà def delete_state( ):# delete choosen stateˆàˆà 130 def delete_state(self):# delete choosen stateˆà 116 131 index = symbols.get(state_list.get("active").split()[1])ˆà 117 132 del states[index]ˆà
Note: See TracChangeset
for help on using the changeset viewer.