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

Changeset 58:dd3e42d72f44


Ignore:
Timestamp:
12/08/10 02:33:39 (5 years ago)
Author:
is_rusinov
Branch:
default
Message:

state_list change handlers and fill of entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Interface.py

    r57 r58 ˆà
    195195        ˆà
    196196        def to_top(self):# replace choosen state to topˆà
    197ˆà                index = automata.symbols.get(state_list.get("active").split()[0])ˆà
    198ˆà                state = automata.states[index]ˆà
    199ˆà                del automata.states[index]ˆà
    200ˆà                automata.states.insert(0, state)ˆà
    201ˆà                state_list.delete(index)ˆà
    202ˆà                state_list.insert(0, state)ˆà
    ˆà197                selected = state_list.curselection()ˆà
    ˆà198                if len(selected):ˆà
    ˆà199                        index = int(selected[0])ˆà
    ˆà200                        state = automata.states[index]ˆà
    ˆà201                        print stateˆà
    ˆà202                        del automata.states[index]ˆà
    ˆà203                        automata.states.insert(0, state)ˆà
    ˆà204                        self.refresh_list()ˆà
    ˆà205                        state_list.selection_set(0)ˆà
    ˆà206                        print automata.statesˆà
    203207        ˆà
    204208        def to_bottom(self):# replace choosen state to bottonˆà
    205ˆà                index = automata.symbols.get(state_list.get("active").split()[0])ˆà
    206ˆà                state = automata.states[index]ˆà
    207ˆà                del automata.states[index]ˆà
    208ˆà                automata.states.append(state)ˆà
    209ˆà                state_list.delete(index)ˆà
    210ˆà                state_list.insert("end", state)ˆà
    ˆà209                selected = state_list.curselection()ˆà
    ˆà210                if len(selected):ˆà
    ˆà211                        index = int(selected[0])ˆà
    ˆà212                        state = automata.states[index]ˆà
    ˆà213                        print stateˆà
    ˆà214                        del automata.states[index]ˆà
    ˆà215                        automata.states.append(state)ˆà
    ˆà216                        self.refresh_list()ˆà
    ˆà217                        state_list.selection_set("end")ˆà
    ˆà218                        print automata.statesˆà
    211219        ˆà
    212220        def upwards(self):ˆà
    213ˆà                index = automata.symbols.get(state_list.get("active").split()[0])ˆà
    214ˆà                state = automata.states[index]ˆà
    215ˆà                del automata.states[index]ˆà
    216ˆà                automata.states.insert(index - 1, state)ˆà
    217ˆà                state_list.delete(index)ˆà
    218ˆà                state_list.insert(index - 1, state)ˆà
    ˆà221                selected = state_list.curselection()ˆà
    ˆà222                if len(selected):ˆà
    ˆà223                        index = int(selected[0])ˆà
    ˆà224                        if index > 0:ˆà
    ˆà225                                state = automata.states[index]ˆà
    ˆà226                                print stateˆà
    ˆà227                                del automata.states[index]ˆà
    ˆà228                                automata.states.insert(index - 1, state)ˆà
    ˆà229                                self.refresh_list()ˆà
    ˆà230                                state_list.selection_set(index - 1)ˆà
    ˆà231                                print automata.statesˆà
    219232        ˆà
    220233        def downwards(self):ˆà
    221ˆà                index = automata.symbols.get(state_list.get("active").split()[0])ˆà
    222ˆà                state = automata.states[index]ˆà
    223ˆà                del automata.states[index]ˆà
    224ˆà                automata.states.insert(index + 1, state)ˆà
    225ˆà                state_list.delete(index)ˆà
    226ˆà                state_list.insert(index + 1, state)ˆà
    ˆà234                selected = state_list.curselection()ˆà
    ˆà235                if len(selected):ˆà
    ˆà236                        index = int(selected[0])ˆà
    ˆà237                        if index < state_list.size() - 1:ˆà
    ˆà238                                state = automata.states[index]ˆà
    ˆà239                                print stateˆà
    ˆà240                                del automata.states[index]ˆà
    ˆà241                                automata.states.insert(index + 1, state)ˆà
    ˆà242                                self.refresh_list()ˆà
    ˆà243                                state_list.selection_set(index + 1)ˆà
    ˆà244                                print automata.statesˆà
    227245        ˆà
    228246        def delete_state(self):# delete choosen stateˆà
    229ˆà                index = automata.symbols.get(state_list.get("active").split()[0])ˆà
    230ˆà                del automata.states[index]ˆà
    231ˆà                state_list.delete(index)ˆà
    ˆà247                selected = state_list.curselection()ˆà
    ˆà248                if len(selected):ˆà
    ˆà249                        index = int(selected[0])ˆà
    ˆà250                        print automata.states[index]ˆà
    ˆà251                        del automata.symbols[automata.states[index].symbol]ˆà
    ˆà252                        for key in self.keys.keys():ˆà
    ˆà253                                if self.keys[key] == index:ˆà
    ˆà254                                        del self.keys[key]ˆà
    ˆà255                        del automata.states[index]ˆà
    ˆà256                        self.refresh_list()ˆà
    ˆà257                        print automata.statesˆà
    232258        ˆà
    233259        def add(self):# add new stateˆà
    òÀæ òÀæ ˆà
    257283                        automata.symbols[symbol] = len(automata.states) - 1ˆà
    258284                        self.keys[key] = len(automata.states) - 1ˆà
    259ˆà                        state_list.insert("end", state)ˆà
    ˆà285                        error.config(text="")ˆà
    ˆà286                        self.refresh_list()ˆà
    260287        ˆà
    261288        def change(self):# change chosen stateˆà
    262ˆà                index = automata.symbols.get(state_list.get("active").split()[0])ˆà
    263ˆà                name = state_name.get()ˆà
    264ˆà                symbol = state_symbol.get()ˆà
    265ˆà                key = state_key.get().lower()ˆà
    266ˆà                color = state_color.get()ˆà
    267ˆà                nums = []ˆà
    268ˆà                for i, value in enumerate(ckeckbox_nums):ˆà
    269ˆà                        print i, value.get()ˆà
    270ˆà                        if value.get() == 1:ˆà
    271ˆà                                nums.append(i)ˆà
    272ˆà                print numsˆà
    273ˆà                if self.keys.has_key(key) and self.keys[key] != index:ˆà
    274ˆà                        error.config(text="State with such key has already existed")ˆà
    275ˆà                        state_key.focus()ˆà
    276ˆà                elif len(key) != 1:ˆà
    277ˆà                        error.config(text="Bad key for state")ˆà
    278ˆà                        state_key.focus()ˆà
    279ˆà                elif automata.symbols.has_key(symbol)  and automata.symbols[symbol] != index:ˆà
    280ˆà                        error.config(text="State with such symbol has already existed")ˆà
    281ˆà                        state_symbol.focus()ˆà
    282ˆà                elif len(symbol) != 1:ˆà
    283ˆà                        error.config(text="Bad symbol for state")ˆà
    284ˆà                        state_symbol.focus()ˆà
    285ˆà                else:ˆà
    286ˆà                        state = State(name, symbol, color, nums)ˆà
    287ˆà                        automata.states[index] = stateˆà
    288ˆà                        automata.symbols[symbol] = indexˆà
    289ˆà                        self.keys[key] = indexˆà
    290ˆà                        state_list.delete(index)ˆà
    291ˆà                        state_list.insert(index, state)ˆà
    ˆà289                selected = state_list.curselection()ˆà
    ˆà290                if len(selected):ˆà
    ˆà291                        index = int(selected[0])ˆà
    ˆà292                        name = state_name.get()ˆà
    ˆà293                        symbol = state_symbol.get()ˆà
    ˆà294                        key = state_key.get().lower()ˆà
    ˆà295                        color = state_color.get()ˆà
    ˆà296                        nums = []ˆà
    ˆà297                        for i, value in enumerate(ckeckbox_nums):ˆà
    ˆà298                                print i, value.get()ˆà
    ˆà299                                if value.get() == 1:ˆà
    ˆà300                                        nums.append(i)ˆà
    ˆà301                        print numsˆà
    ˆà302                        if self.keys.has_key(key) and self.keys[key] != index:ˆà
    ˆà303                                error.config(text="State with such key has already existed")ˆà
    ˆà304                                state_key.focus()ˆà
    ˆà305                        elif len(key) != 1:ˆà
    ˆà306                                error.config(text="Bad key for state")ˆà
    ˆà307                                state_key.focus()ˆà
    ˆà308                        elif automata.symbols.has_key(symbol)  and automata.symbols[symbol] != index:ˆà
    ˆà309                                error.config(text="State with such symbol has already existed")ˆà
    ˆà310                                state_symbol.focus()ˆà
    ˆà311                        elif len(symbol) != 1:ˆà
    ˆà312                                error.config(text="Bad symbol for state")ˆà
    ˆà313                                state_symbol.focus()ˆà
    ˆà314                        else:ˆà
    ˆà315                                state = State(name, symbol, color, nums)ˆà
    ˆà316                                automata.states[index] = stateˆà
    ˆà317                                automata.symbols[symbol] = indexˆà
    ˆà318                                self.keys[key] = indexˆà
    ˆà319                                error.config(text="")ˆà
    ˆà320                                self.refresh_list()ˆà
    292321        ˆà
    293322        def show_size_window(self):ˆà
    òÀæ òÀæ ˆà
    302331        def hide_automata_window(self):ˆà
    303332                automata_window.withdraw()ˆà
    304ˆà                ˆà
    ˆà333        def refresh_list(self):ˆà
    ˆà334                state_list.delete(0, "end")ˆà
    ˆà335                for state in automata.states:ˆà
    ˆà336                        state_list.insert("end", state)ˆà
    ˆà337        def list_mouse_release(self, event):ˆà
    ˆà338                print 'hello'ˆà
    ˆà339                selected = state_list.curselection()ˆà
    ˆà340                if len(selected):ˆà
    ˆà341                        index = int(selected[0])ˆà
    ˆà342                        state = automata.states[index]ˆà
    ˆà343                        state_name.delete(0, "end")ˆà
    ˆà344                        state_name.insert(0, state.name)ˆà
    ˆà345                        state_symbol.delete(0, "end")ˆà
    ˆà346                        state_symbol.insert(0, state.symbol)ˆà
    ˆà347                        for key in self.keys.keys():ˆà
    ˆà348                                if self.keys[key] == index:ˆà
    ˆà349                                        state_key.delete(0, "end")ˆà
    ˆà350                                        state_key.insert(0, key)ˆà
    ˆà351                        state_color.delete(0, "end")ˆà
    ˆà352                        state_color.insert(0, state.color)ˆà
    ˆà353                        for i in range(9):ˆà
    ˆà354                                ckeckbox_nums[i].set(i in state.nums)ˆà
    305355ˆà
    306356ˆà
    òÀæ òÀæ ˆà
    343393scrollbar = Scrollbar(list_frame)ˆà
    344394scrollbar.pack(side="right", fill="y")ˆà
    345ˆàstate_list=Listbox(list_frame, yscrollcommand=scrollbar.set, ˆà
    346ˆà                                                                                        selectmode="extended")ˆà
    347ˆàfor state in automata.states:ˆà
    348ˆà        state_list.insert("end", state)ˆà
    ˆà395state_list=Listbox(list_frame, yscrollcommand=scrollbar.set, activestyle="none", selectmode="single")ˆà
    ˆà396handlers.refresh_list()ˆà
    ˆà397state_list.bind("<ButtonRelease-1>", handlers.list_mouse_release)ˆà
    349398state_list.pack(side="top", fill="y")ˆà
    350399scrollbar.config(command=state_list.yview)ˆà
Note: See TracChangeset for help on using the changeset viewer.