Arguments for button command via Tkinter?
- From: "dakman@xxxxxxxxx" <dakman@xxxxxxxxx>
- Date: 31 Oct 2005 06:15:46 -0800
Recently, I have been needing to do this alot and I can never find a
way around it, the main reason I want to do this is because for example
in the application I am making right now, it creates a grid of buttons
in a loop and they all have the same purpose so they need to call the
same method, within this method they need to change the background
color of the button clicked, I've tried stuff like...
button['command'] = lambda: self.fill(button)
def fill(self, wid):
button['bg'] = '#ff0000'
But that's no good, everytime it I do click a button the lambda method
I have setup keeps getting recreated so all of the button commands
point to the same lambda method, I have also tried appending them to an
array, and calling them from that.
Anyone have any clue as of what to do? Thanks.
.
- Prev by Date: Re: mixin helper class for unknown attribute access?
- Next by Date: Windows - Need to process quotes in string...
- Previous by thread: Re: mixin helper class for unknown attribute access?
- Next by thread: Windows - Need to process quotes in string...
- Index(es):