Python 3 WxPython Bitmap png/jpg Image Button GUI Desktop App Full Project For Beginners

Python 3 WxPython Bitmap png/jpg Image Button GUI Desktop App Full Project For Beginners

 

Welcome folks today in this blog post we will be looking at wxpython bitmap png/jpg Image Button. 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

 

app.py

 

import wx

class BitmapButtonFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Bitmap Button Example', 
                size=(200, 150))
        panel = wx.Panel(self, -1)
        bmp = wx.Image("bitmap.bmp", wx.BITMAP_TYPE_BMP).ConvertToBitmap()
        self.button = wx.BitmapButton(panel, -1, bmp, pos=(10, 20))
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)
        self.button.SetDefault()
        self.button2 = wx.BitmapButton(panel, -1, bmp, pos=(100, 20), 
            style=0)
        self.Bind(wx.EVT_BUTTON, self.OnClick, self.button2)

    def OnClick(self, event):
        self.Destroy()
        
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = BitmapButtonFrame()
    frame.Show()
    app.MainLoop()

 

See also  Python 3 WxPython HTML Help Dialog Popup Menu in GUI Desktop App Full Project For Beginners

 

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

 

python app.py

 

 

Leave a Reply