调试GUI应用程序的最佳方法(尤其是在Python中)? [英] Best way to debug a GUI application (particularly in Python)?

查看:51
本文介绍了调试GUI应用程序的最佳方法(尤其是在Python中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试调试未编写的具有GUI的源代码(在Python中)(

So I'm trying to debug this source code (in Python) that I didn't write that has a GUI (Kivy in particular, and I'm trying to figure out what code/event is being triggered when I click on certain things. I try to put in breakpoints for where I think it's going to be triggered, I sometimes find that I'm wrong, and the breakpoint doesn't seem to ever be encountered for what I want.

任何人都对GUI调试有任何建议,并弄清某些事件(特别是在Python中)触发了什么?

Anyone have any advice for GUI debugging, and figuring out what is being triggered by certain events, especially in Python?

推荐答案

有一个著名的基于CLI的笑话程序,名为 xcowsay.它显示一个弹出窗口(一个GUI)-带有消息的母牛的图片.您首先需要在PC上安装xcowsay,它很小.

There's a famous CLI based joke program called xcowsay. It displays a popup(a GUI one) - picture of a cow with a message. You'll need to install xcowsay on your PC first, it is very small.

而不是 print ,然后在您的终端中搜索消息,请使用此单行纸

Instead of print and then searching for the message in your terminal, use this oneliner

# Example
import subprocess; subprocess.Popen(['xcowsay', 'your message here', '-t 1'])

# General syntax
import subprocess; subprocess.Popen(['xcowsay', string1, string2, string3 ..., '-t 1'])

# For printing objects, cast them to str first
# '-t 1' is for displaying the popup for one second, you can change it.

为什么要使用它:

  1. 简单而简短-一行
  2. 适用于大多数系统-Linux,Mac和Windows
  3. 异步运行-不会干扰您应用的执行
  4. 支持多行字符串
  5. Unicode支持-表情符号可以正常工作

当我开始使用Python时发现了这一点,并且不知道 pdb 等.实际上,该程序可以 GUI 遍历整个CLI.

I found this when I started using Python, and didn't know of pdb etc. In fact, this program can GUIfy your whole CLI.

截图

这篇关于调试GUI应用程序的最佳方法(尤其是在Python中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆