Reputation: 12294
I'm using Jython, Swing, and PyDev (Eclipse).
Breakpoints are not being hit on any code that runs on the EDT (aka AWT Event Queue?).
This includes:
SwingUtilities.invokeLater()
(See the last example here.Swing event code to reproduce:
from javax.swing import JFrame, JButton
def TestFunc(event):
#breakpoints in this function don't work
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
invokeLater() code to reproduce:
from java.lang import Runnable
from javax.swing import SwingUtilities
import threading
class foo(Runnable):
def __init__(self, bar):
self.bar = bar
def run(self):
#breakpoints in this function don't work
print threading.currentThread()
print self.bar
if __name__ == '__main__':
myFoo = foo(5)
SwingUtilities.invokeLater(myFoo)
Upvotes: 0
Views: 358
Reputation: 25332
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
Upvotes: 1