如何在wxpython中同时在图像帧中设置多个图像

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

我一直在开发一个gps系统。然后我使用 python 和 wx python 来制作 GUI。所以我能够在图像查看器中显示单个地图部分。但这还不够。我想同时加载单独的图像并在我的 wx python GUI 中将它们显示为单个图像。

我如何使用 wx python 做到这一点?

您可以使用 OnPaint(在任何小部件中)绘制自己的元素。

您可以在小部件中绘制许多图像。

import wx

class MyFrame(wx.Frame):

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

        #self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)

        # 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)

        self.Show()

    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()
    MyFrame()
    app.MainLoop()

球-1.png 球-2.png