M
Mike
I'm trying to arrange for an Entry widget to check whether its data
is all digits and whether the number represented is small enough.
The validate function seem to be called once at startup and not
afterwards:
import sys, Tkinter, tkFileDialog, tkMessageBox
tk=Tkinter
tkfd=tkFileDialog
....
class Functor :
def __init__(self, func, data) :
self.func=func
self.data=data
def __call__(self) : return self.func(self.data)
....
class Levels(tk.Frame) :
def __init__(self, parent) :
tk.Frame.__init__(self, parent)
self.tv=[]
for rgb in range(3) :
self.tv.append(tk.StringVar())
e=tk.Entry(self, textvariable=self.tv[rgb], width=5,
validate='all',
validatecommand=Functor(self.vc, self.tv
[rgb]) )
self.tv[rgb].set(str(levels_av_max))
e.grid(row=2, column=rgb)
lab=tk.Label(self, text='RGB'[rgb])
lab.grid(row=1, column=rgb)
doit=tk.Button(self, text='set levels', command=self.pushed)
doit.grid(row=0, column=0, columnspan=3)
def vc(self, arg2=None) :
print 'vc:', arg2.get()
The print statement run 3 times at startup.
Editing an Entry does not cause any printing.
Any ideas?
is all digits and whether the number represented is small enough.
The validate function seem to be called once at startup and not
afterwards:
import sys, Tkinter, tkFileDialog, tkMessageBox
tk=Tkinter
tkfd=tkFileDialog
....
class Functor :
def __init__(self, func, data) :
self.func=func
self.data=data
def __call__(self) : return self.func(self.data)
....
class Levels(tk.Frame) :
def __init__(self, parent) :
tk.Frame.__init__(self, parent)
self.tv=[]
for rgb in range(3) :
self.tv.append(tk.StringVar())
e=tk.Entry(self, textvariable=self.tv[rgb], width=5,
validate='all',
validatecommand=Functor(self.vc, self.tv
[rgb]) )
self.tv[rgb].set(str(levels_av_max))
e.grid(row=2, column=rgb)
lab=tk.Label(self, text='RGB'[rgb])
lab.grid(row=1, column=rgb)
doit=tk.Button(self, text='set levels', command=self.pushed)
doit.grid(row=0, column=0, columnspan=3)
def vc(self, arg2=None) :
print 'vc:', arg2.get()
The print statement run 3 times at startup.
Editing an Entry does not cause any printing.
Any ideas?