@@ -1035,38 +1035,54 @@ def _substitute(self, *args):
10351035 """Internal function."""
10361036 if len (args ) != len (self ._subst_format ): return args
10371037 getboolean = self .tk .getboolean
1038+
10381039 getint = int
1040+ def getint_event (s ):
1041+ """Tk changed behavior in 8.4.2, returning "??" rather more often."""
1042+ try :
1043+ return int (s )
1044+ except ValueError :
1045+ return s
1046+
10391047 nsign , b , f , h , k , s , t , w , x , y , A , E , K , N , W , T , X , Y , D = args
10401048 # Missing: (a, c, d, m, o, v, B, R)
10411049 e = Event ()
1050+ # serial field: valid vor all events
1051+ # number of button: ButtonPress and ButtonRelease events only
1052+ # height field: Configure, ConfigureRequest, Create,
1053+ # ResizeRequest, and Expose events only
1054+ # keycode field: KeyPress and KeyRelease events only
1055+ # time field: "valid for events that contain a time field"
1056+ # width field: Configure, ConfigureRequest, Create, ResizeRequest,
1057+ # and Expose events only
1058+ # x field: "valid for events that contain a x field"
1059+ # y field: "valid for events that contain a y field"
1060+ # keysym as decimal: KeyPress and KeyRelease events only
1061+ # x_root, y_root fields: ButtonPress, ButtonRelease, KeyPress,
1062+ # KeyRelease,and Motion events
10421063 e .serial = getint (nsign )
1043- e .num = getint (b )
1064+ e .num = getint_event (b )
10441065 try : e .focus = getboolean (f )
10451066 except TclError : pass
1046- e .height = getint (h )
1047- e .keycode = getint (k )
1048- # For Visibility events, event state is a string and
1049- # not an integer:
1050- try :
1051- e .state = getint (s )
1052- except ValueError :
1053- e .state = s
1054- e .time = getint (t )
1055- e .width = getint (w )
1056- e .x = getint (x )
1057- e .y = getint (y )
1067+ e .height = getint_event (h )
1068+ e .keycode = getint_event (k )
1069+ e .state = getint_event (s )
1070+ e .time = getint_event (t )
1071+ e .width = getint_event (w )
1072+ e .x = getint_event (x )
1073+ e .y = getint_event (y )
10581074 e .char = A
10591075 try : e .send_event = getboolean (E )
10601076 except TclError : pass
10611077 e .keysym = K
1062- e .keysym_num = getint (N )
1078+ e .keysym_num = getint_event (N )
10631079 e .type = T
10641080 try :
10651081 e .widget = self ._nametowidget (W )
10661082 except KeyError :
10671083 e .widget = W
1068- e .x_root = getint (X )
1069- e .y_root = getint (Y )
1084+ e .x_root = getint_event (X )
1085+ e .y_root = getint_event (Y )
10701086 try :
10711087 e .delta = getint (D )
10721088 except ValueError :
0 commit comments