2014-05-24 27 views
1

我很驚訝地發現,斷點的存在可以改變一個pyqtgraph對象(python2.7)的行爲。pyqtgraph古怪與pdb一起使用

這裏有一個最小的工作示例:

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?
+0

嗯,*我*獲得退出分段錯誤。我認爲這是對潛在問題的暗示。 – Veedrac

+0

@Veedrac從我的經驗來看,它是rt *不會在pyqtgraph退出時得到* segfault。不完全確定這是pyqtgraph的錯誤,但必須源自底層軟件包。 – shx2

+0

這聽起來令人愉快:P。祝你好運。 – Veedrac

回答

1

我想我想通了。在Qt中必須有一個自動的「事件處理」在一個信號/中斷(從而產生一個斷點)。

這模擬它:

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