Esempio n. 1
0
    def __init__(self, parent=None, width=50, height=40, dpi=50, field_name='chart', **kwargs):
        from matplotlib.figure import Figure
        from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
        super(ChartEditor, self).__init__( parent )
        AbstractCustomEditor.__init__( self )
        self.setObjectName( field_name )
        
        chart_frame = QtGui.QFrame( self )
        chart_frame.setFrameShape( self.Box )
        chart_frame.setContentsMargins( 1, 1, 1, 1 )
        chart_frame_layout = QtGui.QHBoxLayout()
        chart_frame_layout.setContentsMargins( 0, 0, 0, 0)
        chart_frame.setLayout( chart_frame_layout )

        # find out background color, because using a transparent
        # figure fails when the window is resized: the background
        # is not redrawn
        # need to do str() else matplotlib gets confused by the qstring
        # bgcolorrgb = str(self.palette().background().color().name())
        self.fig = Figure(
            figsize=(width, height),
            dpi=dpi,
            facecolor='#ffffff',
        )
        layout = QtGui.QHBoxLayout()
        self.canvas = FigureCanvas( self.fig )
        chart_frame_layout.addWidget( self.canvas )
        layout.addWidget(chart_frame)
        button_layout = QtGui.QVBoxLayout()
        button_layout.setSpacing( 0 )

        icon = Icon( 'tango/16x16/actions/document-print-preview.png' ).getQIcon()
        button_layout.addStretch()
        
        print_button = QtGui.QToolButton()
        print_button.setIcon( icon )
        print_button.setAutoRaise( True )
        print_button.setToolTip( _('Print Preview') )
        print_button.clicked.connect( self.print_preview )
        button_layout.addWidget( print_button )

        icon = Icon( 'tango/16x16/actions/edit-copy.png' ).getQIcon()
        copy_button = QtGui.QToolButton()
        copy_button.setIcon( icon )
        copy_button.setAutoRaise( True )
        copy_button.setToolTip( _('Copy to clipboard') )
        copy_button.clicked.connect( self.copy_to_clipboard )
        button_layout.addWidget( copy_button )
                
        layout.addLayout( button_layout )
        layout.setContentsMargins( 0, 0, 0, 0)
        self.setLayout(layout)
        self.canvas.setSizePolicy(
            QtGui.QSizePolicy.Expanding,
            QtGui.QSizePolicy.Expanding
        )
        self.canvas.installEventFilter(self)
        self.show_fullscreen_signal.connect(self.show_fullscreen)
        self.canvas.updateGeometry()
        self._litebox = None
Esempio n. 2
0
 def set_value(self, value):
     """Accepts a camelot.container.chartcontainer.FigureContainer or a 
     camelot.container.chartcontainer.AxesContainer """
     from camelot.container.chartcontainer import structure_to_figure_container
     self._value = structure_to_figure_container(
         AbstractCustomEditor.set_value(self, value))
     self.on_draw()
Esempio n. 3
0
    def __init__(self,
                 parent=None,
                 width=50,
                 height=40,
                 dpi=50,
                 field_name='chart',
                 **kwargs):
        from matplotlib.figure import Figure
        from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
        super(ChartEditor, self).__init__(parent)
        AbstractCustomEditor.__init__(self)
        self.setObjectName(field_name)

        chart_frame = QtWidgets.QFrame(self)
        chart_frame.setFrameShape(self.Box)
        chart_frame.setContentsMargins(1, 1, 1, 1)
        chart_frame_layout = QtWidgets.QHBoxLayout()
        chart_frame_layout.setContentsMargins(0, 0, 0, 0)
        chart_frame.setLayout(chart_frame_layout)

        # find out background color, because using a transparent
        # figure fails when the window is resized: the background
        # is not redrawn
        # need to do str() else matplotlib gets confused by the qstring
        # bgcolorrgb = str(self.palette().background().color().name())
        self.fig = Figure(
            figsize=(width, height),
            dpi=dpi,
            facecolor='#ffffff',
        )
        layout = QtWidgets.QHBoxLayout()
        self.canvas = FigureCanvas(self.fig)
        chart_frame_layout.addWidget(self.canvas)
        layout.addWidget(chart_frame)
        button_layout = QtWidgets.QVBoxLayout()
        button_layout.setSpacing(0)

        icon = Icon(
            'tango/16x16/actions/document-print-preview.png').getQIcon()
        button_layout.addStretch()

        print_button = QtWidgets.QToolButton()
        print_button.setIcon(icon)
        print_button.setAutoRaise(True)
        print_button.setToolTip(_('Print Preview'))
        print_button.clicked.connect(self.print_preview)
        button_layout.addWidget(print_button)

        icon = Icon('tango/16x16/actions/edit-copy.png').getQIcon()
        copy_button = QtWidgets.QToolButton()
        copy_button.setIcon(icon)
        copy_button.setAutoRaise(True)
        copy_button.setToolTip(_('Copy to clipboard'))
        copy_button.clicked.connect(self.copy_to_clipboard)
        button_layout.addWidget(copy_button)

        layout.addLayout(button_layout)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                  QtGui.QSizePolicy.Expanding)
        self.canvas.installEventFilter(self)
        self.show_fullscreen_signal.connect(self.show_fullscreen)
        self.canvas.updateGeometry()
        self._litebox = None
        self.gui_context = ListActionGuiContext()
Esempio n. 4
0
 def get_value(self):
     return AbstractCustomEditor.get_value(self) or self._value
Esempio n. 5
0
 def get_value(self):
     return AbstractCustomEditor.get_value( self ) or self._value
Esempio n. 6
0
 def set_value(self, value):
     """Accepts a camelot.container.chartcontainer.FigureContainer or a 
     camelot.container.chartcontainer.AxesContainer """
     from camelot.container.chartcontainer import structure_to_figure_container
     self._value = structure_to_figure_container( AbstractCustomEditor.set_value( self, value ) )
     self.on_draw()