Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Orange/widgets/classify/owtreeviewer2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class OWTreeViewer2D(OWWidget):
_DEF_NODE_WIDTH = 24
_DEF_NODE_HEIGHT = 20

graph_name = True
graph_name = "scene"

def __init__(self):
super().__init__()
Expand Down
20 changes: 19 additions & 1 deletion Orange/widgets/io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from PyQt4 import QtGui, QtCore, QtSvg
from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget
from PyQt4.QtCore import QMimeData
from PyQt4.QtGui import QGraphicsScene, QGraphicsView, QWidget, QApplication

from Orange.data.io import FileFormat

Expand Down Expand Up @@ -100,6 +101,23 @@ def _export(exporter, filename):
buffer.save(filename, "png")


class ClipboardFormat(PngFormat):
EXTENSIONS = ()
DESCRIPTION = 'System Clipboard'
PRIORITY = 50

@staticmethod
def _save_buffer(buffer, _):
QApplication.clipboard().setPixmap(buffer)

@staticmethod
def _export(exporter, _):
buffer = exporter.export(toBytes=True)
mimedata = QMimeData()
mimedata.setData("image/png", buffer)
QApplication.clipboard().setMimeData(mimedata)


class SvgFormat(ImgFormat):
EXTENSIONS = ('.svg',)
DESCRIPTION = 'Scalable Vector Graphics'
Expand Down
10 changes: 10 additions & 0 deletions Orange/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from Orange.canvas.registry import description as widget_description
from Orange.canvas.report import Report
from Orange.widgets.gui import ControlledAttributesDict, notify_changed
from Orange.widgets.io import ClipboardFormat
from Orange.widgets.settings import SettingsHandler
from Orange.widgets.utils import saveplot, getdeepattr
from .utils.overlay import MessageOverlayWidget
Expand Down Expand Up @@ -198,6 +199,9 @@ def __new__(cls, *args, **kwargs):
sc = QShortcut(QKeySequence(Qt.ShiftModifier | Qt.Key_F1), self)
sc.activated.connect(self.__quicktip)

sc = QShortcut(QKeySequence.Copy, self)
sc.activated.connect(self.copy_to_clipboard)

return self

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -316,6 +320,12 @@ def save_graph(self):
return
saveplot.save_plot(graph_obj, self.graph_writers)

def copy_to_clipboard(self):
graph_obj = getdeepattr(self, self.graph_name, None)
if graph_obj is None:
return
ClipboardFormat.write_image(None, graph_obj)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't step through it after here. 😕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With which visualization? All? Perhaps you should ask @VesnaT. Linear projection report used to fail on Os X in a similar call, and she fixed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Doesn't segfault anymore, yet nothing has changed code-wise. But anyway, now the images are borked:
distributions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try now? For me it now works on all visualizations.

Copy link
Contributor

@kernc kernc Jun 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works here too. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can somebody (@thocevar?) try this PR on Windows?


def __restoreWidgetGeometry(self):

def _fullscreen_to_maximized(geometry):
Expand Down