1

forループで作成され、個別に検証したい辞書に記録されたエントリボックスのセットがあります。それらを作成するループは次のとおりです。

vcmd = (self.register(self.VE), '%P')
for pos in [(i,j) for i in range(9) for j in range(9)]:
            self.inputDict[pos] = tk.StringVar()
            self.entryDict[pos] = tk.Entry(font = ('Arial', 20, 'bold'),
                                           textvariable = self.inputDict[pos],
                                           borderwidth = 1, width = 2,
                                           justify = 'center',
                                           validatecommand = vcmd,
                                           validate = 'key')

self.VE のコードは次のとおりです。

def VE(self, P, pos):
    if P in [str(i) for i in map(chr,range(49,58))]:
        self.solution.insertVal(P,pos)
    elif P == '': self.solution.removeVal(pos)
    return P in [str(i) for i in map(chr,range(49,58))]+['']

私の問題は、この回答で提供されるリストに含まれていない引数をVEに取得させる方法がわからないことです。以下に複製します。

# valid percent substitutions (from the Tk entry man page)
# %d = Type of action (1=insert, 0=delete, -1 for others)
# %i = index of char string to be inserted/deleted, or -1
# %P = value of the entry if the edit is allowed
# %s = value of entry prior to editing
# %S = the text string being inserted or deleted, if any
# %v = the type of validation that is currently set
# %V = the type of validation that triggered the callback
#      (key, focusin, focusout, forced)
# %W = the tk name of the widget

を定義する行に変更を加える必要があると思いますがvcmd、検証コマンドがエントリの位置 (つまり、の値pos) と試行された入力。そのリストにない引数を検証コマンドに追加するにはどうすればよいですか?

4

1 に答える 1