#NEWLINE# def __buttonEvent( event = None , buttons = None , virtual_event = None ) : #NEWLINE# #INDENT# '\n    Handle an event that is generated by a person interacting with a button.  It may be a button press\n    or a key press.\n    ' #NEWLINE# global boxRoot , __replyButtonText #NEWLINE# m = re . match ( '(\\d+)x(\\d+)([-+]\\d+)([-+]\\d+)' , boxRoot . geometry ( ) ) #NEWLINE# if ( not m ) : #NEWLINE# #INDENT# raise ValueError ( 'failed to parse geometry string: {}' . format ( boxRoot . geometry ( ) ) ) #NEWLINE# #UNINDENT# ( width , height , xoffset , yoffset ) = [ int ( s ) for s in m . groups ( ) ] #NEWLINE# st . rootWindowPosition = '{0:+g}{1:+g}' . format ( xoffset , yoffset ) #NEWLINE# if ( virtual_event == 'cancel' ) : #NEWLINE# #INDENT# for ( button_name , button ) in buttons . items ( ) : #NEWLINE# #INDENT# if ( 'cancel_choice' in button ) : #NEWLINE# #INDENT# __replyButtonText = button [ 'original_text' ] #NEWLINE# #UNINDENT# #UNINDENT# __replyButtonText = None #NEWLINE# boxRoot . quit ( ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( virtual_event == 'select' ) : #NEWLINE# #INDENT# text = event . widget . config ( 'text' ) [ ( - 1 ) ] #NEWLINE# if ( not isinstance ( text , ut . basestring ) ) : #NEWLINE# #INDENT# text = ' ' . join ( text ) #NEWLINE# #UNINDENT# for ( button_name , button ) in buttons . items ( ) : #NEWLINE# #INDENT# if ( button [ 'clean_text' ] == text ) : #NEWLINE# #INDENT# __replyButtonText = button [ 'original_text' ] #NEWLINE# boxRoot . quit ( ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if buttons : #NEWLINE# #INDENT# for ( button_name , button ) in buttons . items ( ) : #NEWLINE# #INDENT# hotkey_pressed = event . keysym #NEWLINE# if ( event . keysym != event . char ) : #NEWLINE# #INDENT# hotkey_pressed = '<{}>' . format ( event . keysym ) #NEWLINE# #UNINDENT# if ( button [ 'hotkey' ] == hotkey_pressed ) : #NEWLINE# #INDENT# __replyButtonText = button_name #NEWLINE# boxRoot . quit ( ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# print ( 'Event not understood' )