WxPython Popup Menubar and Statusbar Example Using Menu Class GUI Desktop App Full Tutorial For Beginners

WxPython Popup Menubar and Statusbar Example Using Menu Class GUI Desktop App Full Tutorial For Beginners

 

 

Welcome folks today in this blog post we will be building a popup menubar and statusbar inside wxpython gui  desktop app in python using menu class. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to install the below library using the pip command as shown below

 

pip install wxpython

 

After installing this library you need to make an app.py file and copy paste the following code

See also  Python Tkinter GUI Script to Make a Simple Age Calculator From Date of Birth (DOB) Full Project For Beginners

 

app.py

 

import wx

class MyApp(wx.App):
    
    def OnInit(self):
       frame = MyFrame("Hello World", (50, 60), (450, 340))
       frame.Show()
       self.SetTopWindow(frame)
       return True
    
class MyFrame(wx.Frame):
    
    def __init__(self, title, pos, size):
        wx.Frame.__init__(self, None, -1, title, pos, size)
        menuFile = wx.Menu()
        menuFile.Append(1, "&About...")
        menuFile.AppendSeparator()
        menuFile.Append(2, "E&xit")
        menuBar = wx.MenuBar()
        menuBar.Append(menuFile, "&File")
        self.SetMenuBar(menuBar)
        self.CreateStatusBar()
        self.SetStatusText("Welcome to wxPython!")
        self.Bind(wx.EVT_MENU, self.OnAbout, id=1)
        self.Bind(wx.EVT_MENU, self.OnQuit, id=2)
        
    def OnQuit(self, event):
        self.Close()
         
    def OnAbout(self, event):
        wx.MessageBox("This is a wxPython Hello world sample", 
                "About Hello World", wx.OK | wx.ICON_INFORMATION, self)
                
if __name__ == '__main__':
    app = MyApp(False)
    app.MainLoop()

 

See also  Python 3 Tkinter Display Image (PNG,JPG,GIF) From Base64 Code Using PhotoImage Widget GUI Desktop App Full Project For Beginners

 

So as you can see in the above figure we are using the menu class and appending multiple menu items into it and then showing the menu in the gui desktop app

 

If you execute the above python script by typing the below command

 

See also  Python 3 WxPython Drag and Drop Files and Printing Full Path Example in GUI Desktop App Full Project For Beginners

python app.py

 

 

Leave a Reply