Background image is not taking full length height from the bottom. Is there someone to have any approach to get it full length height for parent control(panel)

Background image is not taking full length height from the bottom. Is there someone to have any approach to get it full length height for parent control(panel).

I have placed a background image in panel. and also resizing and scaling background images accordance to panel size. Please find below code sample.

import wx.grid

class Frame ( wx.Frame ):

def __init__( self, parent ):
    wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Test", pos=wx.DefaultPosition, size=wx.DefaultSize)
    self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
    bSizer11 = wx.BoxSizer( wx.HORIZONTAL )
    self.img1=wx.Image(".\splash.png", wx.BITMAP_TYPE_ANY)
    self.m_bitmap3 = wx.StaticBitmap( self, wx.ID_ANY, wx.BitmapFromImage(self.img1), wx.DefaultPosition, wx.DefaultSize, 0 )
    bSizer11.Add( self.m_bitmap3, 1, wx.EXPAND, 0 )
    self.Bind(wx.EVT_SIZE, self.onResize)
    self.SetSizer( bSizer11 )
    self.Layout()
    self.Centre(wx.BOTH)
    self.Show()

def onResize(self, event):
    frame_size = self.GetSize()
    frame_h = (frame_size[0])
    frame_w = (frame_size[1])
    img1 = self.img1.Scale(frame_h,frame_w)
    self.m_bitmap3.SetBitmap(wx.BitmapFromImage(img1))
    self.Refresh()
    self.Layout()

if name == “main”:
app = wx.App()
Frame(None)
app.MainLoop()

The output is something like

I guess the aspect ratio (ScaleMode) :smirk:

I ran your code using Python 3.10.6 + wxPython 4.2.0 gtk3 (phoenix) wxWidgets 3.2.0 on Linux Mint 21.1.

The only changes I made were to fix 3 deprecation warnings and to specify one of my own images.

This is the modified code:

import wx

class Frame ( wx.Frame ):
    def __init__( self, parent ):
        wx.Frame.__init__( self, parent, id = wx.ID_ANY, title = u"Test", pos=wx.DefaultPosition, size=wx.DefaultSize)
        self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
        bSizer11 = wx.BoxSizer( wx.HORIZONTAL )
        self.img1=wx.Image("IMJ_31183.png", wx.BITMAP_TYPE_ANY)
        self.m_bitmap3 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap(self.img1), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer11.Add( self.m_bitmap3, 1, wx.EXPAND, 0 )
        self.Bind(wx.EVT_SIZE, self.onResize)
        self.SetSizer( bSizer11 )
        self.Layout()
        self.Centre(wx.BOTH)
        self.Show()

    def onResize(self, event):
        frame_size = self.GetSize()
        frame_h = (frame_size[0])
        frame_w = (frame_size[1])
        img1 = self.img1.Scale(frame_h,frame_w)
        self.m_bitmap3.SetBitmap(wx.Bitmap(img1))
        self.Refresh()
        self.Layout()


if __name__ == "__main__":
    app = wx.App()
    Frame(None)
    app.MainLoop()

When I run it, the image does fill the whole frame and scales as expected when I resize the frame.

Screenshot at 2023-03-22 09-23-04

Portsmouth :sunglasses: