简体   繁体   English

在Python GUI应用程序中找到所谓的def

[英]Finding what calls a def from a Python GUI app

I'm trying to understand a Python app developed by a peer who left the company. 我试图了解由离开公司的同行开发的Python应用程序。 There is a def in a class of a module that I am trying to find what within the GUI would invoke it. 我正在尝试在GUI的类中找到一个def ,以尝试在GUI中调用它。 I am using Visual Studio and have Python Tools installed. 我正在使用Visual Studio并安装了Python工具。

I know about shift-F12 but it doesn't seem to do the same as Java and Eclipse, which I am more versed in. So I'm getting frustrated. 我知道shift-F12,但是它似乎与Java和Eclipse并没有像我一样,我更精通。所以我感到沮丧。

Module: LoadSet.py

...other classes in this file...
class LoadSet_Base(object):
   ...other def in this Class...
    def copy_from(self, that):
       I have a break in this section but I never can get into this section

There are over 200 Classes in the project so it is not a small project. 该项目中有200多个班级,因此这不是一个小项目。 I've taken a number of Python training modules at SkillPort and all have been basic teachings of the language, and seem way more straightforward than my ex-peer's code. 我在SkillPort上学习了许多Python培训模块,所有模块都是该语言的基本知识,并且比前辈的代码更直接。 Perhaps my ex-peer's code is not pythonic! 也许我的前辈的代码不是pythonic!

So how can I find what widget, click, action etc... within a GUI (wxPython) app would invoke this method? 那么,如何在GUI(wxPython)应用程序中找到将调用此方法的小部件,单击,操作等?

I usually use the IDE to find all usages of a particular function if I don't know how it is used. 如果不知道如何使用某个特定函数,我通常会使用它来查找它的所有用法。 PyCharm and Wingware both have this built in. I would be greatly surprised if Visual Studio didn't have some kind of right-click support for this too. PyCharm和Wingware都内置了此功能。如果Visual Studio也没有对此提供某种右键单击支持,我将感到非常惊讶。

If all else fails, grep for that function name in the entirety of the source. 如果所有其他方法均失败,则在整个源代码中对该函数名称使用grep。

It is possible that you have found an instance of dead code too. 您可能也找到了无效代码的实例。 Perhaps the code was refactored and that function / method is no longer called. 也许代码已重构,并且不再调用该函数/方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM