i have a program where i use a while loop to create buttons dynamically.
Each button is created with, for a label, the name of one the drives on the machine(using the result of the fsutils command).
Up to this point everything works fine, if i have drive C: and drive D: available on my computer, then program is gonna create two wx.Buttons which will be displayed with the drive name as the label on each button.
Now, i want to be able to bind the dynamically created buttons to the listDir() method so that for example, when i try and click on one of the created buttons it executes a dir command using the drive letter just selected.
Only, the listDir() method is constantly referring to the last button that it has been bound to in the while loop... .
In other words, if i have two drives on my computer, C: and D:, the program will create two buttons, one with C: and the other one with D: on the label, and wether i click on either the C: or the D: button, i end up with the same result as if i had clicked twice on the D: button only...
Obviously, i understand that the listDir method will automatically refer to the last button that it has been bound to, even if you dynamically assigned a 'name' parameter to the button.
But there has got to be a way to bind 'unique' events to buttons created dynamically, hasn't there?
Thanks for your suggestions,