如何将已捕获的屏幕截图添加到 wx.BoxSizer? [英] How add already captured screenshot to wx.BoxSizer?
本文介绍了如何将已捕获的屏幕截图添加到 wx.BoxSizer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 Python 代码:
self.images = wx.StaticBitmap(self, id=-1, pos=wx.DefaultPosition,
size=(200,150),
style= wx.SUNKEN_BORDER)
self.hbox = wx.BoxSizer(wx.HORIZONTAL)
self.sizer.Add(self.hbox) # my main sizer
#in function dynamically captured images
bmp = wx.BitmapFromImage(image)
self.images.SetBitmap(bmp)
self.hbox.Add(self.images, 1, wx.EXPAND | wx.ALL, 3)
...在我想添加下一个图像(另一个 - 我不想替换旧图像)之后,我有信息将窗口添加到同一个 sizer 两次?"
...and after I want to add next image (another - I don't want to replace older) I have information "Adding a window to the same sizer twice?"
我该如何解决这个问题?
How can I resolve this problem?
推荐答案
在你的动态捕获图像函数中,你需要创建一个新的staticBitmap
而不是设置self.images
覆盖并因此替换...
In your function for dynamically captured images, you need to create a new staticBitmap
rather than setting self.images
which overwrites and therefore replaces...
所以代替
self.images.SetBitmap(bmp)
你需要做的
newImage = wx.StaticBitmap(self, id=-1
size=(200,150),
style= wx.SUNKEN_BORDER
bitmap = bmp)
self.hbox.Add(newImage, 1, wx.EXPAND | wx.ALL, 3)
self.SetSizerAndFit(self.sizer)
self.Refresh()
self.Layout()
这篇关于如何将已捕获的屏幕截图添加到 wx.BoxSizer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文