I want to be able to clear a partially filled form, back to its original
state. Mostly I can do this with the Clear() methods of the various
controls but, for wxChoice, Clear() deletes all the choice strings. Having
a blank field as a valid choice is not an option. The only way I have come
up with is:
def clearchoice(wxch):
" Clear the on-screen choice for wxChoice instance 'wxch'"
store = []
for num in range(wxch.GetCount()):
store.append(wxch.GetString(num))
wxch.Clear()
wxch.Append('')
wxch.SetSelection(0)
wxch.Clear()
for num in range(len(store)):
wxch.Append(store[num])
i.e. save and delete all the choices, add and choose a blank field and
then restore everything again. Have I missed some easier way?
Regards,
David Hughes
Forestfield Software Ltd
www.forestfield.co.uk
I don't think there is an easier way without having a blank field.
On the other hand one choice should always be selected, because
otherwise the user has no option to return to the initial selection
state.
If you want the user to be able to select nothing, give him a
'nothing' choice, otherwise select one just after creating the
wxChoice. On Linux this is done automatically.
Thomas
···
On Thu, Aug 01, 2002 at 04:02:00PM +0100, David Hughes wrote:
I want to be able to clear a partially filled form, back to its original
state. Mostly I can do this with the Clear() methods of the various
controls but, for wxChoice, Clear() deletes all the choice strings. Having
a blank field as a valid choice is not an option. The only way I have come
up with is:
def clearchoice(wxch):
" Clear the on-screen choice for wxChoice instance 'wxch'"
store =
for num in range(wxch.GetCount()):
store.append(wxch.GetString(num))
wxch.Clear()
wxch.Append('')
wxch.SetSelection(0)
wxch.Clear()
for num in range(len(store)):
wxch.Append(store[num])
i.e. save and delete all the choices, add and choose a blank field and
then restore everything again. Have I missed some easier way?
--
Email: tkoester@intevation.de
http://intevation.de/~tkoester/
> I want to be able to clear a partially filled form, back to its
> original state. Mostly I can do this with the Clear() methods of the
> various controls but, for wxChoice, Clear() deletes all the choice
> strings...<snip>
I don't think there is an easier way without having a blank field.
On the other hand one choice should always be selected, because
otherwise the user has no option to return to the initial selection
state.
If you want the user to be able to select nothing, give him a
'nothing' choice, otherwise select one just after creating the
wxChoice. On Linux this is done automatically.
Thanks for the confirmation, Thomas. I see what you are saying, but I need
the user to make a 'not null' choice, such as Male/Female. However, to
make an arbitrary initial choice for him/(her?) seems wrong - not to say,
in this case, sexist 
Regards,
David Hughes
Forestfield Software Ltd
www.forestfield.co.uk
But if the user has the option to not select anything, then you may
name the selections like ["(choose one)", "male", "female"]. You
have to check the selection in any case, so it doesn't matter if it's
nothing-selected or "(choose-one)".
Thomas
···
On Thu, Aug 01, 2002 at 07:38:00PM +0100, David Hughes wrote:
> If you want the user to be able to select nothing, give him a
> 'nothing' choice, otherwise select one just after creating the
> wxChoice. On Linux this is done automatically.
Thanks for the confirmation, Thomas. I see what you are saying, but I need
the user to make a 'not null' choice, such as Male/Female. However, to
make an arbitrary initial choice for him/(her?) seems wrong - not to say,
in this case, sexist 
--
Email: tkoester@intevation.de
http://intevation.de/~tkoester/
You have to check the selection in any case, so it doesn't matter
if it's nothing-selected or "(choose-one)".
Sounds like its platform dependent. Under MS Windows nothing is displayed
until the user makes a choice so there is no need for the 3rd 'Not chosen
yet' option. But if it's different under Linux(?) I will need to follow
your suggestion for a general-purpose solution.
Regards,
David Hughes
Forestfield Software Ltd
www.forestfield.co.uk
It's different on Linux, see
GREAT-ER: SciParam - SciParam GUI features for
example screen shots.
Thomas
···
On Fri, Aug 02, 2002 at 06:59:00AM +0100, David Hughes wrote:
> You have to check the selection in any case, so it doesn't matter
> if it's nothing-selected or "(choose-one)".
Sounds like its platform dependent. Under MS Windows nothing is displayed
until the user makes a choice so there is no need for the 3rd 'Not chosen
yet' option. But if it's different under Linux(?) I will need to follow
your suggestion for a general-purpose solution.
--
Email: tkoester@intevation.de
http://intevation.de/~tkoester/