本文整理汇总了Python中Orange.canvas.report.owreport.OWReport类的典型用法代码示例。如果您正苦于以下问题:Python OWReport类的具体用法?Python OWReport怎么用?Python OWReport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OWReport类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_report_widgets_all
def test_report_widgets_all(self):
rep = OWReport.get_instance()
widgets = self.clas_widgets + self.data_widgets + self.eval_widgets + \
self.regr_widgets + self.unsu_widgets + self.dist_widgets + \
self.visu_widgets + self.spec_widgets
self.assertEqual(len(widgets), 52)
self._create_report(widgets, rep, None)
示例2: test_report_widgets_visualize
def test_report_widgets_visualize(self):
app = QApplication(sys.argv)
rep = OWReport.get_instance()
data = Table("zoo")
widgets = self.visu_widgets
self.assertEqual(len(widgets), 10)
self._create_report(widgets, rep, data, app)
示例3: report_view
def report_view(self):
"""
Return a OWReport instance used by the workflow.
If a report window has not been set then the `report_view_requested`
signal is emitted to allow the framework to setup the report window.
If the report window is still not set after the signal is emitted, a
new default OWReport instance is constructed and returned.
Returns
-------
report : OWReport
"""
from Orange.canvas.report.owreport import OWReport
if self.__report_view is None:
self.report_view_requested.emit()
if self.__report_view is None:
parent = self.parent()
if isinstance(parent, QWidget):
window = parent.window() # type: QWidget
else:
window = None
self.__report_view = OWReport()
if window is not None:
self.__report_view.setParent(window, Qt.Window)
return self.__report_view
示例4: test_report_widgets_all
def test_report_widgets_all(self):
app = QApplication(sys.argv)
rep = OWReport.get_instance()
widgets = self.clas_widgets + self.data_widgets + self.eval_widgets + \
self.regr_widgets + self.unsu_widgets + self.dist_widgets + \
self.visu_widgets + self.spec_widgets
self.assertEqual(len(widgets), 51)
self._create_report(widgets, rep, None, app)
示例5: test_report
def test_report(self):
count = 5
app = QApplication(sys.argv)
for i in range(count):
rep = OWReport.get_instance()
file = OWFile()
file.create_report_html()
rep.make_report(file)
self.assertEqual(rep.table_model.rowCount(), count)
示例6: test_report_table
def test_report_table(self):
rep = OWReport().get_instance()
model = PyTableModel([['x', 1, 2],
['y', 2, 2]])
model.setHorizontalHeaderLabels(['a', 'b', 'c'])
model.setData(model.index(0, 0), Qt.AlignHCenter | Qt.AlignTop, Qt.TextAlignmentRole)
model.setData(model.index(1, 0), QFont('', -1, QFont.Bold), Qt.FontRole)
model.setData(model.index(1, 2), QBrush(Qt.red), Qt.BackgroundRole)
view = gui.TableView()
view.show()
view.setModel(model)
rep.report_table('Name', view)
self.maxDiff = None
self.assertEqual(
rep.report_html,
'<h2>Name</h2><table>\n'
'<tr>'
'<th style="color:black;border:0;background:transparent;'
'font-weight:normal;text-align:left;vertical-align:middle;">a</th>'
'<th style="color:black;border:0;background:transparent;'
'font-weight:normal;text-align:left;vertical-align:middle;">b</th>'
'<th style="color:black;border:0;background:transparent;'
'font-weight:normal;text-align:left;vertical-align:middle;">c</th>'
'</tr>'
'<tr>'
'<td style="color:black;border:0;background:transparent;'
'font-weight:normal;text-align:center;vertical-align:top;">x</td>'
'<td style="color:black;border:0;background:transparent;'
'font-weight:normal;text-align:right;vertical-align:middle;">1</td>'
'<td style="color:black;border:0;background:transparent;'
'font-weight:normal;text-align:right;vertical-align:middle;">2</td>'
'</tr>'
'<tr>'
'<td style="color:black;border:0;background:transparent;'
'font-weight:bold;text-align:left;vertical-align:middle;">y</td>'
'<td style="color:black;border:0;background:transparent;'
'font-weight:normal;text-align:right;vertical-align:middle;">2</td>'
'<td style="color:black;border:0;background:#ff0000;'
'font-weight:normal;text-align:right;vertical-align:middle;">2</td>'
'</tr></table>')
示例7: show_report
def show_report(self):
"""
Raise the report window.
"""
from Orange.canvas.report.owreport import OWReport
report = OWReport.get_instance()
self.create_report_html()
report.make_report(self)
report.show()
report.raise_()
示例8: test_save_report_permission
def test_save_report_permission(self):
"""
Permission Error may occur when trying to save report.
GH-2147
"""
rep = OWReport.get_instance()
patch_target_1 = "Orange.canvas.report.owreport.open"
patch_target_2 = "AnyQt.QtWidgets.QFileDialog.getSaveFileName"
patch_target_3 = "AnyQt.QtWidgets.QMessageBox.exec_"
filenames = ["f.report", "f.html"]
for filename in filenames:
with unittest.mock.patch(patch_target_1, create=True, side_effect=PermissionError),\
unittest.mock.patch(patch_target_2, return_value=(filename, 0)),\
unittest.mock.patch(patch_target_3, return_value=True):
rep.save_report()
示例9: test_save_report
def test_save_report(self):
rep = OWReport.get_instance()
file = self.create_widget(OWFile)
file.create_report_html()
rep.make_report(file)
temp_dir = tempfile.mkdtemp()
temp_name = os.path.join(temp_dir, "f.report")
try:
with mock.patch("AnyQt.QtWidgets.QFileDialog.getSaveFileName",
return_value=(temp_name, 0)), \
mock.patch("AnyQt.QtWidgets.QMessageBox.exec_",
return_value=True):
rep.save_report()
finally:
os.remove(temp_name)
os.rmdir(temp_dir)
示例10: show_report_view
def show_report_view(self):
from Orange.canvas.report.owreport import OWReport
inst = OWReport.get_instance()
inst.show()
inst.raise_()
示例11: test_report_widgets_all
def test_report_widgets_all(self):
rep = OWReport.get_instance()
widgets = self.model_widgets + self.data_widgets + self.eval_widgets + \
self.unsu_widgets + self.dist_widgets + self.visu_widgets + \
self.spec_widgets
self._create_report(widgets, rep, None)
示例12: WidgetsScheme
class WidgetsScheme(Scheme):
"""
A Scheme containing Orange Widgets managed with a `WidgetsSignalManager`
instance.
Extends the base `Scheme` class to handle the lifetime
(creation/deletion, etc.) of `OWBaseWidget` instances corresponding to
the nodes in the scheme. It also delegates the interwidget signal
propagation to an instance of `WidgetsSignalManager`.
"""
#: Emitted when a report_view is requested for the first time, before a
#: default instance is created. Clients can connect to this signal to
#: set a report view (`set_report_view`) to use instead.
report_view_requested = Signal()
def __init__(self, parent=None, title=None, description=None, env={}):
Scheme.__init__(self, parent, title, description, env=env)
self.signal_manager = WidgetsSignalManager(self)
self.widget_manager = WidgetManager()
def onchanged(state):
# Update widget creation policy based on signal manager's state
if state == SignalManager.Running:
self.widget_manager.set_creation_policy(WidgetManager.Normal)
else:
self.widget_manager.set_creation_policy(WidgetManager.OnDemand)
self.signal_manager.stateChanged.connect(onchanged)
self.widget_manager.set_scheme(self)
self.__report_view = None # type: Optional[OWReport]
def widget_for_node(self, node):
"""
Return the OWWidget instance for a `node`.
"""
return self.widget_manager.widget_for_node(node)
def node_for_widget(self, widget):
"""
Return the SchemeNode instance for the `widget`.
"""
return self.widget_manager.node_for_widget(widget)
def save_widget_geometry_for_node(self, node):
# type: (SchemeNode) -> bytes
"""
Save and return the current geometry and state for node
Parameters
----------
node : Scheme
"""
w = self.widget_for_node(node) # type: OWWidget
return bytes(w.saveGeometryAndLayoutState())
def restore_widget_geometry_for_node(self, node, state):
# type: (SchemeNode, bytes) -> bool
w = self.widget_for_node(node)
if w is not None:
return w.restoreGeometryAndLayoutState(QByteArray(state))
else:
return False
def sync_node_properties(self):
"""
Sync the widget settings/properties with the SchemeNode.properties.
Return True if there were any changes in the properties (i.e. if the
new node.properties differ from the old value) and False otherwise.
"""
changed = False
for node in self.nodes:
settings = self.widget_manager.widget_properties(node)
if settings != node.properties:
node.properties = settings
changed = True
log.debug("Scheme node properties sync (changed: %s)", changed)
return changed
def show_report_view(self):
inst = self.report_view()
inst.show()
inst.raise_()
def has_report(self):
"""
Does this workflow have an associated report
Returns
-------
has_report: bool
"""
return self.__report_view is not None
def report_view(self):
"""
Return a OWReport instance used by the workflow.
#.........这里部分代码省略.........