Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Button 如何创建带有SVG图标的wxPython按钮?_Button_Svg_Wxpython - Fatal编程技术网

Button 如何创建带有SVG图标的wxPython按钮?

Button 如何创建带有SVG图标的wxPython按钮?,button,svg,wxpython,Button,Svg,Wxpython,我面临着反对的警告 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 :c

我面临着反对的警告

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)
为了

我似乎找不到关于如何为按钮创建SVG图标的信息(说明图标应该是位图,考虑到SVG存在的时间,这似乎有点过时)和。也只提到位图

即使我必须使用位图,我也希望消除弃用警告


我使用的是源代码在Ubuntu 16.10上构建的Phoenix 9b743cf3(他们无法使用git标签)。

警告告诉您如何更正它
wx.Image
可以接受流作为第一个参数(而不是
wx.ImageFromStream
),而
wx.Bitmap
可以接受
wx.Image
作为第一个参数(而不是
wx.BitmapFromImage

另见

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