Changeset 58:dd3e42d72f44
- Timestamp:
- 12/08/10 02:33:39 (5 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface.py
r57 r58 ˆà 195 195 ˆà 196 196 def to_top(self):# replace choosen state to topˆà 197 ˆà index = automata.symbols.get(state_list.get("active").split()[0])ˆà 198 ˆà state = automata.states[index]ˆà 199 ˆà del automata.states[index]ˆà 200 ˆà automata.states.insert(0, state)ˆà 201 ˆà state_list.delete(index)ˆà 202 ˆà state_list.insert(0, state)ˆà ˆà 197 selected = state_list.curselection()ˆà ˆà 198 if len(selected):ˆà ˆà 199 index = int(selected[0])ˆà ˆà 200 state = automata.states[index]ˆà ˆà 201 print stateˆà ˆà 202 del automata.states[index]ˆà ˆà 203 automata.states.insert(0, state)ˆà ˆà 204 self.refresh_list()ˆà ˆà 205 state_list.selection_set(0)ˆà ˆà 206 print automata.statesˆà 203 207 ˆà 204 208 def to_bottom(self):# replace choosen state to bottonˆà 205 ˆà index = automata.symbols.get(state_list.get("active").split()[0])ˆà 206 ˆà state = automata.states[index]ˆà 207 ˆà del automata.states[index]ˆà 208 ˆà automata.states.append(state)ˆà 209 ˆà state_list.delete(index)ˆà 210 ˆà state_list.insert("end", state)ˆà ˆà 209 selected = state_list.curselection()ˆà ˆà 210 if len(selected):ˆà ˆà 211 index = int(selected[0])ˆà ˆà 212 state = automata.states[index]ˆà ˆà 213 print stateˆà ˆà 214 del automata.states[index]ˆà ˆà 215 automata.states.append(state)ˆà ˆà 216 self.refresh_list()ˆà ˆà 217 state_list.selection_set("end")ˆà ˆà 218 print automata.statesˆà 211 219 ˆà 212 220 def upwards(self):ˆà 213 ˆà index = automata.symbols.get(state_list.get("active").split()[0])ˆà 214 ˆà state = automata.states[index]ˆà 215 ˆà del automata.states[index]ˆà 216 ˆà automata.states.insert(index - 1, state)ˆà 217 ˆà state_list.delete(index)ˆà 218 ˆà state_list.insert(index - 1, state)ˆà ˆà 221 selected = state_list.curselection()ˆà ˆà 222 if len(selected):ˆà ˆà 223 index = int(selected[0])ˆà ˆà 224 if index > 0:ˆà ˆà 225 state = automata.states[index]ˆà ˆà 226 print stateˆà ˆà 227 del automata.states[index]ˆà ˆà 228 automata.states.insert(index - 1, state)ˆà ˆà 229 self.refresh_list()ˆà ˆà 230 state_list.selection_set(index - 1)ˆà ˆà 231 print automata.statesˆà 219 232 ˆà 220 233 def downwards(self):ˆà 221 ˆà index = automata.symbols.get(state_list.get("active").split()[0])ˆà 222 ˆà state = automata.states[index]ˆà 223 ˆà del automata.states[index]ˆà 224 ˆà automata.states.insert(index + 1, state)ˆà 225 ˆà state_list.delete(index)ˆà 226 ˆà state_list.insert(index + 1, state)ˆà ˆà 234 selected = state_list.curselection()ˆà ˆà 235 if len(selected):ˆà ˆà 236 index = int(selected[0])ˆà ˆà 237 if index < state_list.size() - 1:ˆà ˆà 238 state = automata.states[index]ˆà ˆà 239 print stateˆà ˆà 240 del automata.states[index]ˆà ˆà 241 automata.states.insert(index + 1, state)ˆà ˆà 242 self.refresh_list()ˆà ˆà 243 state_list.selection_set(index + 1)ˆà ˆà 244 print automata.statesˆà 227 245 ˆà 228 246 def delete_state(self):# delete choosen stateˆà 229 ˆà index = automata.symbols.get(state_list.get("active").split()[0])ˆà 230 ˆà del automata.states[index]ˆà 231 ˆà state_list.delete(index)ˆà ˆà 247 selected = state_list.curselection()ˆà ˆà 248 if len(selected):ˆà ˆà 249 index = int(selected[0])ˆà ˆà 250 print automata.states[index]ˆà ˆà 251 del automata.symbols[automata.states[index].symbol]ˆà ˆà 252 for key in self.keys.keys():ˆà ˆà 253 if self.keys[key] == index:ˆà ˆà 254 del self.keys[key]ˆà ˆà 255 del automata.states[index]ˆà ˆà 256 self.refresh_list()ˆà ˆà 257 print automata.statesˆà 232 258 ˆà 233 259 def add(self):# add new stateˆà òÀæ òÀæ ˆà 257 283 automata.symbols[symbol] = len(automata.states) - 1ˆà 258 284 self.keys[key] = len(automata.states) - 1ˆà 259 ˆà state_list.insert("end", state)ˆà ˆà 285 error.config(text="")ˆà ˆà 286 self.refresh_list()ˆà 260 287 ˆà 261 288 def change(self):# change chosen stateˆà 262 ˆà index = automata.symbols.get(state_list.get("active").split()[0])ˆà 263 ˆà name = state_name.get()ˆà 264 ˆà symbol = state_symbol.get()ˆà 265 ˆà key = state_key.get().lower()ˆà 266 ˆà color = state_color.get()ˆà 267 ˆà nums = []ˆà 268 ˆà for i, value in enumerate(ckeckbox_nums):ˆà 269 ˆà print i, value.get()ˆà 270 ˆà if value.get() == 1:ˆà 271 ˆà nums.append(i)ˆà 272 ˆà print numsˆà 273 ˆà if self.keys.has_key(key) and self.keys[key] != index:ˆà 274 ˆà error.config(text="State with such key has already existed")ˆà 275 ˆà state_key.focus()ˆà 276 ˆà elif len(key) != 1:ˆà 277 ˆà error.config(text="Bad key for state")ˆà 278 ˆà state_key.focus()ˆà 279 ˆà elif automata.symbols.has_key(symbol) and automata.symbols[symbol] != index:ˆà 280 ˆà error.config(text="State with such symbol has already existed")ˆà 281 ˆà state_symbol.focus()ˆà 282 ˆà elif len(symbol) != 1:ˆà 283 ˆà error.config(text="Bad symbol for state")ˆà 284 ˆà state_symbol.focus()ˆà 285 ˆà else:ˆà 286 ˆà state = State(name, symbol, color, nums)ˆà 287 ˆà automata.states[index] = stateˆà 288 ˆà automata.symbols[symbol] = indexˆà 289 ˆà self.keys[key] = indexˆà 290 ˆà state_list.delete(index)ˆà 291 ˆà state_list.insert(index, state)ˆà ˆà 289 selected = state_list.curselection()ˆà ˆà 290 if len(selected):ˆà ˆà 291 index = int(selected[0])ˆà ˆà 292 name = state_name.get()ˆà ˆà 293 symbol = state_symbol.get()ˆà ˆà 294 key = state_key.get().lower()ˆà ˆà 295 color = state_color.get()ˆà ˆà 296 nums = []ˆà ˆà 297 for i, value in enumerate(ckeckbox_nums):ˆà ˆà 298 print i, value.get()ˆà ˆà 299 if value.get() == 1:ˆà ˆà 300 nums.append(i)ˆà ˆà 301 print numsˆà ˆà 302 if self.keys.has_key(key) and self.keys[key] != index:ˆà ˆà 303 error.config(text="State with such key has already existed")ˆà ˆà 304 state_key.focus()ˆà ˆà 305 elif len(key) != 1:ˆà ˆà 306 error.config(text="Bad key for state")ˆà ˆà 307 state_key.focus()ˆà ˆà 308 elif automata.symbols.has_key(symbol) and automata.symbols[symbol] != index:ˆà ˆà 309 error.config(text="State with such symbol has already existed")ˆà ˆà 310 state_symbol.focus()ˆà ˆà 311 elif len(symbol) != 1:ˆà ˆà 312 error.config(text="Bad symbol for state")ˆà ˆà 313 state_symbol.focus()ˆà ˆà 314 else:ˆà ˆà 315 state = State(name, symbol, color, nums)ˆà ˆà 316 automata.states[index] = stateˆà ˆà 317 automata.symbols[symbol] = indexˆà ˆà 318 self.keys[key] = indexˆà ˆà 319 error.config(text="")ˆà ˆà 320 self.refresh_list()ˆà 292 321 ˆà 293 322 def show_size_window(self):ˆà òÀæ òÀæ ˆà 302 331 def hide_automata_window(self):ˆà 303 332 automata_window.withdraw()ˆà 304 ˆà ˆà ˆà 333 def refresh_list(self):ˆà ˆà 334 state_list.delete(0, "end")ˆà ˆà 335 for state in automata.states:ˆà ˆà 336 state_list.insert("end", state)ˆà ˆà 337 def list_mouse_release(self, event):ˆà ˆà 338 print 'hello'ˆà ˆà 339 selected = state_list.curselection()ˆà ˆà 340 if len(selected):ˆà ˆà 341 index = int(selected[0])ˆà ˆà 342 state = automata.states[index]ˆà ˆà 343 state_name.delete(0, "end")ˆà ˆà 344 state_name.insert(0, state.name)ˆà ˆà 345 state_symbol.delete(0, "end")ˆà ˆà 346 state_symbol.insert(0, state.symbol)ˆà ˆà 347 for key in self.keys.keys():ˆà ˆà 348 if self.keys[key] == index:ˆà ˆà 349 state_key.delete(0, "end")ˆà ˆà 350 state_key.insert(0, key)ˆà ˆà 351 state_color.delete(0, "end")ˆà ˆà 352 state_color.insert(0, state.color)ˆà ˆà 353 for i in range(9):ˆà ˆà 354 ckeckbox_nums[i].set(i in state.nums)ˆà 305 355 ˆà 306 356 ˆà òÀæ òÀæ ˆà 343 393 scrollbar = Scrollbar(list_frame)ˆà 344 394 scrollbar.pack(side="right", fill="y")ˆà 345 ˆà state_list=Listbox(list_frame, yscrollcommand=scrollbar.set, ˆà 346 ˆà selectmode="extended")ˆà 347 ˆà for state in automata.states:ˆà 348 ˆà state_list.insert("end", state)ˆà ˆà 395 state_list=Listbox(list_frame, yscrollcommand=scrollbar.set, activestyle="none", selectmode="single")ˆà ˆà 396 handlers.refresh_list()ˆà ˆà 397 state_list.bind("<ButtonRelease-1>", handlers.list_mouse_release)ˆà 349 398 state_list.pack(side="top", fill="y")ˆà 350 399 scrollbar.config(command=state_list.yview)ˆà
Note: See TracChangeset
for help on using the changeset viewer.