You are replacing the same self.frame each time you loop
for i in range (1,5):
self.frame = QtGui.QFrame(self.Frame_ptr)
This will work in terms of creating them and parenting each button to the frame
you just made.
As a different point, I don't see where you have the attribute name:
> MainUi.Frame_1.children
Are you trying to refer directly to the objectName you set dynamically as an
attribute? Frame_1 would not automatically resolve to an object name unless you
explicitly did:
MainUi.Frame_1 = anObject
On Sep 3, 2012, at 12:54 AM, PBLN RAO <[email protected]> wrote:
> Hi,
>
> I have a QFrame (Frame_ptr), and at run time i am creating a frames in loop
> with child objects in that frame.
>
> like
> [code]
> for i in range (1,5):
> self.frame = QtGui.QFrame(self.Frame_ptr) # creating frame as
> child in "Frame_prt" as discussed above
> self.frame.setGeometry(QtCore.QRect(9, self.Record_Location, 575, 25))
> self.frame.setMinimumSize(QtCore.QSize(575, 25))
> self.frame.setMaximumSize(QtCore.QSize(575, 10))
> self.frame.setFrameShape(QtGui.QFrame.NoFrame)
> self.frame.setFrameShadow(QtGui.QFrame.Raised)
> self.frame.setObjectName("Frame_" + i)
> self.frame.show()
>
> #Adding Button
> self.pushButton = QtGui.QPushButton(i,self.frame)
> #creating as child in above created frame
> self.pushButton.setGeometry(QtCore.QRect(0, 0, 65, 25))
> self.pushButton.setAutoFillBackground(False)
> self.pushButton.setCheckable(True)
> self.pushButton.setObjectName("Btn_" + i)
>
> [/code]
>
> now in maya if i use the below command it gives me error
> [code]
> for child1 in MainUi.Frame_1.children():
> print child1.objectName()
>
> # Error: AttributeError: 'Interface' object has no attribute 'Frame_012' #
>
> [/code]
>
> if i create the same in designer and use the same command i can retrieve the
> details.
> how to overcome this issue.
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe