0

I have an application to use this vcmd command with and don't understand it entirely. Here is my validation code:

def validate(self, action, index, value_if_allowed, prior_value, text, validation_type, trigger_type, widget_name):
    if not int(action):
        return True
    elif text in '0123456789.-+':
        try:
            float(value_if_allowed)
            return True
        except ValueError:
            return False
    else:
        return False

I don't get why in this code I need all of these:

action, index, value_if_allowed, prior_value, text, validation_type, trigger_type, widget_name

Why do I need all of these specific to my validation code for it to function correctly and what use are they? The documentation I've seen made sense but some of those '%s', '%i' stuff seemed unnecessary for my specific code yet it only works with all of them included like so:

vcmd = (self.master.register(self.validate), '%d', '%i', '%P', '%s', '%S', '%v', '%V', '%W')

I also want to know what self.master.register does please, I still can't figure that one out.

I have not seen direct answers to my specific question on validation. I edited another post on validation of mine with the information in this post for someone. I need to understand the command well, therefore I have made a separate post on this specific question.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](https://meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Apr 24 '17 at 08:07
  • Please provide a [Minimum, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) that shows a small program that "stalls" with some of the parameters removed. It should only take a dozen or two lines of code to illustrate. – Bryan Oakley Apr 24 '17 at 11:30
  • Will do tomorrow. Thanks – Tweakforce_LG Apr 24 '17 at 11:32

0 Answers0