2024-04-20 05:38:53 发布
网友
我一直在开发一个gps系统。然后我使用python和wxpython来制作GUI。所以我可以在图像查看器中显示单个地图部分。但这是不够的。我想在同一时间用一个python图像和wx图像分开显示。在
如何使用wx python实现这一点?在
您可以使用OnPaint(在任何小部件中)来绘制自己的元素。在
OnPaint
您可以在widget中绘制许多图像。在
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()
ball-1.png ball-2.png
您可以使用
OnPaint
(在任何小部件中)来绘制自己的元素。在您可以在widget中绘制许多图像。在
ball-1.png ball-2.png
相关问题 更多 >
编程相关推荐