Show More
@@ -10,7 +10,7 b' def save_svg(string, parent=None):' | |||||
10 |
|
10 | |||
11 | Parameters: |
|
11 | Parameters: | |
12 | ----------- |
|
12 | ----------- | |
13 | string : str |
|
13 | string : basestring | |
14 | A Python string containing a SVG document. |
|
14 | A Python string containing a SVG document. | |
15 |
|
15 | |||
16 | parent : QWidget, optional |
|
16 | parent : QWidget, optional | |
@@ -40,9 +40,12 b' def svg_to_clipboard(string):' | |||||
40 |
|
40 | |||
41 | Parameters: |
|
41 | Parameters: | |
42 | ----------- |
|
42 | ----------- | |
43 | string : str |
|
43 | string : basestring | |
44 | A Python string containing a SVG document. |
|
44 | A Python string containing a SVG document. | |
45 | """ |
|
45 | """ | |
|
46 | if isinstance(string, unicode): | |||
|
47 | string = string.encode('utf-8') | |||
|
48 | ||||
46 | mime_data = QtCore.QMimeData() |
|
49 | mime_data = QtCore.QMimeData() | |
47 | mime_data.setData('image/svg+xml', string) |
|
50 | mime_data.setData('image/svg+xml', string) | |
48 | QtGui.QApplication.clipboard().setMimeData(mime_data) |
|
51 | QtGui.QApplication.clipboard().setMimeData(mime_data) | |
@@ -52,7 +55,7 b' def svg_to_image(string, size=None):' | |||||
52 |
|
55 | |||
53 | Parameters: |
|
56 | Parameters: | |
54 | ----------- |
|
57 | ----------- | |
55 | string : str |
|
58 | string : basestring | |
56 | A Python string containing a SVG document. |
|
59 | A Python string containing a SVG document. | |
57 |
|
60 | |||
58 | size : QSize, optional |
|
61 | size : QSize, optional | |
@@ -68,6 +71,9 b' def svg_to_image(string, size=None):' | |||||
68 | -------- |
|
71 | -------- | |
69 | A QImage of format QImage.Format_ARGB32. |
|
72 | A QImage of format QImage.Format_ARGB32. | |
70 | """ |
|
73 | """ | |
|
74 | if isinstance(string, unicode): | |||
|
75 | string = string.encode('utf-8') | |||
|
76 | ||||
71 | renderer = QtSvg.QSvgRenderer(QtCore.QByteArray(string)) |
|
77 | renderer = QtSvg.QSvgRenderer(QtCore.QByteArray(string)) | |
72 | if not renderer.isValid(): |
|
78 | if not renderer.isValid(): | |
73 | raise ValueError('Invalid SVG data.') |
|
79 | raise ValueError('Invalid SVG data.') |
General Comments 0
You need to be logged in to leave comments.
Login now