Changeset 6:721fdbb815c8
- Timestamp:
- 12/03/10 23:05:02 (5 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface.py
r5 r6 ˆà 1 ˆà # Interfaceˆà 2 ˆà automataˆà 3 ˆà handlersˆà 4 ˆà #menuˆà 5 ˆà #infoPanel=Frameˆà 6 ˆà #canvasˆà 7 ˆà #actionPanelFrame start stop nextStep zoomIn zoomOut faster slowerˆà ˆà 1 from Tkinter import *ˆà 8 2 ˆà 9 3 class Handlers(object):ˆà 10 4 ˆà 11 ˆà def __init__(self, scale, speed, offset ):ˆàˆà 5 def __init__(self, scale, speed, offset_x, offset_y):ˆà 12 6 self.scale = scaleˆà 13 7 self.speed = speedˆà 14 ˆà self.offset = offsetˆà ˆà 8 self.offset_x = offset_xˆà ˆà 9 self.offset_y = offset_yˆà 15 10 self.after_id = 0ˆà 16 11 ˆà òÀæ òÀæ ˆà 115 110 def close_state_window():ˆà 116 111 passˆà ˆà 112 ˆà ˆà 113 def show_frame():ˆà ˆà 114 frame1.pack(side="right", fill="y", expand="no", before=canvas)ˆà ˆà 115 ˆà ˆà 116 ˆà ˆà 117 root = Tk()ˆà ˆà 118 root.title("Cyclyc Cell Automata")ˆà ˆà 119 ˆà ˆà 120 canvas = Canvas(root, background="white")ˆà ˆà 121 canvas.config(width=500, height=400)ˆà ˆà 122 canvas.pack(fill="both", expand="yes")ˆà ˆà 123 ˆà ˆà 124 automata = Automata() ˆà ˆà 125 handlers = Handlers(1, 1, 0, 0)ˆà ˆà 126 ˆà ˆà 127 states = []ˆà ˆà 128 symboles = dict()ˆà ˆà 129 ˆà ˆà 130 #infoPanel=Frameˆà ˆà 131 frame1=Frame(root, background="grey")ˆà ˆà 132 statelist=Listbox(frame1, selectmode="extended")ˆà ˆà 133 for state in states:ˆà ˆà 134 statelist.insert("end", state)ˆà ˆà 135 statelist.pack(side="top", fill="y")ˆà ˆà 136 up = Button(frame1, text="Up", state="disable")ˆà ˆà 137 up.config(bg="red")ˆà ˆà 138 down = Button(frame1, text="Down", state="disable")ˆà ˆà 139 down.config(bg="orange")ˆà ˆà 140 to_top = Button(frame1, text="To Top", state="disable")ˆà ˆà 141 to_top.config(bg="yellow")ˆà ˆà 142 to_bottom = Button(frame1, text="To Bottom", state="disable")ˆà ˆà 143 to_bottom.config(bg="green")ˆà ˆà 144 hide = Button(frame1, text="hide", command=frame1.forget)ˆà ˆà 145 hide.config(bg="cyan")ˆà ˆà 146 up.pack(side="top", fill="x")ˆà ˆà 147 down.pack(side="top", fill="x")ˆà ˆà 148 to_top.pack(side="top", fill="x")ˆà ˆà 149 to_bottom.pack(side="top", fill="x")ˆà ˆà 150 hide.pack(side="bottom", fill="x")ˆà ˆà 151 ˆà ˆà 152 ˆà ˆà 153 menubar = Menu(root)ˆà ˆà 154 root.config(menu=menubar)ˆà ˆà 155 ˆà ˆà 156 menu_file = Menu(menubar)ˆà ˆà 157 menu_file.add_command(label="New")ˆà ˆà 158 menu_file.add_command(label="Open...")ˆà ˆà 159 menu_file.add_command(label="Save...")ˆà ˆà 160 menu_file.add_separator()ˆà ˆà 161 menu_file.add_command(label="Exit")ˆà ˆà 162 menubar.add_cascade(label="File", menu=menu_file)ˆà ˆà 163 ˆà ˆà 164 menu_action = Menu(menubar)ˆà ˆà 165 menu_action.add_command(label="Start")ˆà ˆà 166 menu_action.add_command(label="Stop")ˆà ˆà 167 menu_action.add_command(label="Next Step")ˆà ˆà 168 menu_action.add_command(label="Increase speed")ˆà ˆà 169 menu_action.add_command(label="Decrease speed")ˆà ˆà 170 menu_action.add_command(label="Zoom In")ˆà ˆà 171 menu_action.add_command(label="Zoom Out")ˆà ˆà 172 menu_action.add_command(label="Clean field")ˆà ˆà 173 menu_action.add_command(label="Fill randomly")ˆà ˆà 174 menubar.add_cascade(label="Action", menu=menu_action)ˆà ˆà 175 ˆà ˆà 176 menubar.add_command(label="Automata", command=handlers.show_frame)ˆà ˆà 177 ˆà ˆà 178 menubar.add_command(label="Help")ˆà ˆà 179 ˆà ˆà 180 root.mainloop()ˆà ˆà 181 ˆà
Note: See TracChangeset
for help on using the changeset viewer.