相关疑难解决方法(0)

PyGame应用程序中的SVG渲染

pyGame应用程序中,我想渲染SVG中描述的无分辨率的GUI小部件.

我可以使用哪些工具和/或库来实现这一目标?

(我喜欢OCEMP GUI工具包,但它的渲染似乎依赖于位图)

python svg pygame widget

23
推荐指数
4
解决办法
1万
查看次数

在 Python Pygame 上显示 SVG(来自字符串)

我有一个以字符串表示的 SVG 图形

svg_string='<svg height="100" width="500"><ellipse cx="240" cy="50" rx="220" ry="30" style="fill:yellow" /><ellipse cx="220" cy="50" rx="190" ry="20" style="fill:white" /></svg>'
Run Code Online (Sandbox Code Playgroud)

我想在Python启动的窗口上显示由 表示的图形svg_string,它是2个椭圆。

其伪代码应该是这样的

import pygame


def display_svg_figure(screen, svg_string):
    #   Code that draws the rendered SVG string on
    #   the screen
    pass

background_colour = (255, 255, 255)
(width, height) = (900, 900)

screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Display SVG')
screen.fill(background_colour)

pygame.display.flip()

svg_string='<svg height="100" width="500"><ellipse cx="240" cy="50" rx="220" ry="30" style="fill:yellow" /><ellipse cx="220" cy="50" rx="190" ry="20" style="fill:white" /></svg>'
display_svg_figure(screen, svg_string)


running = True
while …
Run Code Online (Sandbox Code Playgroud)

python svg pygame python-3.x pygame-surface

5
推荐指数
1
解决办法
3702
查看次数

如何从字符串/xml流在PyQT5中显示SVG图像?

在 Python3/QT5 应用程序中,我试图显示最初作为字符串构建的 SVG 图像。我需要操作这个 SVG 图像(例如改变它的颜色),所以我的字符串随着时间的推移而改变。这是一个最小的工作示例:

import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtSvg import QSvgWidget

svg_str = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="300" height="300" viewBox="0 0 300 300" id="smile" version="1.1">
    <path
        style="fill:#ffaaaa"
        d="M 150,0 A 150,150 0 0 0 0,150 150,150 0 0 0 150,300 150,150 0 0 0 
            300,150 150,150 0 0 0 150,0 Z M 72,65 A 21,29.5 0 0 1 93,94.33 
            21,29.5 0 0 1 72,124 21,29.5 0 0 1 51,94.33 21,29.5 0 0 1 …
Run Code Online (Sandbox Code Playgroud)

svg python-3.x qt5 pyqt5

3
推荐指数
2
解决办法
2724
查看次数

标签 统计

svg ×3

pygame ×2

python ×2

python-3.x ×2

pygame-surface ×1

pyqt5 ×1

qt5 ×1

widget ×1