pyqtgraph与pdb一起使用时的怪异

2024-04-19 06:55:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我惊讶地发现,仅仅断点的存在就可以改变pyqtgraph对象(python2.7)的行为。你知道吗

下面是一个最小的工作示例:

import pyqtgraph as pg
pg.mkQApp()
pw = pg.PlotWidget()
p1 = pw.plotItem
p1.showAxis('right')
#import pdb; pdb.set_trace()  # Running once with this line, once without
print p1.getAxis('right').rect().width()

运行它:

# No breakpoint:
% python qtg_pdb_bug.py
0.0
# With breakpoint:
% python qtg_pdb_bug.py
> qtg_pdb_bug.py(7)<module>()
-> print p1.getAxis('right').rect().width()
(Pdb) c
35.0

问题:

  1. 出于好奇:当停在导致这种奇怪的断点时会发生什么?这是pyqtgraph中的错误吗?你知道吗
  2. 哪个是正确的/预期的结果?0还是35?你知道吗

Tags: pyrectimportrightbugpdbpyqtgraphpg