You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The two validating functions could be merged two one dynamic validating function which accepts a keyword (e.g. called "floattype") so that depending on value of that keyword argument a different regex is compiled.
See this PSEUDO-CODE:
def validate_input(self,name,index,mode,floattype=None):
if floattype == "unit interval":
regex = re.compile(r'^0(\.[0-9]*)?$|^1(\.0?)?$|^$')
regex = re.compile(r'^[+-]?((\d+\.?\d*)|(\.\d+))$|^$')
for var in self.input_vars:
if name == str(var):
if not regex.match(var.get()):
var.set(var.get()[:-1])
self.master.bell()
On the other hand I don't really find the suggested methods in the stackoverflow-posts readable, so it could also be a trade-off question (readability vs. length of code)
The two validating functions could be merged two one dynamic validating function which accepts a keyword (e.g. called "floattype") so that depending on value of that keyword argument a different regex is compiled.
See this PSEUDO-CODE:
See also these stackoverflow-posts:
Pass Multiple Arguments to Callback for a StringVar in Tkinter
How can I pass arguments to Tkinter button's callback command?
The text was updated successfully, but these errors were encountered: