DDev
May 19, 2015, 2:21pm
3
Thaumaturge:
Hmm… It’s a pity that the text-colour doesn’t seem to be one of the parameters that DirectButton allows one to specify as a list of values, one for each state…
That said, you could perhaps create four DirectLabels, one of each colour, and, storing them in a list, pass them into the DirectButton’s “geom” parameter.
Regarding “bind”, I think that the problem is that “bind” expects a function-reference, and an optional set of extra arguments; what you’re currently passing to it, I believe, is the result of calling “linkButton.configure”, which may well be “None”. In short, if your code includes a method-name followed by the relevant brackets and parameters, that method is (in general) called there and then; the method-name alone provides a reference to that method.
Consider this quick example:
def mew(loudness):
return "you mew " + loudness
val = mew("loudly")
# val now holds the string "you mew loudly"
val = mew
# val now holds a reference to the function "mew"
In terms of “bind”, I think that something like this might work:
# I'm assuming that this takes place within an object,
# hence the use of "self"; if not, adjust accordingly.
linkButton.bind(DGG.WITHIN, self.setButtonColour, extraArgs = [linkButton, (1, 1, 1, 1)])
# Elsewhere:
def setButton(self, btn, colour):
btn["text_fg"] = colour
Your solution worked, so I thank you for that one it was Much Appreciated. This even helped to further explain the usage of extraArgs for me, and how it ties in with object execution. However, I kept getting a typeError saying that it takes 2 arguments and 3 were given, so i added an extra parameter to setButtonColour to get around this.