1

我惊讶地发现仅仅存在一个断点就可以改变 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?
4

1 回答 1

1

我想我想通了。在信号/中断(因此在断点上)时,Qt 中必须有自动的“事件处理”。

这模仿它:

from pyqtgraph.Qt import QtGui; QtGui.QApplication.processEvents()
于 2014-05-27T08:12:18.713 回答