【问题标题】:pyqtgraph weirdness when used with pdb与 pdb 一起使用时的 pyqtgraph 怪异
【发布时间】:2014-07-13 19:28:37
【问题描述】:

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

【问题讨论】:

  • 好吧,在退出时遇到分段错误。我认为这是对潜在问题的暗示。
  • @Veedrac 根据我的经验,使用 pyqtgraph 在退出时不要出现段错误。虽然不完全确定这是 pyqtgraph 的错,但一定是源自底层包。
  • 这听起来令人愉快:P。祝你好运。

标签: python pdb pyqtgraph


【解决方案1】:

我想我明白了。 Qt 中必须在信号/中断(因此在断点上)时自动进行“事件处理”。

这模仿了它:

from pyqtgraph.Qt import QtGui; QtGui.QApplication.processEvents()

【讨论】:

    猜你喜欢
    • 2018-03-12
    • 1970-01-01
    • 1970-01-01
    • 2014-09-03
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 2023-03-31
    • 2013-05-24
    相关资源
    最近更新 更多