Hey,

You are on the right path, but just missed one thing. The static 
QColorDialog.getColor() can take an optional initial color.
What you will want to do is save the previous QColor only if its valid (not 
every time). You can also set the color to its exact rgb values instead of a 
color name.
In my example, I start the bgColor with a saved value of white, and constantly 
provide it back to the dialog call.

QColorDialog.getColor() - 
http://qt-project.org/doc/qt-4.8/qcolordialog.html#getColor-2

https://gist.github.com/justinfx/5793291
I had to use gist because pastebin kept saying I was posting spam.

Also just one nitpicky thing... I am not sure if you are importing * since you 
didn't post the import statements, but its a lot better to either import the 
exact classes you need, or to import the QtCore and QtGui modules as a 
namespace. This prevents your module from becoming entirely polluted with every 
class in the Qt modules. 

from PyQt4 import QtCore
# or
from PyQt4.QtGui import QFrame
from PyQt4.QtCore import Qt

Hope that helps!


On Jun 17, 2013, at 7:10 AM, David Martinez wrote:

> Hi,
> 
> I'm starting to experiment with PyQT and PySide and I'm loving it.
> 
> I created an object based on the existing widget 'QFrame'. It's a box that 
> when clicked, I can select a color which will become the background of the 
> 'QFrame':
> 
> Here is the code that I have so far:
> 
> http://pastebin.com/L9ge14k0
> 
> Is there a way to open the color selector using the current color as a 
> starting point?
> I can't seem to figure out how to get it working.
> 
> Many thanks.
> 
> -- 
> 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.


Reply via email to