本文整理汇总了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