user3152250 user3152250 - 1 year ago 90
Python Question

How to set multiple image in image frame same time in wxpython

I have been develop a gps system. then i am using python and wx python for make GUI. so i have able to show single map part in image viewer. but is is not sufficient. i want to load separate images same time and show them as a single image in my wx python GUI.

How can i do this with wx python?

Answer Source

You can use OnPaint (in any widget) to draw own elements.

You can draw many images in widget.

import wx

class MyFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, size=(300, 200))


        # two images
        self.image1 = wx.Bitmap("ball-1.png")
        self.image2 = wx.Bitmap("ball-2.png")

        # assign own function to draw widget
        self.Bind(wx.EVT_PAINT, self.OnPaint)


    def OnPaint(self, evt):
        dc = wx.PaintDC(self)

        # draw own elements

        width  = self.image1.GetWidth()
        height = self.image1.GetHeight()

        dc.DrawBitmap(self.image1, 0, 0)
        dc.DrawBitmap(self.image2, width, 0)

        dc.DrawBitmap(self.image2, 0, height)
        dc.DrawBitmap(self.image1, width, height)

if __name__ == '__main__':

    app = wx.App()

ball-1.png ball-1.png ball-2.png ball-2.png


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download