Пример #1
0
    def copy_to_clipboard(plot):
#        pass
#     @staticmethod
#     def wx_copy_to_clipboard(plot):
#         # WX specific, though QT implementation is similar using
#         # QImage and QClipboard
#         import wx
# 
        width, height = plot.outer_bounds
# 
        gc = PlotGraphicsContext((width, height), dpi=72)
        backbuffer = plot.use_backbuffer
        plot.use_backbuffer = False
        gc.render_component(plot)
        plot.use_backbuffer = backbuffer
# 

#         # Create a bitmap the same size as the plot
#         # and copy the plot data to it
        bmp = gc.bmp_array
        if gc.format().startswith('bgra'):
            bmp_rgba = bmp[:,:,[2,1,0,3]]
        else:
            bmp_rgba = bmp
             
        bitmap=QImage(bmp_rgba.tostring(),width,height, PySide.QtGui.QImage.Format_RGB32)
        if QApplication.clipboard():
            QApplication.clipboard().setImage(bitmap.copy())
        else:
            PySide.QtGui.QMessageBox("Unable to open the clipboard.", "Error")
Пример #2
0
    def copy_to_clipboard(plot):
        # WX specific, though QT implementation is similar using
        # QImage and QClipboard
        import wx

        width, height = plot.outer_bounds

        gc = PlotGraphicsContext((width, height), dpi=72)
        backbuffer = plot.use_backbuffer
        plot.use_backbuffer = False
        gc.render_component(plot)
        plot.use_backbuffer = backbuffer

        # Create a bitmap the same size as the plot
        # and copy the plot data to it
        bmp = gc.bmp_array
        if gc.format().startswith('bgra'):
            bmp_rgba = bmp[:,:,[2,1,0,3]]
        else:
            bmp_rgba = bmp
        bitmap = wx.BitmapFromBufferRGBA(width+1, height+1,
                                     bmp_rgba.flatten())
        data = wx.BitmapDataObject()
        data.SetBitmap(bitmap)

        if wx.TheClipboard.Open():
            wx.TheClipboard.SetData(data)
            wx.TheClipboard.Close()
        else:
            wx.MessageBox("Unable to open the clipboard.", "Error")
Пример #3
0
    def copy_to_clipboard(plot):
        #        pass
        #     @staticmethod
        #     def wx_copy_to_clipboard(plot):
        #         # WX specific, though QT implementation is similar using
        #         # QImage and QClipboard
        #         import wx
        #
        width, height = plot.outer_bounds
        #
        gc = PlotGraphicsContext((width, height), dpi=72)
        backbuffer = plot.use_backbuffer
        plot.use_backbuffer = False
        gc.render_component(plot)
        plot.use_backbuffer = backbuffer
        #

        #         # Create a bitmap the same size as the plot
        #         # and copy the plot data to it
        bmp = gc.bmp_array
        if gc.format().startswith('bgra'):
            bmp_rgba = bmp[:, :, [2, 1, 0, 3]]
        else:
            bmp_rgba = bmp

        bitmap = QImage(bmp_rgba.tostring(), width, height,
                        PySide.QtGui.QImage.Format_RGB32)
        if QApplication.clipboard():
            QApplication.clipboard().setImage(bitmap.copy())
        else:
            PySide.QtGui.QMessageBox("Unable to open the clipboard.", "Error")
Пример #4
0
    def copy_to_clipboard(plot):
        width, height = plot.outer_bounds

        gc = PlotGraphicsContext((width, height), dpi=72)
        backbuffer = plot.use_backbuffer
        plot.use_backbuffer = False
        gc.render_component(plot)
        plot.use_backbuffer = backbuffer

        # Create a bitmap the same size as the plot
        # and copy the plot data to it
        bmp = gc.bmp_array

        cache_bmp = bmp.tobytes()
        bitmap = QImage(cache_bmp, width+1, height+1, QImage.Format_RGB32)
        if QApplication.clipboard():
            QApplication.clipboard().setImage(bitmap.copy(), QClipboard.Clipboard)
        else:
            PySide.QtGui.QMessageBox("Unable to open the clipboard.", "Error")
Пример #5
0
 def save_with_kiva(plot, width, height, dpi, filename, ext):
     gc = PlotGraphicsContext((width, height), dpi=dpi)
     gc.render_component(plot)
     gc.save(filename,file_format=ext)
     logger.logger.info('Saved plot {}'.format(filename))
Пример #6
0
 def save_with_kiva(plot, width, height, dpi, filename):
     gc = PlotGraphicsContext((width, height), dpi=dpi)
     gc.render_component(plot)
     gc.save(filename)
     logger.logger.info('Saved plot {}'.format(filename))