Issue
I understand why I am getting this error, it's looking for my object as an argument, and receiving a string value. But I'm confused as to what the solution would be?
The following code snippet is simply trying to run this command;
self.buttonGroup.addButton(self.ui.m001)
x number of times:
num = 0
range_ = 10
prefix = "m"
for i in range (range_):
if num <(range_-1):
numString = "00"+str(num)
if (num >9):
numString = "0"+str(num)
button = "self.ui."+prefix+numString
self.buttonGroup.addButton(button)
num +=1
print self.buttonGroup
Solution
The problem is that button is a string, a possible solution is to use getattr
.
Change:
button = "self.ui."+prefix+numString
to
button = getattr(self.ui, prefix+numString)
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.