Menu items not showing up

Hi there,

My first time in the forums. I started with the hello world extended sample code, the snippet that used menus. I wanted to extend that into something more like what I am intending to create. When I added more ‘non-stock’ items under the file menu, they don’t show up. In fact, I can’t get any other items to show up. Example code below:

    mniItem1 = wx.MenuItem(fileMenu, wx.newID, "mni1", "This Better Work...")
    mniItem1 = wx.MenuItem(fileMenu, wx.newID, "mni2", "This Better Work...") 
    mnuItem2 = wx.MenuItem(fileMenu, wx.newID, "mni3", "This Better Work...")
    mnuItem3 = wx.MenuItem(fileMenu, wx.newID, "mni4", "This Better Work...")
    mnuItem4 = wx.MenuItem(fileMenu, wx.newID, "mni5", "This Better Work...")
    mnuItem5 = wx.MenuItem(fileMenu, wx.newID, "mni6", "This Better Work...")
    mnuItem6 = wx.MenuItem(fileMenu, wx.newID, "mni7", "This Better Work...")
    fileMenu.AppendItem(mniItem1)
    fileMenu.AppendItem(mniItem1)
    fileMenu.AppendItem(mnuItem2)
    fileMenu.AppendItem(mnuItem3)
    fileMenu.AppendItem(mnuItem4)
    fileMenu.AppendItem(mnuItem5)
    fileMenu.AppendItem(mnuItem6)

I don’t know wx.newID.
wx.NewID is a function but it is deprecated and “not safe”;
You should use wx.ID_ANY.

Did you do a MenuBar and attach the Menu to the bar?

Here is an example:

import wx

def main():
	app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
	frame = wx.Frame(None, wx.ID_ANY, "Menu Testing") # A Frame is a top-level window.


	# Menubar for the frame
	menuBar = wx.MenuBar()

	# Menu in the menubar
	fileMenu = wx.Menu()

	# Custom item
	# item = wx.MenuItem(parentMenu=fileMenu, id=wx.ID_ANY, text="TestItem", helpString="This Better Work...", kind=wx.ITEM_NORMAL)
	# # Set custom item settings
	# # item.SetBitmap(...)

	# # Append the item to the menu (AppendItem is deprecated)
	# fileMenu.Append(item)

	mniItem0 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni1", "This Better Work...")
	# You had two mniItem1 ...
	# mniItem1 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni1", "This Better Work...")
	mniItem1 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni2", "This Better Work...") 
	mnuItem2 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni3", "This Better Work...")
	mnuItem3 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni4", "This Better Work...")
	mnuItem4 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni5", "This Better Work...")
	mnuItem5 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni6", "This Better Work...")
	mnuItem6 = wx.MenuItem(fileMenu, wx.ID_ANY, "mni7", "This Better Work...")
	fileMenu.Append(mniItem0)
	fileMenu.Append(mniItem1)
	fileMenu.Append(mnuItem2)
	fileMenu.Append(mnuItem3)
	fileMenu.Append(mnuItem4)
	fileMenu.Append(mnuItem5)
	fileMenu.Append(mnuItem6)

	# Attach the menu to the menubar
	menuBar.Append(fileMenu, "&TestMenu")

	# Attached to the frame (the magic that makes the menus show up)
	frame.SetMenuBar(menuBar)

	# status bar at the bottom to see the help string we created.
	statusbar = frame.CreateStatusBar()

	frame.Show(True)     # Show the frame.
	app.MainLoop()


if __name__ == "__main__":
	main()

Example output:
image

I corrected two things in your example. You had mniItem1 twice and you were using AppendItem instead of Append.

Let me know if this helps!