【发布时间】:2017-04-04 20:55:38
【问题描述】:
我正面临弃用警告
wxPyDeprecationWarning: Call to deprecated item ImageFromStream. Use :class:`Image` instead.
svgimg = wx.ImageFromStream(StringIO.StringIO(svgpng),wx.BITMAP_TYPE_PNG)
wxPyDeprecationWarning: Call to deprecated item BitmapFromImage. Use :class:`wx.Bitmap` instead
svgbmp = wx.BitmapFromImage(svgimg)
为
def getBmpFromSvg(self,svgxml, width, height):
"""
Credit goes to https://cyberxml.wordpress.com/2015/02/17/wxpython-wx-bitmap-icons-from-svg-xml/. Asked https://cyberxml.wordpress.com/2015/02/17/wxpython-wx-bitmap-icons-from-svg-xml/comment-page-1/#comment-11 to a version avoiding deprecated wx.BitmapFromImage.
"""
svgpng = cairosvg.svg2png(svgxml)
svgimg = wx.ImageFromStream(StringIO.StringIO(svgpng),wx.BITMAP_TYPE_PNG)
svgimg = svgimg.Scale(width, height, wx.IMAGE_QUALITY_HIGH)
svgbmp = wx.BitmapFromImage(svgimg)
return svgbmp
playButtonImg = self.getBmpFromSvg(resource_string("[name]", os.path.join("resources", "icons", 'play-button.svg')), icon_size_default, icon_size_default)
self.playButton = buttons.GenBitmapButton(self.videoPanel, bitmap=playButtonImg, name="play")
而且我似乎没有从Icon's documentation 中找到有关如何为按钮创建 SVG 图标的信息(说明图标应该是位图,考虑到 SVG 的出现,这似乎有点过时)和@987654322 @。 Button's documentation 也只提到了位图。
即使我必须使用位图,我也想消除弃用警告。
我正在使用从 Ubuntu 16.10 上的源代码构建的 Phoenix 9b743cf3(他们无法使用 git 标签)。
【问题讨论】: