我不知道OperationsRig类的定义,所以我自己定义了一个。
因为它可以成功匹配,我认为这不是pyqt的问题。
这是我的代码:
class OperationsRig:
def foo(self, msg):
print('foo:' + str(msg))
return 'foo OK'
def foo1(self, msg):
print('foo1:' + str(msg))
return 'foo1 OK'
opr = OperationsRig()
def operations_module(text):
# Text gives me the name to Match ------------------#
# ------------------------#
# have 3 ways of getting the class instance methods into a list to iterate ..
method_list = [func for func in dir(opr) if callable(getattr(opr, func))]
# This var is a list to pass to the Method
Sel_list = [1,2,3]
# iterate over the "self.OperationsRig" methods
#
""" option 1 """
for meth in method_list:
if text.strip().lower() in meth.lower()[:]:
# if match, and it does, will call the class method and send the data.
pass
return getattr(opr, meth)(Sel_list) # Executes the funcion instance, but is not
# sending the data, I've checked printing inside.
# NoneTypeObject is not iterable. no data sent.
print(operations_module('foo'))
print(operations_module('foo1'))
结果如下:
foo:[1, 2, 3]
foo OK
foo1:[1, 2, 3]
foo1 OK
Process finished with exit code 0
正如我所期望的那样,我仍然不明白为什么你的代码失败了。或者你可以做进一步的解释。