Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.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

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
如何在GTK3和python中绘制SVG src作为图像?_Python_Svg_Gtk3 - Fatal编程技术网

如何在GTK3和python中绘制SVG src作为图像?

如何在GTK3和python中绘制SVG src作为图像?,python,svg,gtk3,Python,Svg,Gtk3,我的代码如下所示: img = '''<?xml version="1.0" encoding="UTF-8"?> <svg width="50" height="50" xmlns="http://www.w3.org/2000/svg"> <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ --> <g> <title>Layer 1</title&

我的代码如下所示:

img = '''<?xml version="1.0" encoding="UTF-8"?>
<svg width="50" height="50" xmlns="http://www.w3.org/2000/svg">
 <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
 <g>
  <title>Layer 1</title>
  <circle stroke-width="3" stroke="#1a1a1a" fill="#dfdbd2" r="16" cy="25" cx="25"/>
  <path stroke-width="0" fill="#1a1a1a" d="m25,9a16,16 0 0 0 0,32l0,-1.5a18,18 0 0 0 0,-29l0,-1.5z"/>
 </g>
</svg>'''

请原谅我的英语不好:)

尝试将答案改编为-看起来你会想调查问题。但我不能将它与Gtk3一起使用,Gtk3是动态的,Rsvg是静态的。我不明白为什么不可以,我有一些代码可以通过
Rsvg
将svg加载到
Gtk3.DrawingArea
中。它变成了一个固定的大小,但在DrawingArea的开罗上下文中应该很容易处理。如果这不是您想要的,那么您可以进一步解释一下真正的问题是什么。我想从其XML源而不是svg文件在gtk中绘制svg图像,我可以在PyQT中轻松完成此操作。答案如下:
    Image=Gtk.Image()
    Image.set_from_pixbuf(img)