I have a custom slider, at run time different piece of data can be
hooked with this slider. For example, when you selected data[3],
data[3] is hooked with slider and data[3] value can be changed. Every
element of data has a unique string for it's identification. When
data[n] is getting hooked with slider, I am changing slider's name
with
slider.SetName(data[n].GetUniqueId()).
1. Hook data[0] change name and change value (undo registered)
2. Hook data[1] change name and change value (undo registered)
3. undo (this procedure search for a widget in property editor with
name = current data element's unique id.
The result is true because currently the name of the slider
matches with data[1]'s string id and slider's value is
changed
4. undo (This time search will return false as data[0]'s unique id is
different and currently the name of the slider is
data[1]'s unique id.
5. I think changing name of a widget at run time doesn't affect. Is it
correct? Is there any other better method?
shall I use a positive integer for id instead of string one and
change the widgets id at run time so that it can be uniquely
identified?
The UI is property editor of a node. It's created at run time and it
may or may not exist while undo-redo.
Prashant
···
On Aug 27, 1:42 pm, <GadgetSt...@live.co.uk> wrote:
--------------------------------------------------
From: "King" <animator...@gmail.com>
Sent: Friday, August 27, 2010 7:59 AM
To: "wxPython-users" <wxpython-users@googlegroups.com>
Subject: [wxPython-users] SetName at run time for widget identification
> Hi,
> I have a custom slider, at run time different piece of data can be
> hooked with this slider. For example, when you selected data[3],
> data[3] is hooked with slider and data[3] value can be changed. Every
> element of data has a unique string for it's identification. When
> data[n] is getting hooked with slider, I am changing slider's name
> with
> slider.SetName(data[n].GetUniqueId()).
> 1. Hook data[0] change name and change value (undo registered)
> 2. Hook data[1] change name and change value (undo registered)
> 3. undo (this procedure search for a widget in property editor with
> name = current data element's unique id.
> The result is true because currently the name of the slider
> matches with data[1]'s string id and slider's value is
> changed
> 4. undo (This time search will return false as data[0]'s unique id is
> different and currently the name of the slider is
> data[1]'s unique id.
> 5. I think changing name of a widget at run time doesn't affect. Is it
> correct? Is there any other better method?
Wouldn't it be simpler to have an OnSelect method that stored in which
simply set self.selected to the item index and and the slider and undo
values to the current value for that item and an OnSlide method that called
set value on data[self.selected]
Gadget/Steve
> shall I use a positive integer for id instead of string one and
> change the widgets id at run time so that it can be uniquely
> identified?
> Prashant
> --
> To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
> or visithttp://groups.google.com/group/wxPython-users?hl=en
Yes, that is fine. The name property is not used for anything critical in wx except for in the old Motif port and also while loading items from XRC files.
···
On 8/26/10 11:59 PM, King wrote:
5. I think changing name of a widget at run time doesn't affect. Is it
correct?
So what's the solution? Shall I change the control's id at run time to
identify it?
Prashant
···
On Aug 27, 9:45 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 8/26/10 11:59 PM, King wrote:
> 5. I think changing name of a widget at run time doesn't affect. Is it
> correct?
Yes, that is fine. The name property is not used for anything critical
in wx except for in the old Motif port and also while loading items from
XRC files.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
Using the name property is okay. The only time you might have a conflict is if you are using XRC, but even then after you've loaded the UI there should not be any problems with changing the names.
···
On 8/27/10 10:09 AM, King wrote:
So what's the solution? Shall I change the control's id at run time to
identify it?
Using the name property is okay. The only time you might have a
conflict is if you are using XRC, but even then after you've loaded the
UI there should not be any problems with changing the names.
Ok,
Check the sample app here:
The name of panel has been changed but wx.FindWindowByName is still
returns true based on old name. It's printing the correct name after
changing it but something is wrong.
Changing of name is working with button, instead of panel you change
the name of the button 'b1' and search and it'll return false.
Try using a name besides "panel". That is the default name and so that may be affecting the search somehow.
···
On 8/30/10 3:19 AM, King wrote:
Using the name property is okay. The only time you might have a
conflict is if you are using XRC, but even then after you've loaded the
UI there should not be any problems with changing the names.
The name of panel has been changed but wx.FindWindowByName is still
returns true based on old name. It's printing the correct name after
changing it but something is wrong.
Changing of name is working with button, instead of panel you change
the name of the button 'b1' and search and it'll return false.