On Tue, Aug 21, 2018, 7:38 AM <[email protected]> wrote:

>
> Hi Justin. I have 2 questions tho. You mention that I am operating in my
> custom CustomButtom logic, but when I create a button, I have the text from
> that custom class. If it`s picking up the default QPushButton class, why I
> have the text?I think I`m confused about this.
>

First look at this code when you create the button :

    buttonCreatorInstance = CustomButtom()
    self.windowNorth = self.menuLikeWindow("windowNorth")
    self.windowNorthButton =
buttonCreatorInstance.buttonCreator(self.windowNorth, "buttonWindNorth",
self.windowsList)

Your custom button is created locally with no text and no parent. It will
die after this function ends.
You call the creator method on it, passing a parent and text. And save None
as the result to your windowNorthButton field.

Now look at how the button is created:

def buttonCreator(self, parentWindow, buttonName, windowsList):
    self.buttonTest = QtGui.QPushButton(parent = parentWindow)
    self.buttonTest.setObjectName(buttonName)
    self.buttonTest.setText("test")

You create your button with just the parent. You set the object name to the
text, which isn't a display property. And then you set the text to a hard
coded literal.


> The second thing is that you say create and save. My guess is that I need
> to create an instance from the CustomButtom class, and return it, which is
> something I am not doing right now. Is that it?
>

Yes. Instead of that creator method creating a QPushButton, just have it
create a CustomButtom, and also don't make it a method of CustomButtom.
Honestly, it feels like all of that creator code should be in your
CustomButtom.__init__


> thanks again for your time, it would take me some time to figure it out by
> myself.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/8bcc6aca-04b6-4fef-93b9-8df019f1baba%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2B0V_rRV8%2BkQ7y3%3DZ%3D-7xXcNcm1GxkFmuUhg4d3vJDhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to