On Sat, Jun 14, 2014 at 9:52 AM, Saimadhav Heblikar <saimadhavhebli...@gmail.com> wrote: > My thinking was to use the validator method across IDLE(in tests, > validating key config before IDLE starts and of course in the key > binding dialog KeyOk method) > If we need it only for the dialog, then I will extract those regex's only.
We're going to need two different keysym checking functions, for use in several places: 1) Check that a keysym is valid for Tk. This will be used for manually defined key bindings in the advanced dialog and user config files. This should use the method from Roger Serwy's patch, which creates a temporary Tk object and tries to bind the keysym with it. It could also include a preliminary check (via simple parsing) to give informative error messages for obviously invalid keysyms such as "<Key-x" and "<Alt-Alt-x>". 2) Check that a keysym is in our canonical form. This will be used to test the default config files shipped with IDLE and for testing the "basic" key config dialog. Both of these should use some common code for the basic parsing of a keysym into its parts. > No particular reason. I had a feeling splitting method could get > messy. But if its for a small set that the validity method is going to > be required for, splitting method is better. As can be seen in your patch, parsing with regexps tends to get even messier. I believe removing the '<' and '>' and the ends and splitting by '-' will be much simpler. Just make sure to group the pieces into the three relevant groups: modifier(s), type and detail (see [1]), while preserving the order of the items in each group. .. [1]: http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm - Tal Einat _______________________________________________ IDLE-dev mailing list IDLE-dev@python.org https://mail.python.org/mailman/listinfo/idle-dev