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


Python FigureCanvasGTK3Agg.queue_draw方法代码示例

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


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

示例1: HeapGraph

# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import queue_draw [as 别名]
class HeapGraph(Gtk.ScrolledWindow):
    def __init__(self, debugger):
        """
        @type debugger: debugger.Debugger
        """
        Gtk.ScrolledWindow.__init__(self)
        self.debugger = debugger
        self.debugger.heap_manager.on_heap_change.subscribe(
            lambda heap: self._handle_heap_change(heap))
        self.debugger.on_process_state_changed.subscribe(
            lambda state, data: self._handle_process_change(state))
        self.sizes = []
        self.times = []

        figure = Figure()
        self.axis = figure.add_subplot(111)

        figure.subplots_adjust(bottom=0.3)

        self.canvas = Canvas(figure)
        self.add_with_viewport(self.canvas)

        self.heap_size = 0
        self.start_time = 0

    def redraw(self):
        self.axis.set_xlabel('time [s]')
        self.axis.set_ylabel('heap size [MiB]')
        self.axis.plot(self.times, self.sizes, "r")
        self.canvas.queue_draw()

    def _reset(self):
        self.sizes = []
        self.times = []
        self.heap_size = 0
        self.start_time = time.time()
        self.axis.cla()

    def _handle_process_change(self, state):
        """
        @type state: enums.ProcessState
        """
        if state == ProcessState.Launching:
            self._reset()
            self.redraw()
        elif state == ProcessState.Running:
            self._schedule_refresh()

    def _timer_tick(self):
        self.sizes.append(self.heap_size)
        self.times.append(time.time() - self.start_time)
        self.redraw()
        return self.debugger.process_state == ProcessState.Running

    def _schedule_refresh(self):
        GObject.timeout_add(1000,
                            self._timer_tick)

    def _handle_heap_change(self, heap):
        """
        @type heap: list of debugee.HeapBlock
        """
        size = 0
        for block in heap:
            size += block.size

        self.heap_size = size / 1024.0  # size in MiBs
开发者ID:Kobzol,项目名称:debug-visualizer,代码行数:69,代码来源:heap_detail.py


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