I would wager is it because signals emitted and received within the same thread use a direct connection, which means that the button has probably not fully completed its "clicked" state until it returns back to the event loop. You could either called QApplication.processEvents() in your slot before you launch a modal dialog to flush the event loop, or you could make the signal/slot connection be of type QueuedConnection, making it put the callback into the event loop to get picked up. In terms of the stylesheet behavior, did you want it to respond to a color change only for the time when it is "pressed down"? or are you using a checkable button that it should be green while in the checked state? There are a couple different pseudo-states for the variations.
On Wed, Jul 31, 2013 at 10:57 AM, drchickins <[email protected]>wrote: > hi all, > > having a small issue with a simple pushButton change of color. > > so the stylesheet is this > > color = QtGui.QColor() > color.setGreen(125) > self.create_button.setStyleSheet( "QPushButton:checked { > background-color: %s }" % color.name()) > > > then i have a callback triggered from a clicked() signal attached to that > pushButton. > > when its clicked its supposed to turn green, which it has up untill i put > a cmds.confirmDialog() within the callback > > the problem is that i gather because the callback hasnt completed i think > the styleSheet doesnt get to finish. and even when i except the button > doesnt change color. > > when i changed the styleSheet to "QPushButton:pressed it worked however > when i > use button.setChecked(False) it dosnt return to its defualt color. > > so it works fine without the maya comfim Dialog but with it in the mix i'm > missing somthing. > > when is a styleSheet activated ? i gather there is a signal that happens. > > anyway any solutions would be great > > john > > -- > 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 post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- 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 post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
