Changeset 52:6630f82e4675
- Timestamp:
- 12/06/10 16:02:42 (5 years ago)
- Branch:
- default
- Parents:
- 50:9cbbff6dbbaf (diff), 51:f411a1e0a5cb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface.py
r50 r52 ˆà 14 14 self.offset_y = offset_yˆà 15 15 self.after_id = 0ˆà 16 ˆà self.mouse_x = 0ˆà 17 ˆà self.mouse_y = 0ˆà ˆà 16 self.mouse_col=0ˆà ˆà 17 self.mouse_row=0ˆà ˆà 18 self.mouse_offset_x = 0ˆà ˆà 19 self.mouse_offset_y = 0ˆà 18 20 self.mouse_zoom = 0ˆà 19 21 self.zoom_divisor = 10ˆà òÀæ òÀæ ˆà 116 118 index = (automata.symbols[automata.field[row][column]] + 1) % len(automata.states)ˆà 117 119 automata.field[row][column] = automata.states[index].symbolˆà 118 ˆà self.draw ()ˆàˆà 120 self.draw_cell(tuple([column, row]))ˆà 119 121 ˆà 120 122 def motion1(self, event):# drawerˆà òÀæ òÀæ ˆà 123 125 index = (automata.symbols[automata.field[row][column]] + 1) % len(automata.states)ˆà 124 126 automata.field[row][column] = automata.states[index].symbolˆà 125 ˆà self.draw ()ˆàˆà 127 self.draw_cell(tuple([column, row]))ˆà 126 128 ˆà 127 129 def press3(self, event):# drawerˆà òÀæ òÀæ ˆà 130 132 index = (automata.symbols[automata.field[row][column]] + len(automata.states) - 1) % len(automata.states)ˆà 131 133 automata.field[row][column] = automata.states[index].symbolˆà 132 ˆà self.draw ()ˆàˆà 134 self.draw_cell(tuple([column, row]))ˆà 133 135 ˆà 134 136 def motion3(self, event):# drawerˆà òÀæ òÀæ ˆà 137 139 index = (automata.symbols[automata.field[row][column]] + len(automata.states) - 1) % len(automata.states)ˆà 138 140 automata.field[row][column] = automata.states[index].symbolˆà 139 ˆà self.draw ()ˆàˆà 141 self.draw_cell(tuple([column, row]))ˆà 140 142 ˆà 141 143 def press1_key(self, event):# drawerˆà òÀæ òÀæ ˆà 144 146 row = (event.y - self.offset_y * (self.cell_size + self.line_width)) / (self.cell_size + self.line_width)ˆà 145 147 automata.field[row][column] = automata.states[keys[event.char]].symbolˆà 146 ˆà self.draw ()ˆàˆà 148 self.draw_cell(tuple([column, row]))ˆà 147 149 ˆà 148 150 def motion1_key(self, event):# drawerˆà òÀæ òÀæ ˆà 151 153 row = (event.y - self.offset_y * (self.cell_size + self.line_width)) / (self.cell_size + self.line_width)ˆà 152 154 automata.field[row][column] = automata.states[keys[event.char]].symbolˆà 153 ˆà self.draw ()ˆàˆà 155 self.draw_cell(tuple([column, row]))ˆà 154 156 ˆà 155 157 def press1_ctrl(self, event):# change_offset (B1+ctrl)ˆà 156 ˆà self.mouse_ x = event.xˆà157 ˆà self.mouse_ y = event.yˆàˆà 158 self.mouse_offset_x = event.xˆà ˆà 159 self.mouse_offset_y = event.yˆà 158 160 ˆà 159 161 def motion1_ctrl(self, event):# change_offset (B1+ctrl)ˆà 160 ˆà self.offset_x = (event.x - self.mouse_ x) / (self.cell_size + self.line_width)ˆà161 ˆà self.offset_y = (event.y - self.mouse_ y) / (self.cell_size + self.line_width)ˆà162 ˆà self.mouse_ x = event.xˆà163 ˆà self.mouse_ y = event.yˆàˆà 162 self.offset_x = (event.x - self.mouse_offset_x) / (self.cell_size + self.line_width)ˆà ˆà 163 self.offset_y = (event.y - self.mouse_offset_y) / (self.cell_size + self.line_width)ˆà ˆà 164 self.mouse_offset_x = event.xˆà ˆà 165 self.mouse_offset_y = event.yˆà 164 166 self.draw()ˆà 165 167 ˆà òÀæ òÀæ ˆà 181 183 ˆà 182 184 def to_top(self):# replace choosen state to topˆà 183 ˆà index = automata.symbols.get(state_list.get("active").split()[ 1])ˆàˆà 185 index = automata.symbols.get(state_list.get("active").split()[0])ˆà 184 186 state = automata.states[index]ˆà 185 187 del automata.states[index]ˆà òÀæ òÀæ ˆà 187 189 ˆà 188 190 def to_bottom(self):# replace choosen state to bottonˆà 189 ˆà index = automata.symbols.get(state_list.get("active").split()[ 1])ˆàˆà 191 index = automata.symbols.get(state_list.get("active").split()[0])ˆà 190 192 state = automata.states[index]ˆà 191 193 del automata.states[index]ˆà òÀæ òÀæ ˆà 193 195 ˆà 194 196 def upwards(self):ˆà 195 ˆà index = automata.symbols.get(state_list.get("active").split()[ 1])ˆàˆà 197 index = automata.symbols.get(state_list.get("active").split()[0])ˆà 196 198 state = automata.states[index]ˆà 197 199 del automata.states[index]ˆà òÀæ òÀæ ˆà 199 201 ˆà 200 202 def downwards(self):ˆà 201 ˆà index = automata.symbols.get(state_list.get("active").split()[ 1])ˆàˆà 203 index = automata.symbols.get(state_list.get("active").split()[0])ˆà 202 204 state = automata.states[index]ˆà 203 205 del automata.states[index]ˆà òÀæ òÀæ ˆà 205 207 ˆà 206 208 def delete_state(self):# delete choosen stateˆà 207 ˆà index = automata.symbols.get(state_list.get("active").split()[ 1])ˆàˆà 209 index = automata.symbols.get(state_list.get("active").split()[0])ˆà 208 210 del automata.states[index]ˆà 209 211 ˆà 210 212 def add(self):# add new stateˆà 211 ˆà passˆà212 213 name = state_name.get()ˆà 213 214 symbol = state_symbol.get()ˆà -
Interface.py
r51 r52 ˆà 87 87 self.draw()ˆà 88 88 ˆà 89 ˆà def draw_ step(self):ˆà90 ˆà for row, col in automata.next_step():ˆàˆà 89 def draw_cell(self, cells):ˆà ˆà 90 for row, col in cells:ˆà 91 91 index = automata.symbols[automata.field[row][col]]ˆà 92 92 color = automata.states[index].colorˆà òÀæ òÀæ ˆà 110 110 left + col * shift + self.cell_size,ˆà 111 111 top + row * shift + self.cell_size,ˆà 112 ˆà fill=color, outline="" )ˆàˆà 112 fill=color, outline="", tag="cell")ˆà 113 113 self.cells[row].append(cell)ˆà 114 114 ˆà
Note: See TracChangeset
for help on using the changeset viewer.