Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.su/trac/cca/changeset/6
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 00:39:55 2016
Êîäèðîâêà: IBM-866
Changeset 6:721fdbb815c8 òÀÓ Cyclyc Cell Automata

Changeset 6:721fdbb815c8


Ignore:
Timestamp:
12/03/10 23:05:02 (5 years ago)
Author:
Ilia
Branch:
default
Message:

basic structure of interface

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