示例#1
0
    def perform(self, event):

        plot_component = self.container.component

        filter = 'PNG file (*.png)|*.png|\nTIFF file (*.tiff)|*.tiff|'
        dialog = FileDialog(action='save as', wildcard=filter)

        if dialog.open() != OK:
            return

        # Remove the toolbar before saving the plot, so the output doesn't
        # include the toolbar.
        plot_component.remove_toolbar()

        filename = dialog.path

        width, height = plot_component.outer_bounds

        gc = PlotGraphicsContext((width, height), dpi=72)
        gc.render_component(plot_component)
        try:
            gc.save(filename)
        except KeyError, e:
            errmsg = "The filename must have an extension that matches a graphics"
            errmsg = errmsg + " format, such as '.png' or '.tiff'."
            if str(e.message) != '':
                errmsg = ("Unknown filename extension: '%s'\n" % str(e.message)) + errmsg

            error(None, errmsg, title="Invalid Filename Extension")
示例#2
0
    def perform(self, event):
        plot_component = self.container.component

        # Remove the toolbar before saving the plot, so the output doesn't
        # include the toolbar.
        plot_component.remove_toolbar()

        width, height = plot_component.outer_bounds

        gc = PlotGraphicsContext((width, height), dpi=72)
        gc.render_component(plot_component)

        if ETSConfig.toolkit == 'wx':
            self._perform_wx(width, height, gc)
        else:
            pass

        # Restore the toolbar.
        plot_component.add_toolbar()
示例#3
0
 def _get_height(self):
     gc = PlotGraphicsContext((100,100), dpi=72)
     gc.set_font(self.label_font)
     (w, h, descent, leading) = gc.get_full_text_extent(self.label)
     return self._image.height() + h
示例#4
0
 def _get_width(self):
     gc = PlotGraphicsContext((100,100), dpi=72)
     gc.set_font(self.label_font)
     (w, h, descent, leading) = gc.get_full_text_extent(self.label)
     return max(self._image.width(), w)