在 Eclipse 中使用 PyDev 调试 jython 代码时无法为用户生成的操作命中断点
我正在使用 Eclipse 和 PyDev 插件在 Jython 中实现 GUI 应用程序。 问题是我很难使用内置调试器。当我启动调试会话时,它就会停止。当然,这应该是预料之中的,因为程序只是创建了一个 JFrame,然后就完成了。
因此,我为不同事件设置的任何断点(例如按下按钮)永远不会发生,因为调试会话已经终止。
我应该怎么办 ?我已经厌倦了使用打印来进行所有调试。
例如,当我尝试调试这个小型 Java 示例时。我没问题打 我在 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 方法中添加了一个断点。仍然不走运,当我关闭窗口时它没有被击中,但当我看到打印输出时我看到它被执行。
谁能告诉我我做错了什么?我确信我忘记了一些非常简单的事情。
I'm implementing a GUI application in Jython, using Eclipse and PyDev plugin.
The problem is that I have a hard time using the builtin debugger. When I start a debug session it just stops. Of course this should be expected as the program just creates a JFrame and then it's finished.
So any breakpoints I put for different events .e.g. pressing a button, will never happen as the debug session is already terminated.
What should I do ? I'm growing tired of using prints for all my debugging.
For instance, when I tried debugging this small Java example. I have no problem to hit
the breakpoint I had set in the 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);
}
}
And then I tried this somewhat more or less similiar example in 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
If I tried to run the jython example in the debugger and it just terminates. Ok then I added a breakpoint after I created someFrame and a breakpoint in the windowClosing method. Still no luck, It doesn't get hit when I close the window but I see it executed as I see the printout.
Can anyone tell me what I'm doing wrong ? I'm sure I forgot something very simple.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在启动应用程序的主方法的第一行放置一个断点。
如果要调试某些操作(例如按下按钮),请向按钮添加操作侦听器,并在处理方法内添加断点。例如:
Put a breakpoint in the first line of your main method that initiates the application.
If you want to debug certain actions like pressing a button add an action listener to a button and inside the handling method add the breakpoint. For example:
我遇到了同样的问题
,我无法在 actionPerformed 中命中断点,所以我只是创建了一个方法并在其中使用了断点。
I had the same problem
I couldn't hit breakpoints inside actionPerformed, so I just made a method and used breakpoints in it.