Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Python - Move() function in wxPython
Next article icon

wxPython - Replace() function in wxPython

Last Updated : 11 May, 2020
Comments
Improve
Suggest changes
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 : The title of the menu.
Parameter Input Type Description
pos int The position of the new menu in the menu bar
menu wx.Menu The menu to add.
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 :

Next Article
Python - Move() function in wxPython

R

RahulSabharwal
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 - SetBitmap() function in wxPython
    In this article we are going we are going to learn about SetBitmap() function associated with wx.MenuItem class of wxPython. SetBitmap() sets the bitmap for the menu item. SetBitmap must be called before the item is appended to the menu, i.e. appending the item without a bitmap and setting one later
    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
  • wxPython | EnableTool() function in wxPython
    In this article we are going to learn about EnableTool() function of wx.ToolBar class of wxPython. It is another important function in wx.Toolbar class. EnableTool() function is used to enable or disable a particular tool in Toolbar. It takes 'enable' bool parameter which is when true enable the too
    2 min read
  • Python - GetMenu() function in wxPython
    In this particular article we are going to learn about GetMenu() function of wx.MenuBar class of wxPython. GetMenu() is function in wx.MenuBar class that return wx.Menu object present in Menubar. It needs only index of menu present on menubar. Syntax : wx.MenuBar.GetMenu(self, menuindex) Parameters
    1 min read
  • wxPython | GetMargins() function in python
    In this article we are going to learn about GetMargins() function of class wx.ToolBar in wxPython. GetMargins() function returns the left/right and top/bottom margins, which are also used for inter-toolspacing. GetMargins takes no parameters. Syntax: wx.ToolBar.GetMargins(self) Parameters: No Parame
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences