wxPython - Replace() function in wxPython Last Updated : 11 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Another function in wx.MenuBar class is Replace() function. If we ever want to replace a menu from menubar we use Replace() function. It takes three main parameters that is position of menu we want to replace, menu we want to add, title of new menu. Syntax : wx.MenuBar.Replace(self, pos, menu, title) Parameters : Parameter Input Type Description pos int The position of the new menu in the menu bar menu wx.Menu The menu to add. The title of the menu. title string The menu to add. Let's create a window with two menu items Menu_one and Menu_two. Code : Python3 1== import wx class Example(wx.Frame): def __init__(self, *args, **kw): super(Example, self).__init__(*args, **kw) # create MenuBar using MenuBar() function menubar = wx.MenuBar() # add menu to MenuBar fm1 = wx.Menu() fileitem = fm1.Append(20, "one") fm2 = wx.Menu() fileitem2 = fm2.Append(20, "two") menubar.Append(fm1, '&Menu_one') menubar.Append(fm2, '&Menu_two') self.SetMenuBar(menubar) self.SetSize((300, 200)) self.SetTitle('Menu Bar') def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop() if __name__ == '__main__': main() Window: Now lets replace Menu_two with new_Menu. Code for Replace : Python3 1== import wx class Example(wx.Frame): def __init__(self, *args, **kw): super(Example, self).__init__(*args, **kw) # create MenuBar using MenuBar() function menubar = wx.MenuBar() # add menu to MenuBar fm1 = wx.Menu() fileitem = fm1.Append(20, "one") fm2 = wx.Menu() fileitem2 = fm2.Append(21, "two") fm3 = wx.Menu() fileitem3 = fm3.Append(22, "new") menubar.Append(fm1, '&Menu_one') menubar.Append(fm2, '&Menu_two') self.SetMenuBar(menubar) self.SetSize((300, 200)) self.SetTitle('Menu Bar') menubar.Replace(1, fm3, "new_Menu") def main(): app = wx.App() ex = Example(None) ex.Show() app.MainLoop() if __name__ == '__main__': main() Output : Comment More infoAdvertise with us Next Article Python - Create() function in wxPython R RahulSabharwal Follow Improve Article Tags : Python Python-gui Python-wxPython Practice Tags : python Similar Reads Python - Move() function in wxPython In this particular article we will learn, how can we move our window to a particular point. This can be achieved using Move() function in wx.Window class of wxPython. Move() takes x and y points to move window to a particularx, y point. Syntax : wx.Move(self, x, y, flags=SIZE_USE_EXISTING) Parameter 1 min read wxPython | Exit() function in wxPython In this article we are going to learn about wx.Exit() which is a inbuilt parent function present in wxPython.Exit() function exits application after calling wx.App.OnExit . Should only be used in an emergency: normally the top-level frame should be deleted (after deleting all other frames) to termin 1 min read wxPython | InsertSimpleTool() function in python In this article we are going to learn about InsertSimpleTool() function associated with wx.ToolBar class of wxPython. InsertSimpleTool() function is another old style method to insert a tool in the toolbar. InsertSimpleTool() function inserts the tool with the specified attributes into the toolbar a 2 min read wxPython - GetLabelText() function in wxPython In this article we are going to learn about GetLabelText() function associated with wx.MenuItem class of wxPython. GetLabelText() function strips all accelerator characters and mnemonics from the given text. For Example: wx.MenuItem.GetLabelfromText("&Hello\tCtrl-h") will return just "Hello" . T 1 min read Python - Create() function in wxPython In this particular article we are going to learn about Create() function present in wx.Frame class. Create function is similar to Frame() constructor of wx.Frame class. Create function is used in two-step frame construction. Syntax : wx.Frame.Create(parent, id=ID_ANY, title="", pos=DefaultPosition, 1 min read wxPython - SetLabel() function in wx.MenuBar Another important function in wx.MenuBar is SetLabel() function in wx.MenuBar class of wxPython. SetLabel() function is used to change the Label(title) of the menu item in menubar. It is used only after the menubar has been associated with a frame. Syntax : wx.MenuBar.SetLabel(self, id, label) Param 1 min read Like