Newbie needs help with sub-menus

I'm trying to make a simple submenu:

file=wxMenu()
sub = wxMenu()
sub.Append(ID_SUB_GENERATE, "G&enerate", "")
sub.Append(ID_SUB_EXPORT, "E&xport", "")
file.Append(ID_INTERFACE, "Interface", sub, "")

but on the last line I get:
  File "C:\WINDOWS\Desktop\test.py", line 34, in __init__
    file.Append(ID_INTERFACE, "Interface", sub, "")
  File "C:\PYTHON22\lib\site-packages\wxPython\windows.py", line 812, in
Append
    val = apply(windowsc.wxMenu_Append,(self,) + _args, _kwargs)
TypeError: an integer is required

The wxWindows docs say:
void Append(int id, const wxString& item, wxMenu *subMenu, const wxString&
helpString = "")

What am I doing wrong?

Thank you.

Fixed! I needed to use AppendMenu() instead of Append(). AppendMenu() is not
in the wxWindows docs :frowning:

Is there a better collection of docs other than the wxWindows docs?

Thanks again!

···

-----Original Message-----
From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
Sent: Wednesday, January 22, 2003 2:55 PM
To: wxPython-users
Subject: [wxPython-users] Newbie needs help with sub-menus

I'm trying to make a simple submenu:

file=wxMenu()
sub = wxMenu()
sub.Append(ID_SUB_GENERATE, "G&enerate", "")
sub.Append(ID_SUB_EXPORT, "E&xport", "")
file.Append(ID_INTERFACE, "Interface", sub, "")

but on the last line I get:
  File "C:\WINDOWS\Desktop\test.py", line 34, in __init__
    file.Append(ID_INTERFACE, "Interface", sub, "")
  File "C:\PYTHON22\lib\site-packages\wxPython\windows.py", line 812, in
Append
    val = apply(windowsc.wxMenu_Append,(self,) + _args, _kwargs)
TypeError: an integer is required

The wxWindows docs say:
void Append(int id, const wxString& item, wxMenu *subMenu, const wxString&
helpString = "")

What am I doing wrong?

Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

From the 2.4.0.1 docs, wxMenu::Append:

wxPython note: In place of a single overloaded method name, wxPython
implements the following methods:

Append(id, string, helpStr="", checkable=FALSE)
AppendMenu(id, string, aMenu, helpStr="")
AppendItem(aMenuItem)

ka

···

-----Original Message-----
From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
Sent: Wednesday, January 22, 2003 12:05 PM
To: wxPython-users@lists.wxwindows.org
Subject: RE: [wxPython-users] Newbie needs help with sub-menus

Fixed! I needed to use AppendMenu() instead of Append().
AppendMenu() is not
in the wxWindows docs :frowning:

Is there a better collection of docs other than the wxWindows docs?

Thanks again!

-----Original Message-----
From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
Sent: Wednesday, January 22, 2003 2:55 PM
To: wxPython-users
Subject: [wxPython-users] Newbie needs help with sub-menus

I'm trying to make a simple submenu:

file=wxMenu()
sub = wxMenu()
sub.Append(ID_SUB_GENERATE, "G&enerate", "")
sub.Append(ID_SUB_EXPORT, "E&xport", "")
file.Append(ID_INTERFACE, "Interface", sub, "")

but on the last line I get:
  File "C:\WINDOWS\Desktop\test.py", line 34, in __init__
    file.Append(ID_INTERFACE, "Interface", sub, "")
  File "C:\PYTHON22\lib\site-packages\wxPython\windows.py", line 812, in
Append
    val = apply(windowsc.wxMenu_Append,(self,) + _args, _kwargs)
TypeError: an integer is required

The wxWindows docs say:
void Append(int id, const wxString& item, wxMenu *subMenu, const
wxString&
helpString = "")

What am I doing wrong?

Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

That's good and I like that, but IMHO, the C++ prototype should work too..

···

-----Original Message-----
From: Kevin Altis [mailto:altis@semi-retired.com]
Sent: Wednesday, January 22, 2003 3:12 PM
To: wxPython-users@lists.wxwindows.org
Subject: RE: [wxPython-users] Newbie needs help with sub-menus

From the 2.4.0.1 docs, wxMenu::Append:

wxPython note: In place of a single overloaded method name, wxPython
implements the following methods:

Append(id, string, helpStr="", checkable=FALSE)
AppendMenu(id, string, aMenu, helpStr="")
AppendItem(aMenuItem)

ka

-----Original Message-----
From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
Sent: Wednesday, January 22, 2003 12:05 PM
To: wxPython-users@lists.wxwindows.org
Subject: RE: [wxPython-users] Newbie needs help with sub-menus

Fixed! I needed to use AppendMenu() instead of Append().
AppendMenu() is not
in the wxWindows docs :frowning:

Is there a better collection of docs other than the wxWindows docs?

Thanks again!

-----Original Message-----
From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
Sent: Wednesday, January 22, 2003 2:55 PM
To: wxPython-users
Subject: [wxPython-users] Newbie needs help with sub-menus

I'm trying to make a simple submenu:

file=wxMenu()
sub = wxMenu()
sub.Append(ID_SUB_GENERATE, "G&enerate", "")
sub.Append(ID_SUB_EXPORT, "E&xport", "")
file.Append(ID_INTERFACE, "Interface", sub, "")

but on the last line I get:
  File "C:\WINDOWS\Desktop\test.py", line 34, in __init__
    file.Append(ID_INTERFACE, "Interface", sub, "")
  File "C:\PYTHON22\lib\site-packages\wxPython\windows.py", line 812, in
Append
    val = apply(windowsc.wxMenu_Append,(self,) + _args, _kwargs)
TypeError: an integer is required

The wxWindows docs say:
void Append(int id, const wxString& item, wxMenu *subMenu, const
wxString&
helpString = "")

What am I doing wrong?

Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

From: Jason Hihn

That's good and I like that, but IMHO, the C++ prototype should work too..

You can't do that kind of overloading in Python. The best you can do is use
*args, **kwargs and then have an if/elif/else construct in the method to
dispatch based on the tests. That is fairly error-prone and slower, so
whenever you see a method in wxWindows that accepts a variety of argument
lists, then chances are wxPython will have multiple methods corresponding to
the variations. Typically, these are constructors such as the variations
provided for wxBitmap::wxBitmap, but as wxMenu::Append shows, they sometimes
occur for methods too.

ka

···

-----Original Message-----
From: Kevin Altis [mailto:altis@semi-retired.com]
Sent: Wednesday, January 22, 2003 3:12 PM
To: wxPython-users@lists.wxwindows.org
Subject: RE: [wxPython-users] Newbie needs help with sub-menus

>From the 2.4.0.1 docs, wxMenu::Append:

wxPython note: In place of a single overloaded method name, wxPython
implements the following methods:

Append(id, string, helpStr="", checkable=FALSE)
AppendMenu(id, string, aMenu, helpStr="")
AppendItem(aMenuItem)

ka

> -----Original Message-----
> From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
> Sent: Wednesday, January 22, 2003 12:05 PM
> To: wxPython-users@lists.wxwindows.org
> Subject: RE: [wxPython-users] Newbie needs help with sub-menus
>
>
> Fixed! I needed to use AppendMenu() instead of Append().
> AppendMenu() is not
> in the wxWindows docs :frowning:
>
> Is there a better collection of docs other than the wxWindows docs?
>
> Thanks again!
>
> -----Original Message-----
> From: Jason Hihn [mailto:jhihn@paytimepayroll.com]
> Sent: Wednesday, January 22, 2003 2:55 PM
> To: wxPython-users
> Subject: [wxPython-users] Newbie needs help with sub-menus
>
>
> I'm trying to make a simple submenu:
>
> file=wxMenu()
> sub = wxMenu()
> sub.Append(ID_SUB_GENERATE, "G&enerate", "")
> sub.Append(ID_SUB_EXPORT, "E&xport", "")
> file.Append(ID_INTERFACE, "Interface", sub, "")
>
> but on the last line I get:
> File "C:\WINDOWS\Desktop\test.py", line 34, in __init__
> file.Append(ID_INTERFACE, "Interface", sub, "")
> File "C:\PYTHON22\lib\site-packages\wxPython\windows.py", line 812, in
> Append
> val = apply(windowsc.wxMenu_Append,(self,) + _args, _kwargs)
> TypeError: an integer is required
>
> The wxWindows docs say:
> void Append(int id, const wxString& item, wxMenu *subMenu, const
> wxString&
> helpString = "")
>
> What am I doing wrong?
>
> Thank you.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Jason Hihn wrote:

Fixed! I needed to use AppendMenu() instead of Append(). AppendMenu() is not
in the wxWindows docs :frowning:

Is there a better collection of docs other than the wxWindows docs?

There will be.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!