cca
changeset 29:315a5fdf099e
+ add and correct some mistakes
author | is_rusinov |
---|---|
date | Sun, 05 Dec 2010 02:06:28 +0300 |
parents | 5b96b63759e0 |
children | 6a24f9bb0d51 |
files | Interface.py |
diffstat | 1 files changed, 48 insertions(+), 22 deletions(-) [+] |
line diff
1.1 --- a/Interface.py Sun Dec 05 01:15:20 2010 +0300 1.2 +++ b/Interface.py Sun Dec 05 02:06:28 2010 +0300 1.3 @@ -19,6 +19,7 @@ 1.4 self.zoom_divisor = 10 1.5 self.is_started = False 1.6 self.keys = dict() 1.7 + self.draw() 1.8 def start(self): 1.9 if not self.is_started: 1.10 self.is_started = True 1.11 @@ -26,7 +27,7 @@ 1.12 self.after_id = canvas.after(self.delay, self.start) 1.13 1.14 def stop(self): 1.15 - self.canvas.after_cancel(self.after_id) 1.16 + canvas.after_cancel(self.after_id) 1.17 self.is_started = False 1.18 1.19 def next_step(self): 1.20 @@ -39,10 +40,10 @@ 1.21 def open_file(self): 1.22 pass 1.23 1.24 - def help(self): 1.25 + def show_help_window(self): 1.26 pass 1.27 1.28 - def close_help_window(self): 1.29 + def hide_help_window(self): 1.30 pass 1.31 1.32 def zoom_in(self, zoom_rate=1): 1.33 @@ -59,7 +60,7 @@ 1.34 self.delay = self.delay + speed_rate 1.35 1.36 def faster(self, speed_rate=1): 1.37 - if self.speed > speed_rate: 1.38 + if self.delay > speed_rate: 1.39 self.delay = self.delay - speed_rate 1.40 else: 1.41 self.delay = 0 1.42 @@ -155,35 +156,60 @@ 1.43 automata_frame.pack(side="right", fill="y", expand="no", before=canvas) 1.44 1.45 def to_top(self):# replace choosen state to top 1.46 - index = symbols.get(state_list.get("active").split()[1]) 1.47 - state = states[index] 1.48 - del states[index] 1.49 - states.insert(0, state) 1.50 + index = automata.symbols.get(state_list.get("active").split()[1]) 1.51 + state = automata.states[index] 1.52 + del automata.states[index] 1.53 + automata.states.insert(0, state) 1.54 1.55 def to_bottom(self):# replace choosen state to botton 1.56 - index = symbols.get(state_list.get("active").split()[1]) 1.57 - state = states[index] 1.58 - del states[index] 1.59 - states.append(state) 1.60 + index = automata.symbols.get(state_list.get("active").split()[1]) 1.61 + state = automata.states[index] 1.62 + del automata.states[index] 1.63 + automata.states.append(state) 1.64 1.65 def upwards(self): 1.66 - index = symbols.get(state_list.get("active").split()[1]) 1.67 - state = states[index] 1.68 - del states[index] 1.69 - states.insert(index - 1, state) 1.70 + index = automata.symbols.get(state_list.get("active").split()[1]) 1.71 + state = automata.states[index] 1.72 + del automata.states[index] 1.73 + automata.states.insert(index - 1, state) 1.74 1.75 def downwards(self): 1.76 - index = symbols.get(state_list.get("active").split()[1]) 1.77 - state = states[index] 1.78 - del states[index] 1.79 - states.insert(index + 1, state) 1.80 + index = automata.symbols.get(state_list.get("active").split()[1]) 1.81 + state = automata.states[index] 1.82 + del automata.states[index] 1.83 + automata.states.insert(index + 1, state) 1.84 1.85 def delete_state(self):# delete choosen state 1.86 - index = symbols.get(state_list.get("active").split()[1]) 1.87 - del states[index] 1.88 + index = automata.symbols.get(state_list.get("active").split()[1]) 1.89 + del automata.states[index] 1.90 1.91 def add(self):# add new state 1.92 pass 1.93 + name = state_name.get() 1.94 + symbol = state_sympob.get() 1.95 + key = lower(state_key.get()) 1.96 + color = state_color.get() 1.97 + nums = [] 1.98 + for i, value in enumerate(ckeckbox_nums): 1.99 + if value: 1.100 + nums.append(i) 1.101 + if self.keys.has_key(key): 1.102 + error.config(text="State with such key has already existed") 1.103 + state_key.focus() 1.104 + elif len(key) != 1: 1.105 + error.config(text="Bad key for state") 1.106 + state_key.focus() 1.107 + elif automata.symbols.has_key(symbol): 1.108 + error.config(text="State with such symbol has already existed") 1.109 + state_symbol.focus() 1.110 + elif len(symbol) != 1: 1.111 + error.config(text="Bad symbol for state") 1.112 + state_symbol.focus() 1.113 + else: 1.114 + state = State(name, symbol, color, nums) 1.115 + automata.states.append(state) 1.116 + automata.symbols(symbol) = len(automata.states) - 1 1.117 + self.keys(key) = len(automata.states) - 1 1.118 1.119 def change(self):# change chosen state 1.120 pass