Cannot hit breakpoints for user generated actions when debugging jython code with PyDev in Eclipse

I am implementing a GUI application in Jython using the Eclipse and PyDev plugin. The problem is that it's hard for me to use the built-in debugger. When I start a debugging session, it just stops. Of course, this is to be expected, since the program simply creates a JFrame, and then it terminates.

So, any breakpoints that I put for different events. clicking the button will never happen because the debugging session is already completed.

What should I do? I'm tired of using fingerprints for all my debugging.

For example, when I tried to debug this little Java example. I have no problem with the breakpoint I set in windowClosing-method

import java.awt.event.*;
import javax.swing.*;
public class Test1 {

public static void main(String s[]) {
    JFrame frame = new JFrame("JFrame Source Demo");
    // Add a window listner for close button
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    frame.setVisible(true);
}
}

jython

from javax.swing import JFrame;
import java.awt.event.WindowListener as WindowListener

class Test1 (JFrame, WindowListener):
    def __init__(self):
        super(JFrame, self).__init__('Some name goes here', defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size = (800, 800))
        self.addWindowListener(self)        
        self.setVisible(True)

    def windowClosing(self, windowEvent):
        print 'window closing'
        pass # want to hit this breakpoint

someFrame = Test1()
pass #breakpoint here maybe

jython , . , , someFrame windowClosing. - , , , , , .

- , ? , - .

+3
2

, .

, , . :

JButton button = new JButton("OK");
button.addActionListener(new ActionListener()
 {
  @Override
  public void action(ActionEvent e)
  {
   System.out.println("button OK has been pressed"; // add breakpoint here
   // call to some code that handles the event
  }
});
+2

btnCompilar = new JButton("Compilar");
btnCompilar.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) {
         compile(); //can't hit breakpoint here
    }
});

actionPerformed, .

void compile(){  
    //can hit breakpoint here
}
+1

Source: https://habr.com/ru/post/1768579/


All Articles