当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasGTK3Cairo.queue_draw方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_gtk3cairo.FigureCanvasGTK3Cairo.queue_draw方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK3Cairo.queue_draw方法的具体用法?Python FigureCanvasGTK3Cairo.queue_draw怎么用?Python FigureCanvasGTK3Cairo.queue_draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_gtk3cairo.FigureCanvasGTK3Cairo的用法示例。


在下文中一共展示了FigureCanvasGTK3Cairo.queue_draw方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CanvasItem

# 需要导入模块: from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo [as 别名]
# 或者: from matplotlib.backends.backend_gtk3cairo.FigureCanvasGTK3Cairo import queue_draw [as 别名]
class CanvasItem(object):
    """Canvas Item
    Has figure, canvas
    """

    def __init__(self, main_controller):
        """ Initializes figure. Sets a default alpha. Initializes
        configuration dictionary. Initializes context menu. Connects
        button release event on canvas.
        """
        self.main_controller = main_controller
        self.figure = Figure()
        self.figure.patch.set_alpha(0.0)
        self.canvas = FigureCanvas(self.figure)

        self.customize_window = None
        self.config = OrderedDict()

        self._context_menu = gtk.Menu()
        self._build_context_menu()
        self.canvas.connect("button_release_event", self.on_button_release,
                            self.canvas)

    def _build_context_menu(self):
        """ Context menu has menu items for exporting to PDF
        and customizing plot.
        """
        export_pdf_item = gtk.MenuItem("Export to PDF...")
        export_pdf_item.connect("activate", self.on_export_pdf, self.canvas)
        customize_item = gtk.MenuItem("Customize...")
        customize_item.connect("activate", self.show_customize)

        self._context_menu.append(export_pdf_item)
        self._context_menu.append(customize_item)

        self._context_menu.show_all()

    def init_default_config(self):
        """ Empty abstract default config.
        """
        pass

    def get_options_dict(self):
        """ Return configuration dictionary.
        """
        return self.config

    def get_config_values(self):
        """ Gets values of all items in configuration dictionary.
        Returns values as keys in new dictionary.
        """
        return {key: configuration.value for key, configuration in
                self.config.iteritems()}

    def set_config_values(self, config):
        """ Sets current configuration values to ones from
        configuration dictionary in parameter.
        """
        if (config):
            for key, val in config.items():
                self.config[key].value = val

    def apply_config(self, revert_data=None, get_function=None):
        """ For each configuration, if revert data exists,
        revert configuration. If no revert data is provided,
        set configuration value to result from get function.
        If no get function is specified, use current value from
        configuration.

        Calls the function within the configuration with the
        revert/get function/current value.

        Calls queue_draw to update after applying configuration.
        """
        for option_name in self.get_options_dict():
            if (self.config[option_name].configurable):
                if (self.config[option_name].function):
                    function = self.config[option_name].function
                    if (revert_data):
                        new_val = revert_data[option_name]
                    elif (get_function):
                        new_val = get_function(option_name)
                    else:
                        new_val = self.config[option_name].value

                    self.config[option_name].value = new_val
                    function(new_val)

        self.canvas.queue_draw()

    @property
    def title(self):
        """ Abstract title getter.
        """
        raise NotImplementedError

    def on_export_pdf(self, widget, canvas):
        """ Calls controller's export pdf function with plot title.
        """
        self.main_controller.on_export_pdf(None, canvas, self.title)
#.........这里部分代码省略.........
开发者ID:chairmanmeow50,项目名称:Brainspawn,代码行数:103,代码来源:canvas_item.py


注:本文中的matplotlib.backends.backend_gtk3cairo.FigureCanvasGTK3Cairo.queue_draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。