Why aren't breakpoints working on the Swing Event Dispatch Thread in PyDev?

ぃ、小莉子 提交于 2019-12-04 21:42:40

It's actually a Jython issue.

I.e.: in the code below, when TestFunc is called, the print from the trace_dispatch should be called, but it's not.

So, the Jython tracing implementation is not calling the tracing function as it should in that situation. You can 'help' the PyDev debugger by calling import pydevd;pydevd.settrace(suspend=False) so that the debugger discovers about that frame (i.e.: in the start of TestFunc add that line of code).

Note that if you don't pass the suspend=False, it'll act as a breakpoint in the code and will stop the execution at that line.

import sys
import threading
def trace_dispatch(frame, event, arg):
    print frame.f_code.co_filename, frame.f_code.co_name
sys.settrace(trace_dispatch)
threading.settrace(trace_dispatch)

from javax.swing import JFrame, JButton

def TestFunc(event):
    print "Hey"

if __name__ == '__main__':
    mainWindow = JFrame('Test', 
                        defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                        size = (1024, 600))
    mainWindow.add(JButton("Hey", actionPerformed = TestFunc))
    mainWindow.visible = True
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!