0

我正在编写一个 python 脚本来从 PyQt 应用程序中提取特定信息。我的确切目标是提取在应用程序运行时发出的信号。

基本上,我将在编写发射代码片段的特定位置检测(插入我的代码片段)应用程序。由于运行时的检测,我将获得有关发出的信号的信息。

我想用一个场景来解释:

Normal scenario
#A.py(actual code)

#start of a file

from PyQt4.QtGui import *
from PyQt4.QtCore import *
....
....
self.emit(QtCore.SIGNAL("Button_pressed"))
....
....

#end of a file

Instrumented Scenario

#A.py(actual code)

#start of a file

from PyQt4.QtGui import *
from PyQt4.QtCore import *
....
....
signal_sent="Button_pressed" 
print signal_sent
self.emit(QtCore.SIGNAL("Button_pressed"))
....
....

#end of a file

(**注意,只有当我能够解析“emit”语句以便提取字符串“Button_pressed”时,才能将“Button_pressed”值分配给“signal_sent”)

问题陈述:我的目标是准确解析文件中的发出语句,以便我可以检索信号中存在的字符串?我如何解析语句?

4

1 回答 1

0

您可以通过编写以下发射信号来实现相同的目的:-

self.emit(Qt.SIGNAL("buttonPressed(QString)"),"Button_pressed")

和以下连接: -

self.connect(self, Qt.SIGNAL("buttonPressed(QString)"), self.functionCall)
于 2013-07-19T05:33:25.513 回答