cca
diff Interface.py @ 6:721fdbb815c8
basic structure of interface
author | Ilia |
---|---|
date | Fri, 03 Dec 2010 23:05:02 +0300 |
parents | 9194e2a2e45c |
children | e56a5e838f37 |
line diff
1.1 --- a/Interface.py Fri Dec 03 14:21:03 2010 +0300 1.2 +++ b/Interface.py Fri Dec 03 23:05:02 2010 +0300 1.3 @@ -1,17 +1,12 @@ 1.4 -# Interface 1.5 -automata 1.6 -handlers 1.7 -#menu 1.8 -#infoPanel=Frame 1.9 -#canvas 1.10 -#actionPanelFrame start stop nextStep zoomIn zoomOut faster slower 1.11 +from Tkinter import * 1.12 1.13 class Handlers(object): 1.14 1.15 - def __init__(self, scale, speed, offset): 1.16 + def __init__(self, scale, speed, offset_x, offset_y): 1.17 self.scale = scale 1.18 self.speed = speed 1.19 - self.offset = offset 1.20 + self.offset_x = offset_x 1.21 + self.offset_y = offset_y 1.22 self.after_id = 0 1.23 1.24 def start(self): 1.25 @@ -114,3 +109,73 @@ 1.26 1.27 def close_state_window(): 1.28 pass 1.29 + 1.30 + def show_frame(): 1.31 + frame1.pack(side="right", fill="y", expand="no", before=canvas) 1.32 + 1.33 + 1.34 +root = Tk() 1.35 +root.title("Cyclyc Cell Automata") 1.36 + 1.37 +canvas = Canvas(root, background="white") 1.38 +canvas.config(width=500, height=400) 1.39 +canvas.pack(fill="both", expand="yes") 1.40 + 1.41 +automata = Automata() 1.42 +handlers = Handlers(1, 1, 0, 0) 1.43 + 1.44 +states = [] 1.45 +symboles = dict() 1.46 + 1.47 +#infoPanel=Frame 1.48 +frame1=Frame(root, background="grey") 1.49 +statelist=Listbox(frame1, selectmode="extended") 1.50 +for state in states: 1.51 + statelist.insert("end", state) 1.52 +statelist.pack(side="top", fill="y") 1.53 +up = Button(frame1, text="Up", state="disable") 1.54 +up.config(bg="red") 1.55 +down = Button(frame1, text="Down", state="disable") 1.56 +down.config(bg="orange") 1.57 +to_top = Button(frame1, text="To Top", state="disable") 1.58 +to_top.config(bg="yellow") 1.59 +to_bottom = Button(frame1, text="To Bottom", state="disable") 1.60 +to_bottom.config(bg="green") 1.61 +hide = Button(frame1, text="hide", command=frame1.forget) 1.62 +hide.config(bg="cyan") 1.63 +up.pack(side="top", fill="x") 1.64 +down.pack(side="top", fill="x") 1.65 +to_top.pack(side="top", fill="x") 1.66 +to_bottom.pack(side="top", fill="x") 1.67 +hide.pack(side="bottom", fill="x") 1.68 + 1.69 + 1.70 +menubar = Menu(root) 1.71 +root.config(menu=menubar) 1.72 + 1.73 +menu_file = Menu(menubar) 1.74 +menu_file.add_command(label="New") 1.75 +menu_file.add_command(label="Open...") 1.76 +menu_file.add_command(label="Save...") 1.77 +menu_file.add_separator() 1.78 +menu_file.add_command(label="Exit") 1.79 +menubar.add_cascade(label="File", menu=menu_file) 1.80 + 1.81 +menu_action = Menu(menubar) 1.82 +menu_action.add_command(label="Start") 1.83 +menu_action.add_command(label="Stop") 1.84 +menu_action.add_command(label="Next Step") 1.85 +menu_action.add_command(label="Increase speed") 1.86 +menu_action.add_command(label="Decrease speed") 1.87 +menu_action.add_command(label="Zoom In") 1.88 +menu_action.add_command(label="Zoom Out") 1.89 +menu_action.add_command(label="Clean field") 1.90 +menu_action.add_command(label="Fill randomly") 1.91 +menubar.add_cascade(label="Action", menu=menu_action) 1.92 + 1.93 +menubar.add_command(label="Automata", command=handlers.show_frame) 1.94 + 1.95 +menubar.add_command(label="Help") 1.96 + 1.97 +root.mainloop() 1.98 +