<s> import Tkinter as tk <EOL> from robot . parsing . txtreader import TxtReader <EOL> import ttk <EOL> import sys <EOL> import re <EOL> from rwb . widgets import HighlightMixin <EOL> import logging <EOL> import tcl <EOL> '''<STR_LIT>''' <EOL> class QuietIntVar ( tk . IntVar ) : <EOL> '''<STR_LIT>''' <EOL> def __del__ ( self ) : <EOL> try : <EOL> self . _tk . globalunsetvar ( self . _name ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> pass <EOL> class DynamicTableEditor ( tk . Text , HighlightMixin ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> tk . Text . __init__ ( self , * args , ** kwargs ) <EOL> font = self . cget ( "<STR_LIT>" ) <EOL> self . log = logging . getLogger ( "<STR_LIT>" ) <EOL> self . tmpvar = QuietIntVar ( master = self , name = "<STR_LIT>" ) <EOL> bindtags = self . bindtags ( ) <EOL> new_bindtags = tuple ( [ bindtags [ <NUM_LIT:0> ] , "<STR_LIT>" ] + list ( bindtags [ <NUM_LIT:1> : ] ) ) <EOL> self . bindtags ( new_bindtags ) <EOL> self . bind_class ( "<STR_LIT>" , "<STR_LIT>" , self . _on_autocomplete ) <EOL> self . bind_class ( "<STR_LIT>" , "<STR_LIT>" , self . _on_escape ) <EOL> self . bind_class ( "<STR_LIT>" , "<STR_LIT>" , self . _on_down ) <EOL> self . bind_class ( "<STR_LIT>" , "<STR_LIT>" , self . _on_up ) <EOL> self . bind_class ( "<STR_LIT>" , "<STR_LIT>" , self . _on_return ) <EOL> self . bind_class ( "<STR_LIT>" , "<STR_LIT>" , self . _on_tab ) <EOL> self . bind_class ( "<STR_LIT>" , "<STR_LIT>" , self . _on_click ) <EOL> self . bind ( "<STR_LIT>" , self . _on_select_block ) <EOL> self . bind ( "<STR_LIT>" , self . _on_brace_open ) <EOL> self . bind ( "<STR_LIT>" , self . _on_pipe ) <EOL> self . bind ( "<STR_LIT>" , self . on_tab ) <EOL> self . bind ( "<STR_LIT>" , self . _on_triple_click ) <EOL> self . bind ( "<STR_LIT>" , self . _on_control_enter ) <EOL> self . bind ( "<STR_LIT>" , self . _on_expand ) <EOL> self . bind ( "<STR_LIT>" , self . _on_paste ) <EOL> self . tag_configure ( "<STR_LIT>" , background = "<STR_LIT>" ) <EOL> self . tag_raise ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . bind ( "<STR_LIT>" , lambda event : "<STR_LIT>" ) <EOL> self . complete_frame = ttk . Frame ( self ) <EOL> self . list = tk . Listbox ( self . complete_frame , width = <NUM_LIT:30> , height = <NUM_LIT:8> , <EOL> borderwidth = <NUM_LIT:1> , relief = "<STR_LIT>" , exportselection = False ) <EOL> self . list . pack ( side = "<STR_LIT>" , fill = "<STR_LIT>" , expand = True ) <EOL> self . hooks = [ ] <EOL> post_change_hook = self . register ( self . _post_change_hook ) <EOL> widget = str ( self ) <EOL> self . tk . eval ( tcl . CREATE_WIDGET_PROXY ) <EOL> self . tk . eval ( '''<STR_LIT>''' . format ( widget = widget , post_change_hook = post_change_hook ) ) <EOL> self . _last_current_cell_start = "<STR_LIT>" <EOL> @ property <EOL> def current_row_number ( self ) : <EOL> return self . index ( "<STR_LIT>" ) . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] <EOL> def find_start_of_statement ( self , index = "<STR_LIT>" ) : <EOL> '''<STR_LIT>''' <EOL> return self . index ( "<STR_LIT>" % index ) <EOL> def find_end_of_statement ( self , index = "<STR_LIT>" , mark = "<STR_LIT>" ) : <EOL> '''<STR_LIT>''' <EOL> return self . index ( "<STR_LIT>" % index ) <EOL> def get_row_number ( self , index ) : <EOL> '''<STR_LIT>''' <EOL> linenum = int ( self . index ( index ) . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] ) <EOL> return linenum <EOL> def set_completion_choices ( self , choices ) : <EOL> self . list . delete ( <NUM_LIT:0> , "<STR_LIT:end>" ) <EOL> for string in choices : <EOL> self . list . insert ( "<STR_LIT:end>" , string ) <EOL> self . list . selection_set ( <NUM_LIT:0> ) <EOL> self . _reposition_choices ( ) <EOL> self . list . configure ( height = min ( len ( choices ) , <NUM_LIT:10> ) ) <EOL> def get_autocomplete_string ( self ) : <EOL> try : <EOL> return self . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> except : <EOL> return "<STR_LIT>" <EOL> def get_selected_rows ( self ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> first_linenum = int ( self . index ( "<STR_LIT>" ) . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] ) <EOL> last_linenum = int ( self . index ( "<STR_LIT>" ) . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] ) <EOL> result = [ self . get_row ( linenum ) for linenum in range ( first_linenum , last_linenum + <NUM_LIT:1> ) ] <EOL> except Exception , e : <EOL> self . log . debug ( str ( e ) ) <EOL> result = [ ] <EOL> return result <EOL> def compress_columns ( self , anchor = "<STR_LIT>" ) : <EOL> '''<STR_LIT>''' <EOL> linenumber = self . index ( anchor ) . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] <EOL> rows = self . get_selected_rows ( ) <EOL> result = [ ] <EOL> for row in rows : <EOL> row = [ cell . strip ( ) for cell in row ] <EOL> result . append ( row ) <EOL> self . replace_selected_rows ( result ) <EOL> def align_columns ( self , anchor = "<STR_LIT>" ) : <EOL> '''<STR_LIT>''' <EOL> rows = self . get_selected_rows ( ) <EOL> col_size = { } <EOL> for row in rows : <EOL> for i , col in enumerate ( row ) : <EOL> col_size [ i ] = max ( col_size . get ( i , <NUM_LIT:0> ) , len ( col ) ) <EOL> ncols = len ( col_size ) <EOL> result = [ ] <EOL> for row in rows : <EOL> for i , col in enumerate ( row ) : <EOL> row [ i ] = col . ljust ( col_size [ i ] ) <EOL> result . append ( row ) <EOL> self . replace_selected_rows ( result ) <EOL> def convert_to_string ( self , rows ) : <EOL> '''<STR_LIT>''' <EOL> lines = [ ] <EOL> for row in rows : <EOL> data = "<STR_LIT>" . join ( row ) <EOL> data = "<STR_LIT:|>" + data if data . startswith ( "<STR_LIT:U+0020>" ) else "<STR_LIT>" + data <EOL> lines . append ( data . rstrip ( ) ) <EOL> return "<STR_LIT:\n>" . join ( lines ) <EOL> def replace_selected_rows ( self , rows ) : <EOL> '''<STR_LIT>''' <EOL> string = self . convert_to_string ( rows ) <EOL> self . mark_set ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . mark_set ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . mark_gravity ( "<STR_LIT>" , "<STR_LIT:left>" ) <EOL> self . mark_gravity ( "<STR_LIT>" , "<STR_LIT:right>" ) <EOL> sel = ( self . index ( "<STR_LIT>" ) , <EOL> self . index ( "<STR_LIT>" ) ) <EOL> self . replace ( "<STR_LIT>" , "<STR_LIT>" , string ) <EOL> self . tag_add ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . mark_unset ( "<STR_LIT>" ) <EOL> def get_current_statement ( self ) : <EOL> '''<STR_LIT>''' <EOL> text = self . get_current_statement_text ( ) <EOL> if not text . lstrip ( ) . startswith ( "<STR_LIT:|>" ) : <EOL> text = "<STR_LIT>" + text <EOL> lines = text . split ( "<STR_LIT:\n>" ) <EOL> statement = self . _split_row ( lines [ <NUM_LIT:0> ] ) <EOL> for line in lines [ <NUM_LIT:1> : ] : <EOL> line = line . strip ( "<STR_LIT:U+0020>" ) <EOL> if not line . startswith ( "<STR_LIT:|>" ) : <EOL> line = "<STR_LIT>" + line <EOL> row = self . _split_row ( line ) <EOL> statement . extend ( row [ <NUM_LIT:2> : ] ) <EOL> return statement <EOL> def get_current_statement_text ( self ) : <EOL> start = self . find_start_of_statement ( ) <EOL> end = self . find_end_of_statement ( ) <EOL> text = self . get ( start , end ) <EOL> return text <EOL> def get_lines ( self , start = "<STR_LIT:1.0>" , end = "<STR_LIT:end>" ) : <EOL> '''<STR_LIT>''' <EOL> while self . compare ( start , "<STR_LIT:<>" , end ) : <EOL> yield self . get ( "<STR_LIT>" % start , "<STR_LIT>" % start ) <EOL> start = self . index ( "<STR_LIT>" % start ) <EOL> def get_rows ( self , rownums ) : <EOL> result = [ ] <EOL> for rownum in rownums : <EOL> result . append ( self . get_row ( rownum ) ) <EOL> return result <EOL> def get_row ( self , linenumber ) : <EOL> '''<STR_LIT>''' <EOL> line_start = "<STR_LIT>" % linenumber <EOL> line_end = self . index ( line_start + "<STR_LIT>" ) <EOL> text = self . get ( line_start , line_end ) . strip ( ) <EOL> return self . _split_row ( text ) <EOL> def _split_row ( self , row ) : <EOL> '''<STR_LIT>''' <EOL> _space_splitter = re . compile ( '<STR_LIT>' ) <EOL> _pipe_splitter = re . compile ( '<STR_LIT>' ) <EOL> row = row . rstrip ( ) . replace ( '<STR_LIT:\t>' , '<STR_LIT:U+0020>' ) <EOL> if not row . startswith ( '<STR_LIT>' ) : <EOL> return _space_splitter . split ( row ) <EOL> row = row [ <NUM_LIT:1> : - <NUM_LIT:1> ] if row . endswith ( '<STR_LIT>' ) else row [ <NUM_LIT:1> : ] <EOL> return [ cell . strip ( ) for cell in _pipe_splitter . split ( row ) ] <EOL> def current_cell ( self ) : <EOL> '''<STR_LIT>''' <EOL> ( start , end ) = self . _current_cell_boundaries ( ) <EOL> return ( start , end ) <EOL> def select_current_cell ( self ) : <EOL> '''<STR_LIT>''' <EOL> ( start , end ) = self . _current_cell_boundaries ( ) <EOL> self . tag_remove ( "<STR_LIT>" , <NUM_LIT:1.0> , "<STR_LIT:end>" ) <EOL> self . tag_add ( "<STR_LIT>" , start , end ) <EOL> def move_to_next_column ( self ) : <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> self . complete_frame . place_forget ( ) <EOL> i = self . search ( "<STR_LIT>" , "<STR_LIT>" , regexp = True , count = self . tmpvar ) <EOL> if ( i != "<STR_LIT>" ) : <EOL> self . mark_set ( "<STR_LIT>" , "<STR_LIT>" % ( i , self . tmpvar . get ( ) ) ) <EOL> if ( self . get ( "<STR_LIT>" ) == "<STR_LIT:|>" ) : <EOL> self . mark_set ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . select_current_cell ( ) <EOL> self . see ( "<STR_LIT>" ) <EOL> def add_post_change_hook ( self , cmd ) : <EOL> '''<STR_LIT>''' <EOL> self . hooks . append ( cmd ) <EOL> def replace ( self , start , end , string , tags = None ) : <EOL> '''<STR_LIT>''' <EOL> insert = self . index ( start ) <EOL> self . configure ( autoseparators = False ) <EOL> self . edit_separator ( ) <EOL> self . delete ( start , end ) <EOL> self . insert ( insert , string , tags ) <EOL> self . edit_separator ( ) <EOL> self . configure ( autoseparators = True ) <EOL> def _on_paste ( self , event ) : <EOL> '''<STR_LIT>''' <EOL> data = self . clipboard_get ( ) . replace ( "<STR_LIT:\r\n>" , "<STR_LIT:\n>" ) . replace ( "<STR_LIT:\r>" , "<STR_LIT:\n>" ) <EOL> self . edit_separator ( ) <EOL> try : <EOL> self . delete ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> self . insert ( "<STR_LIT>" , data ) <EOL> self . edit_separator ( ) <EOL> return "<STR_LIT>" <EOL> def _on_expand ( self , event ) : <EOL> sys . stdout . flush ( ) <EOL> def _on_select_block ( self , event ) : <EOL> '''<STR_LIT>''' <EOL> sel = self . tag_ranges ( "<STR_LIT>" ) <EOL> if len ( sel ) == <NUM_LIT:0> : <EOL> self . select_current_cell ( ) <EOL> else : <EOL> self . select_current_cell ( ) <EOL> if self . tag_ranges ( "<STR_LIT>" ) == sel : <EOL> self . tag_add ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def _on_control_enter ( self , event ) : <EOL> '''<STR_LIT>''' <EOL> line = self . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> match = re . match ( r'<STR_LIT>' , line ) <EOL> if match : <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT:\n>" + match . group ( <NUM_LIT:0> ) ) <EOL> if re . match ( r'<STR_LIT>' , line ) : <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> return "<STR_LIT>" <EOL> def _on_triple_click ( self , event ) : <EOL> self . select_current_cell ( ) <EOL> return "<STR_LIT>" <EOL> def on_tab ( self , event ) : <EOL> '''<STR_LIT>''' <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> self . complete_frame . place_forget ( ) <EOL> line = self . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> if re . search ( r'<STR_LIT>' , line ) : <EOL> index = self . search ( "<STR_LIT>" , "<STR_LIT>" , regexp = True , <EOL> stopindex = "<STR_LIT>" , count = self . tmpvar ) <EOL> if index != "<STR_LIT>" : <EOL> self . mark_set ( "<STR_LIT>" , "<STR_LIT>" % ( index , self . tmpvar . get ( ) ) ) <EOL> return "<STR_LIT>" <EOL> if ( self . compare ( "<STR_LIT>" , "<STR_LIT:>>" , "<STR_LIT:1.0>" ) and <EOL> self . compare ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) and <EOL> self . compare ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> previous_line = self . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> match = re . match ( r'<STR_LIT>' , previous_line ) <EOL> if match : <EOL> self . insert ( "<STR_LIT>" , match . group ( <NUM_LIT:1> ) ) <EOL> return "<STR_LIT>" <EOL> if self . _should_add_new_column ( ) : <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> return "<STR_LIT>" <EOL> else : <EOL> self . move_to_next_column ( ) <EOL> return "<STR_LIT>" <EOL> def _current_cell_boundaries ( self ) : <EOL> i = self . search ( "<STR_LIT>" , "<STR_LIT>" , regexp = True , <EOL> count = self . tmpvar , backwards = True , <EOL> stopindex = "<STR_LIT>" ) <EOL> if i == "<STR_LIT>" : <EOL> start = self . index ( "<STR_LIT>" ) <EOL> else : <EOL> start = self . index ( "<STR_LIT>" % ( i , self . tmpvar . get ( ) ) ) <EOL> i = self . search ( "<STR_LIT>" , "<STR_LIT>" , stopindex = "<STR_LIT>" , regexp = True ) <EOL> if i == "<STR_LIT>" : i = self . index ( "<STR_LIT>" ) <EOL> return ( start , i ) <EOL> def _should_add_new_column ( self ) : <EOL> if ( self . compare ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> index = self . search ( r'<STR_LIT>' , "<STR_LIT>" , backwards = True , regexp = True , <EOL> stopindex = "<STR_LIT>" ) <EOL> if index == "<STR_LIT>" : <EOL> return True <EOL> return False <EOL> def _on_pipe ( self , event ) : <EOL> if ( self . compare ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> return "<STR_LIT>" <EOL> prev = self . get ( "<STR_LIT>" ) <EOL> if ( prev == "<STR_LIT:\\>" ) : <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT:|>" ) <EOL> return "<STR_LIT>" <EOL> if ( prev != "<STR_LIT:U+0020>" ) : <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT:U+0020>" ) <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT:|>" , "<STR_LIT>" ) <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT:U+0020>" ) <EOL> return "<STR_LIT>" <EOL> def _on_brace_open ( self , event ) : <EOL> prev = self . get ( "<STR_LIT>" ) <EOL> prevprev = self . get ( "<STR_LIT>" ) <EOL> if ( ( prev == "<STR_LIT:$>" or prev == "<STR_LIT:@>" ) and prevprev != "<STR_LIT:\\>" ) : <EOL> self . insert ( "<STR_LIT>" , "<STR_LIT:{}>" ) <EOL> self . tag_add ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . mark_set ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . edit_separator ( ) <EOL> return "<STR_LIT>" <EOL> def _on_click ( self , event ) : <EOL> try : <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> self . complete_frame . place_forget ( ) <EOL> except : <EOL> pass <EOL> def _post_change_hook ( self , result , command , * args ) : <EOL> self . _tag_current_cell ( ) <EOL> self . tag_remove ( "<STR_LIT>" , <NUM_LIT:1.0> , "<STR_LIT:end>" ) <EOL> self . tag_add ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . _reposition_choices ( ) <EOL> for func in self . hooks : <EOL> try : <EOL> func ( result , command , * args ) <EOL> except Exception , e : <EOL> print "<STR_LIT>" , e <EOL> if ( command in ( "<STR_LIT>" , "<STR_LIT>" ) and self . complete_frame . winfo_viewable ( ) ) : <EOL> self . event_generate ( "<STR_LIT>" ) <EOL> line = self . index ( "<STR_LIT>" ) . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] <EOL> def _on_any_key ( self , event ) : <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> self . event_generate ( "<STR_LIT>" ) <EOL> def _on_tab ( self , event ) : <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> selection = self . list . curselection ( ) <EOL> if selection is not None and len ( selection ) > <NUM_LIT:0> : <EOL> i = selection [ <NUM_LIT:0> ] <EOL> text = self . list . get ( i ) <EOL> self . replace ( "<STR_LIT>" , "<STR_LIT>" , text ) <EOL> self . complete_frame . place_forget ( ) <EOL> self . move_to_next_column ( ) <EOL> return "<STR_LIT>" <EOL> self . move_to_next_column ( ) <EOL> return "<STR_LIT>" <EOL> def _on_return ( self , event ) : <EOL> try : <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> selection = self . list . curselection ( ) <EOL> if selection is not None and len ( selection ) > <NUM_LIT:0> : <EOL> i = selection [ <NUM_LIT:0> ] <EOL> text = self . list . get ( i ) <EOL> self . replace ( "<STR_LIT>" , "<STR_LIT>" , text ) <EOL> self . complete_frame . place_forget ( ) <EOL> return "<STR_LIT>" <EOL> except : <EOL> pass <EOL> def _select_next ( self ) : <EOL> selection = self . list . curselection ( ) <EOL> if selection is not None and len ( selection ) > <NUM_LIT:0> : <EOL> index = int ( selection [ <NUM_LIT:0> ] ) + <NUM_LIT:1> <EOL> self . list . activate ( index ) <EOL> self . list . see ( index ) <EOL> self . list . selection_clear ( <NUM_LIT:0> , "<STR_LIT:end>" ) <EOL> self . list . selection_set ( "<STR_LIT>" ) <EOL> def _select_prev ( self ) : <EOL> selection = self . list . curselection ( ) <EOL> if selection is not None and len ( selection ) > <NUM_LIT:0> : <EOL> index = int ( selection [ <NUM_LIT:0> ] ) - <NUM_LIT:1> <EOL> self . list . activate ( index ) <EOL> self . list . see ( index ) <EOL> self . list . selection_clear ( <NUM_LIT:0> , "<STR_LIT:end>" ) <EOL> self . list . selection_set ( "<STR_LIT>" ) <EOL> def _on_up ( self , event ) : <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> self . _select_prev ( ) <EOL> return "<STR_LIT>" <EOL> def _on_down ( self , event ) : <EOL> if self . complete_frame . winfo_viewable ( ) : <EOL> self . _select_next ( ) <EOL> return "<STR_LIT>" <EOL> def _on_escape ( self , event ) : <EOL> if ( self . complete_frame . winfo_viewable ( ) ) : <EOL> self . complete_frame . place_forget ( ) <EOL> def _tag_current_cell ( self ) : <EOL> self . tag_remove ( "<STR_LIT>" , <NUM_LIT:1.0> , "<STR_LIT:end>" ) <EOL> ( start , end ) = self . current_cell ( ) <EOL> self . tag_add ( "<STR_LIT>" , start , end ) <EOL> return <EOL> i = self . search ( "<STR_LIT>" , "<STR_LIT>" , stopindex = "<STR_LIT>" , <EOL> backwards = True , regexp = True ) <EOL> if i == "<STR_LIT>" : <EOL> cell_start = self . index ( "<STR_LIT>" ) <EOL> else : <EOL> cell_start = self . search ( r'<STR_LIT>' , "<STR_LIT>" % i , regexp = True ) <EOL> i = self . search ( "<STR_LIT>" , cell_start , stopindex = "<STR_LIT>" , regexp = True ) <EOL> if i == "<STR_LIT>" : <EOL> cell_end = self . index ( "<STR_LIT>" ) <EOL> else : <EOL> cell_end = i <EOL> self . tag_remove ( "<STR_LIT>" , <NUM_LIT:1.0> , "<STR_LIT:end>" ) <EOL> self . tag_add ( "<STR_LIT>" , cell_start , cell_end ) <EOL> def _on_autocomplete ( self , event ) : <EOL> self . event_generate ( "<STR_LIT>" ) <EOL> self . _reposition_choices ( force = True ) <EOL> def _reposition_choices ( self , force = False ) : <EOL> if not force and not self . complete_frame . winfo_viewable ( ) : <EOL> return <EOL> try : <EOL> bbox = self . bbox ( "<STR_LIT>" ) <EOL> except Exception , e : <EOL> return <EOL> fx = bbox [ <NUM_LIT:0> ] <EOL> fy = bbox [ <NUM_LIT:1> ] + bbox [ <NUM_LIT:3> ] + <NUM_LIT:2> <EOL> yoffset = <NUM_LIT:2> <EOL> listheight = self . complete_frame . winfo_reqheight ( ) <EOL> if fy + listheight > self . winfo_height ( ) : <EOL> fy = bbox [ <NUM_LIT:1> ] - ( listheight + yoffset ) <EOL> if fy < <NUM_LIT:1> : <EOL> fy = bbox [ <NUM_LIT:1> ] + bbox [ <NUM_LIT:3> ] + yoffset <EOL> self . complete_frame . place ( x = fx , y = fy ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import sys <EOL> root = tk . Tk ( ) <EOL> dte = DynamicTableEditor ( root , highlightthickness = <NUM_LIT:0> ) <EOL> vsb = tk . Scrollbar ( root , orient = "<STR_LIT>" , command = dte . yview ) <EOL> hsb = tk . Scrollbar ( root , orient = "<STR_LIT>" , command = dte . xview ) <EOL> dte . configure ( xscrollcommand = hsb . set , yscrollcommand = vsb . set ) <EOL> dte . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:0> , sticky = "<STR_LIT>" ) <EOL> vsb . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:1> , sticky = "<STR_LIT>" ) <EOL> hsb . grid ( row = <NUM_LIT:1> , column = <NUM_LIT:0> , sticky = "<STR_LIT>" ) <EOL> root . grid_rowconfigure ( <NUM_LIT:0> , weight = <NUM_LIT:1> ) <EOL> root . grid_columnconfigure ( <NUM_LIT:0> , weight = <NUM_LIT:1> ) <EOL> root . mainloop ( ) </s>
