Skip to content
Snippets Groups Projects
Commit 4f6fb157 authored by marco's avatar marco
Browse files

added PickColor function

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2707 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent c0dc1901
No related branches found
No related tags found
No related merge requests found
...@@ -39,3 +39,24 @@ def CreateDataViewer(ih,flag=False): ...@@ -39,3 +39,24 @@ def CreateDataViewer(ih,flag=False):
def ClearMessageWidget(): def ClearMessageWidget():
gosty=GostyApp.Instance() gosty=GostyApp.Instance()
gosty.message_widget.Clear() gosty.message_widget.Clear()
from PyQt4.QtGui import *
from ost import gfx
def PickColor(default=gfx.WHITE):
"""
Pops up a color chooser that lets' the user pick a color and returns the
selected color. If the user cancels the color chooser, None is returned.
:rtype: :class:`~ost.gfx.Color`
"""
dialog=QColorDialog()
qt_color=QColor(int(min(255,default.Red()*256)),
int(min(255,default.Green()*256)),
int(min(255,default.Blue()*256)))
qt_color=dialog.getColor(qt_color)
if not qt_color.isValid():
return None
return gfx.Color(qt_color.red()/256.0, qt_color.green()/256.0,
qt_color.blue()/256.0)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment