1 | from Orange.data.io import FileFormats |
||
2 | from PyQt4 import QtGui, QtCore, QtSvg |
||
0 ignored issues
–
show
|
|||
3 | |||
4 | from pyqtgraph.graphicsItems.GraphicsWidget import GraphicsWidget |
||
0 ignored issues
–
show
The import
pyqtgraph.graphicsItems.GraphicsWidget could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands. # .scrutinizer.yml
before_commands:
- sudo pip install abc # Python2
- sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use
the command for the correct version.
2. Missing __init__.py filesThis error could also result from missing ![]() |
|||
5 | from pyqtgraph.exporters.SVGExporter import SVGExporter |
||
0 ignored issues
–
show
The import
pyqtgraph.exporters.SVGExporter could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands. # .scrutinizer.yml
before_commands:
- sudo pip install abc # Python2
- sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use
the command for the correct version.
2. Missing __init__.py filesThis error could also result from missing ![]() |
|||
6 | from pyqtgraph.exporters.ImageExporter import ImageExporter |
||
0 ignored issues
–
show
The import
pyqtgraph.exporters.ImageExporter could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands. # .scrutinizer.yml
before_commands:
- sudo pip install abc # Python2
- sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use
the command for the correct version.
2. Missing __init__.py filesThis error could also result from missing ![]() |
|||
7 | |||
8 | |||
9 | class ImgFormat: |
||
10 | @staticmethod |
||
11 | def _get_buffer(size, filename): |
||
12 | raise NotImplementedError( |
||
13 | "Descendants of ImgFormat must override method _get_buffer") |
||
14 | |||
15 | @staticmethod |
||
16 | def _get_target(self, scene, painter, buffer): |
||
0 ignored issues
–
show
|
|||
17 | raise NotImplementedError( |
||
18 | "Descendants of ImgFormat must override method _get_target") |
||
19 | |||
20 | @staticmethod |
||
21 | def _save_buffer(self, buffer, filename): |
||
0 ignored issues
–
show
|
|||
22 | raise NotImplementedError( |
||
23 | "Descendants of ImgFormat must override method _save_buffer") |
||
24 | |||
25 | @staticmethod |
||
26 | def _get_exporter(self): |
||
0 ignored issues
–
show
|
|||
27 | raise NotImplementedError( |
||
28 | "Descendants of ImgFormat must override method _get_exporter") |
||
29 | |||
30 | @classmethod |
||
31 | def write_image(cls, filename, scene): |
||
32 | if isinstance(scene, GraphicsWidget): |
||
33 | exporter = cls._get_exporter() |
||
34 | exp = exporter(scene) |
||
35 | exp.export(filename) |
||
36 | else: |
||
37 | source = scene.itemsBoundingRect().adjusted(-15, -15, 15, 15) |
||
38 | buffer = cls._get_buffer(source.size(), filename) |
||
39 | |||
40 | painter = QtGui.QPainter() |
||
41 | painter.begin(buffer) |
||
42 | painter.setRenderHint(QtGui.QPainter.Antialiasing) |
||
43 | |||
44 | target = cls._get_target(scene, painter, buffer, source) |
||
45 | scene.render(painter, target, source) |
||
46 | cls._save_buffer(buffer, filename) |
||
47 | painter.end() |
||
48 | |||
49 | def write(self, filename, scene): |
||
50 | if type(scene) == dict: |
||
51 | scene = scene['scene'] |
||
52 | self.write_image(filename, scene) |
||
53 | |||
54 | |||
55 | @FileFormats.register("Portable Network Graphics", ".png") |
||
56 | class PngFormat(ImgFormat): |
||
57 | @staticmethod |
||
58 | def _get_buffer(size, filename): |
||
59 | return QtGui.QPixmap(int(size.width()), int(size.height())) |
||
60 | |||
61 | @staticmethod |
||
62 | def _get_target(scene, painter, buffer, source): |
||
63 | brush = scene.backgroundBrush() |
||
64 | if brush.style() == QtCore.Qt.NoBrush: |
||
65 | brush = QtGui.QBrush(scene.palette().color(QtGui.QPalette.Base)) |
||
66 | painter.fillRect(buffer.rect(), brush) |
||
67 | return QtCore.QRectF(0, 0, source.width(), source.height()) |
||
68 | |||
69 | @staticmethod |
||
70 | def _save_buffer(buffer, filename): |
||
0 ignored issues
–
show
|
|||
71 | buffer.save(filename) |
||
72 | |||
73 | @staticmethod |
||
74 | def _get_exporter(): |
||
0 ignored issues
–
show
|
|||
75 | return ImageExporter |
||
76 | |||
77 | |||
78 | @FileFormats.register("Scalable Vector Graphics", ".svg") |
||
79 | class SvgFormat(ImgFormat): |
||
80 | @staticmethod |
||
81 | def _get_buffer(size, filename): |
||
82 | buffer = QtSvg.QSvgGenerator() |
||
83 | buffer.setFileName(filename) |
||
84 | buffer.setSize(QtCore.QSize(int(size.width()), int(size.height()))) |
||
85 | return buffer |
||
86 | |||
87 | @staticmethod |
||
88 | def _get_target(scene, painter, buffer, source): |
||
89 | return QtCore.QRectF(0, 0, source.width(), source.height()) |
||
90 | |||
91 | @staticmethod |
||
92 | def _save_buffer(buffer, filename): |
||
0 ignored issues
–
show
|
|||
93 | pass |
||
94 | |||
95 | @staticmethod |
||
96 | def _get_exporter(): |
||
0 ignored issues
–
show
|
|||
97 | return SVGExporter |
||
98 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.