<s> import Tkinter , tkMessageBox <EOL> class TagEditorPopup ( ) : <EOL> def _add_tag ( self , event ) : <EOL> tag = event . widget . get ( ) <EOL> if tag . count ( "<STR_LIT::>" ) != <NUM_LIT:1> : <EOL> tkMessageBox . showerror ( "<STR_LIT>" , <EOL> "<STR_LIT>" + tag + <EOL> "<STR_LIT>" , <EOL> parent = self . _parent ) <EOL> return <EOL> self . _tags_listbox . insert ( Tkinter . END , tag ) <EOL> event . widget . delete ( <NUM_LIT:0> , Tkinter . END ) <EOL> self . _tag_change_listener ( self . _tags_listbox . get ( <NUM_LIT:0> , Tkinter . END ) ) <EOL> def _delete_tag ( self , event ) : <EOL> event . widget . delete ( event . widget . curselection ( ) ) <EOL> self . _tag_change_listener ( event . widget . get ( <NUM_LIT:0> , Tkinter . END ) ) <EOL> def hide ( self ) : <EOL> self . _tags_entry . pack_forget ( ) <EOL> self . _tags_listbox . pack_forget ( ) <EOL> self . _tags_popup . pack_forget ( ) <EOL> self . _tags_popup . place_forget ( ) <EOL> def show ( self , tags , x , y ) : <EOL> self . _tags_entry . delete ( <NUM_LIT:0> , Tkinter . END ) <EOL> self . _tags_listbox . delete ( <NUM_LIT:0> , Tkinter . END ) <EOL> for tag in tags : <EOL> if not tag . startswith ( "<STR_LIT:_>" ) : <EOL> self . _tags_listbox . insert ( Tkinter . END , tag ) <EOL> self . _tags_entry . pack ( ) <EOL> self . _tags_listbox . pack ( ) <EOL> self . _tags_popup . pack ( ) <EOL> self . _tags_popup . place ( x = x , y = y ) <EOL> def __init__ ( self , parent , tag_change_listener ) : <EOL> self . _tags_popup = Tkinter . Frame ( parent ) <EOL> self . _tags_entry = Tkinter . Entry ( self . _tags_popup ) <EOL> self . _tags_entry . bind ( '<STR_LIT>' , self . _add_tag ) <EOL> self . _tags_listbox = Tkinter . Listbox ( self . _tags_popup ) <EOL> self . _tags_listbox . bind ( '<STR_LIT>' , self . _delete_tag ) <EOL> self . _tag_change_listener = tag_change_listener <EOL> self . _parent = parent </s>
