cca
diff Interface.py @ 73:da819fc713f8
+ new_file
author | is_rusinov |
---|---|
date | Sun, 12 Dec 2010 13:20:32 +0300 |
parents | abc08aeebe37 |
children | 0eadc4383ca7 |
line diff
1.1 --- a/Interface.py Sun Dec 12 12:55:10 2010 +0300 1.2 +++ b/Interface.py Sun Dec 12 13:20:32 2010 +0300 1.3 @@ -3,6 +3,7 @@ 1.4 import pickle 1.5 import tkColorChooser 1.6 import tkFileDialog 1.7 +import tkMessageBox 1.8 from Tkinter import * 1.9 1.10 from State import * 1.11 @@ -46,7 +47,6 @@ 1.12 1.13 def save_file(self): 1.14 file = tkFileDialog.asksaveasfile(defaultextension=".caf", title="Save automata as", filetypes=[('Cyclic cell Automata File', '*.caf')]) 1.15 - print file 1.16 pickle.dump([automata.field, automata.states], file) 1.17 1.18 def open_file(self): 1.19 @@ -63,6 +63,20 @@ 1.20 self.hide_automata_window() 1.21 self.draw() 1.22 1.23 + def new_file(self): 1.24 + if tkMessageBox.askyesno("Save?", "Do you want to save current automata?"): 1.25 + self.save_file() 1.26 + new_automata = Automata() 1.27 + automata.field = new_automata.field 1.28 + automata.height = len(automata.field) 1.29 + automata.width = len(automata.field[0]) 1.30 + automata.states = new_automata.states 1.31 + self.selected_state = None 1.32 + self.refresh_dicts() 1.33 + self.refresh_list() 1.34 + self.hide_automata_window() 1.35 + self.draw() 1.36 + 1.37 def show_help_window(self): 1.38 pass 1.39 1.40 @@ -654,7 +668,7 @@ 1.41 root.config(menu=menubar) 1.42 1.43 menu_file = Menu(menubar) 1.44 -menu_file.add_command(label="New") 1.45 +menu_file.add_command(label="New", command=handlers.new_file) 1.46 menu_file.add_command(label="Open...", command=handlers.open_file) 1.47 menu_file.add_command(label="Save...", command=handlers.save_file) 1.48 menu_file.add_separator()