The more standard method of adding information to an event call is to
add it to the event when it is raised but as the id of the originating
window/control is already in the event information you just need to use
it in your handler. See wxevent::GetEventObject() for more details.
Gadget/Steve
···
On 12/08/2012 4:47 AM, Mark Budde wrote:
Please go easy on me, I'm pretty new to programming.
I used a loop to generate a bunch of text boxes, so the user can edit attributes of a dictionary. I figured that I would pass an argument to the handler, specify the origin of the text box, but when I do that, it overrides the event. Is there a way to pass both the event and an extra argument to the handler? Alternatively, is there a more standard way of accomplishing this?
for file_name in sorted(parent.spec_file_dict.keys()):
sample = parent.spec_file_dict[file_name]
name = wx.StaticText(panel, label=file_name)
time = wx.TextCtrl(panel, size=(135,-1))
time.SetValue(sample['time'])
time.SetFont(parent.font1)
self.Bind(wx.EVT_TEXT, self.testfunc('extra argument'), time)
dilution = wx.TextCtrl(panel, size=(200,-1))
dilution.SetValue(" ".join(["%s" % el for el in sample['dil']]))
dilution.SetFont(parent.font1)
grid.Add(name, pos=(i,0))
grid.Add(time, pos=(i,1))
grid.Add(dilution, pos=(i,2))
i += 1
Thanks Steve. I’m new to this and had just been considering IDs an annoyance which I should set to -1 
Using your advice, I set the IDs for time as 1000+i, and the IDs for dilution as 2000+i and everything is working well. Is the acceptable practice, or should I start above some number to avoid conflicts with internally assigned IDs? Google is coming up surprisingly short on wxpython IDs.
Thanks,
Mark
···
On Saturday, August 11, 2012 11:19:45 PM UTC-7, Gadget Steve wrote:
On 12/08/2012 4:47 AM, Mark Budde wrote:
Please go easy on me, I’m pretty new to programming.
I used a loop to generate a bunch of text boxes, so the user can edit attributes of a dictionary. I figured that I would pass an argument to the handler, specify the origin of the text box, but when I do that, it overrides the event. Is there a way to pass both the event and an extra argument to the handler? Alternatively, is there a more standard way of accomplishing this?
for file_name in sorted(parent.spec_file_dict.keys()):
sample = parent.spec_file_dict[file_name]
name = wx.StaticText(panel, label=file_name)
time = wx.TextCtrl(panel, size=(135,-1))
time.SetValue(sample['time'])
time.SetFont(parent.font1)
self.Bind(wx.EVT_TEXT, self.testfunc('extra argument'), time)
dilution = wx.TextCtrl(panel, size=(200,-1))
dilution.SetValue(" ".join(["%s" % el for el in sample['dil']]))
dilution.SetFont(parent.font1)
grid.Add(name, pos=(i,0))
grid.Add(time, pos=(i,1))
grid.Add(dilution, pos=(i,2))
i += 1
The more standard method of adding information to an event call is to
add it to the event when it is raised but as the id of the originating
window/control is already in the event information you just need to use
it in your handler. See wxevent::GetEventObject() for more details.
Gadget/Steve
Hi Mark,
There is a "First Unused ID" available to start from but I find that
using wx.ID_ANY, (which happens to equal -1), is good to use when
creating windows/controls because it will cause the system to create a
new ID each call, i.e. no maintenance issues but the good news is that
you can keep references to the item by using the returned value from the
create call.
BTW this is one of the newsgroups that prefer bottom posting, like this,
so that you can just read the last post and get the entire conversation
in context by starting at the top.
Gadget/Steve
···
On 12/08/2012 5:00 PM, Mark Budde wrote:
Thanks Steve. I'm new to this and had just been considering IDs an
annoyance which I should set to -1 
Using your advice, I set the IDs for time as 1000+i, and the IDs for
dilution as 2000+i and everything is working well. Is the acceptable
practice, or should I start above some number to avoid conflicts with
internally assigned IDs? Google is coming up surprisingly short on
wxpython IDs.
Thanks,
Mark