[wxPython] keyword arguments and wxRadioBox

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] keyword arguments and wxRadioBox

Jeffrey Kunce
This works OK:
        rb = wxRadioBox(self, rbID, "", wxDefaultPosition, wxDefaultSize,
                        self.optionTitles, 3, wxRA_SPECIFY_ROWS | wxNO_BORDER)

But this doesn't:
        rb = wxRadioBox(self, rbID, "", choices=self.optionTitles,
        majorDimension=3, style=wxRA_SPECIFY_ROWS | wxNO_BORDER)

Traceback (innermost last):
  ...
  File "F:\Software\Python\wxPython\controls.py", line 682, in __init__
    self.this = apply(controlsc.new_wxRadioBox,_args,_kwargs)
TypeError: choices is an invalid keyword argument for this function


Bug? or an I missing something?

Thanks.
  --Jeff


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] keyword arguments and wxRadioBox

Robin Dunn
> This works OK:
>         rb = wxRadioBox(self, rbID, "", wxDefaultPosition, wxDefaultSize,
>                         self.optionTitles, 3, wxRA_SPECIFY_ROWS |
wxNO_BORDER)

>
> But this doesn't:
>         rb = wxRadioBox(self, rbID, "", choices=self.optionTitles,
>         majorDimension=3, style=wxRA_SPECIFY_ROWS | wxNO_BORDER)
>
> Traceback (innermost last):
>   ...
>   File "F:\Software\Python\wxPython\controls.py", line 682, in __init__
>     self.this = apply(controlsc.new_wxRadioBox,_args,_kwargs)
> TypeError: choices is an invalid keyword argument for this function
>
>
> Bug? or an I missing something?

No it's my fault.  I haven't put a note in the docs about this yet.  The
short answer is to use LIST as the arg name.  See below for the long answer:


Whenever a set of C++ arguments like:

     int n, someType choices[]

is reduced to a single Python list argument, I use a SWIG typemap to do the
dirty work.  To make sure that the typemap isn't accidentally used for some
other "choices" arg that isn't supposed to be reduced like this, I always
rename the choices arg to LIST and use that name for the typemap.  (See
my_typemaps.i if you're interested in how it's done.)  Now that SWIG supports
keyword arguments and I am using it, this practice has caused some name
mismatches like you have found.

I suppose I have two alternatives:

1. Continue using LIST and just update the docs to mention it in the Python
Note.  This would probably help, but not eliminate the confusion as some
people won't always read the note...

2. Change the all the names back to choices, fix the typemaps and be careful
about how the name might be used elsewhere.  This would be backwards
incompatible for anybody currently using the name LIST.

Prefeneces anybody?

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] keyword arguments and wxRadioBox

Markus Gritsch
Robin Dunn wrote:

> 2. Change the all the names back to choices, fix the typemaps and be careful
> about how the name might be used elsewhere.  This would be backwards
> incompatible for anybody currently using the name LIST.

I would prefere this choice. I think being consistent with the current
documentation without adding a note (which is mayme not read) is more important
than breaking up some code.

--
Markus

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] keyword arguments and wxRadioBox

Mike C. Fletcher-3
I would concur.  Following the C++ naming seems better if possible.  I doubt
many people are currently using LIST in their code, and if they are, a
simple search-and-replace should fix it.

Enjoy,
Mike

-----Original Message-----
From: Markus Gritsch [mailto:[hidden email]]
Sent: Thursday, January 13, 2000 5:08 AM
To: wxPython-users list
Subject: Re: [wxPython] keyword arguments and wxRadioBox


Robin Dunn wrote:

> 2. Change the all the names back to choices, fix the typemaps and be
careful
> about how the name might be used elsewhere.  This would be backwards
> incompatible for anybody currently using the name LIST.

I would prefere this choice. I think being consistent with the current
documentation without adding a note (which is mayme not read) is more
important
than breaking up some code.

--
Markus

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users