Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.su/trac/cca/changeset/08600f868875b1cab7d402f7cbd4eec772456ba4
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 05:26:34 2016
Êîäèðîâêà: UTF-8
Changeset 87:08600f868875 ? Cyclyc Cell Automata

Changeset 87:08600f868875


Ignore:
Timestamp:
12/13/10 02:23:13 (5 years ago)
Author:
is_rusinov
Branch:
default
Message:

+ statusbar, fix #24

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Interface.py

    r86 r87 š
    1313class Handlers(object):š
    1414        š
    15š        def __init__(self, cell_size=8, line_width=1 ,delay=10, dx=0, dy=0):# cell_size is size of cell, including line width, if there is itš
    š15        def __init__(self, cell_size=8, line_width=1 ,delay=8, dx=0, dy=0):# cell_size is size of cell, including line width, if there is itš
    1616                self.cell_size = cell_sizeš
    1717                self.line_width = line_widthš
    ? ? š
    3333                        self.is_started = Trueš
    3434                        self.repeat()š
    š35                        self.update_status()š
    3536        š
    3637        def repeat(self):š
    ? ? š
    4142                canvas.after_cancel(self.after_id)š
    4243                self.is_started = Falseš
    š44                self.update_status()š
    4345        š
    4446        def next_step(self, event=None):š
    ? ? š
    4648                        canvas.after_cancel(self.after_id)š
    4749                        self.is_started = Falseš
    š50                        self.update_status()š
    4851                else:š
    4952                        self.draw_cell(automata.next_step())š
    ? ? š
    101104        š
    102105        def slower(self, event=None, speed_rate=2):š
    103š                self.stop()š
    104š                self.delay = self.delay*speed_rateš
    105š                self.start()š
    š106                if self.delay <= 500:š
    š107                        self.delay = self.delay * speed_rateš
    š108                        self.update_status()š
    106109        š
    107110        def faster(self, event=None, speed_rate=2):š
    108š                self.stop()š
    109111                self.delay = self.delay / speed_rateš
    110112                if self.delay == 0:š
    111113                        self.delay = 1š
    112š                self.start()š
    š114                self.update_status()š
    113115        š
    114116        def change_size(self):š
    ? ? š
    134136                        self.hide_size_window()š
    135137                        self.change_scroll_area()š
    š138                        self.update_status()š
    136139                except Exception:š
    137140                        message.config(text="Operation is refused")š
    138141                        message.after(2000, self.clear_message)š
    š142        š
    139143        def draw_cell(self, cells):š
    140144                for row, col in cells:š
    ? ? š
    392396        š
    393397        def show_size_window(self, event=None):š
    š398                size.config(text=str(len(automata.field[0])) + " x " + str(len(automata.field)))š
    394399                size_window.deiconify()š
    395400        š
    ? ? š
    485490                height = automata.height * (self.cell_size + self.line_width) + self.line_widthš
    486491                canvas.config(scrollregion=(0, 0, width, height))š
    š492        def update_status(self):š
    š493                status_size.config(text="size: " + str(len(automata.field[0])) + " x " + str(len(automata.field)))š
    š494                state = "paused"š
    š495                speed = 0š
    š496                if self.is_started:š
    š497                        state = "running"š
    š498                        speed = 512 / self.delayš
    š499                status_state.config(text="status: " + state)š
    š500                status_speed.config(text="speed: " + str(speed))š
    487501š
    488502š
    ? ? š
    503517canvas.bind_all("<KeyRelease>", handlers.release_key)š
    504518š
    505šscroll_x=Scrollbar(root, orient="horizontal")š
    506šscroll_y=Scrollbar(root, orient="vertical")š
    š519scroll_x = Scrollbar(root, orient="horizontal")š
    š520scroll_y = Scrollbar(root, orient="vertical")š
    š521statusline = Frame(root)š
    š522status_size = Label(statusline)š
    š523status_state = Label(statusline)š
    š524status_speed = Label(statusline)š
    š525š
    š526handlers.update_status()š
    507527š
    508528canvas.grid(row=0, column=0, sticky="nsew")š
    509529scroll_y.grid(row=0, column=1, sticky="ns")š
    510530scroll_x.grid(row=1, column=0, sticky="ew")š
    š531statusline.grid(row=2, column=0, sticky="ew")š
    š532status_size.grid(row=0, column=0, sticky="w")š
    š533status_state.grid(row=0, column=1, sticky="w")š
    š534status_speed.grid(row=0, column=2, sticky="w")š
    511535š
    512536handlers.change_scroll_area()š
    ? ? š
    516540root.columnconfigure(0, weight=1)š
    517541root.rowconfigure(0, weight=1)š
    š542statusline.columnconfigure(0, weight=1)š
    š543statusline.columnconfigure(1, weight=1)š
    š544statusline.columnconfigure(2, weight=1)š
    518545š
    519546š
    ? ? š
    632659size_window.protocol("WM_DELETE_WINDOW", handlers.hide_size_window)š
    633660Label(size_window, text= "Current size of window:").pack(side="top", fill="x")š
    634šsize = Label(size_window, text= str(len(automata.field)) + " x " + str(len(automata.field[0])))š
    š661size = Label(size_window, text= str(len(automata.field[0])) + " x " + str(len(automata.field)))š
    635662size.pack(side="top", fill="x")š
    636663Label(size_window, text= "New size:").pack(side="top", fill="x")š
Note: See TracChangeset for help on using the changeset viewer.