#NEWLINE# def KeyboardListener( event ) : #NEWLINE# #INDENT# global choiceboxChoices , choiceboxWidget #NEWLINE# key = event . keysym #NEWLINE# if ( len ( key ) <= 1 ) : #NEWLINE# #INDENT# if ( key in string . printable ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# start_n = int ( choiceboxWidget . curselection ( ) [ 0 ] ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# start_n = ( - 1 ) #NEWLINE# #UNINDENT# choiceboxWidget . selection_clear ( 0 , 'end' ) #NEWLINE# for n in range ( ( start_n + 1 ) , len ( choiceboxChoices ) ) : #NEWLINE# #INDENT# item = choiceboxChoices [ n ] #NEWLINE# if ( item [ 0 ] . lower ( ) == key . lower ( ) ) : #NEWLINE# #INDENT# choiceboxWidget . selection_set ( first = n ) #NEWLINE# choiceboxWidget . see ( n ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for ( n , item ) in enumerate ( choiceboxChoices ) : #NEWLINE# #INDENT# if ( item [ 0 ] . lower ( ) == key . lower ( ) ) : #NEWLINE# #INDENT# choiceboxWidget . selection_set ( first = n ) #NEWLINE# choiceboxWidget . see ( n ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# for ( n , item ) in enumerate ( choiceboxChoices ) : #NEWLINE# #INDENT# if ( item [ 0 ] . lower ( ) > key . lower ( ) ) : #NEWLINE# #INDENT# if ( n > 0 ) : #NEWLINE# #INDENT# choiceboxWidget . selection_set ( first = ( n - 1 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# choiceboxWidget . selection_set ( first = 0 ) #NEWLINE# #UNINDENT# choiceboxWidget . see ( n ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# lastIndex = ( len ( choiceboxChoices ) - 1 ) #NEWLINE# choiceboxWidget . selection_set ( first = lastIndex ) #NEWLINE# choiceboxWidget . see ( start_n ) #NEWLINE# return