Add top level stack() function for debugging
This commit is contained in:
parent
52754d4859
commit
09aa198731
@ -449,6 +449,25 @@ def dbg(*args, **kwds):
|
||||
return c
|
||||
|
||||
|
||||
def stack(*args, **kwds):
|
||||
"""
|
||||
Create a console window and show the current stack trace.
|
||||
|
||||
All arguments are passed to :func:`ConsoleWidget.__init__() <pyqtgraph.console.ConsoleWidget.__init__>`.
|
||||
"""
|
||||
mkQApp()
|
||||
from . import console
|
||||
c = console.ConsoleWidget(*args, **kwds)
|
||||
c.setStack()
|
||||
c.show()
|
||||
global consoles
|
||||
try:
|
||||
consoles.append(c)
|
||||
except NameError:
|
||||
consoles = [c]
|
||||
return c
|
||||
|
||||
|
||||
def mkQApp():
|
||||
global QAPP
|
||||
inst = QtGui.QApplication.instance()
|
||||
|
@ -147,10 +147,11 @@ class ConsoleWidget(QtGui.QWidget):
|
||||
|
||||
def currentFrame(self):
|
||||
## Return the currently selected exception stack frame (or None if there is no exception)
|
||||
if self.currentTraceback is None:
|
||||
return None
|
||||
index = self.ui.exceptionStackList.currentRow()
|
||||
if index >= 0 and index < len(self.frames):
|
||||
return self.frames[index]
|
||||
else:
|
||||
return None
|
||||
|
||||
def execSingle(self, cmd):
|
||||
try:
|
||||
@ -276,6 +277,7 @@ class ConsoleWidget(QtGui.QWidget):
|
||||
|
||||
def clearExceptionClicked(self):
|
||||
self.currentTraceback = None
|
||||
self.frames = []
|
||||
self.ui.exceptionInfoLabel.setText("[No current exception]")
|
||||
self.ui.exceptionStackList.clear()
|
||||
self.ui.clearExceptionBtn.setEnabled(False)
|
||||
|
Loading…
Reference in New Issue
Block a user