Source code for openalea.oalab.control.selector

# -*- python -*-
#
#       OpenAlea.OALab: Multi-Paradigm GUI
#
#       Copyright 2014 INRIA
#
#       File author(s): Guillaume Baty <guillaume.baty@inria.fr>
#
#       File contributor(s):
#
#       Distributed under the Cecill-C License.
#       See accompanying file LICENSE.txt or copy at
#           http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html
#
#       OpenAlea WebSite : http://openalea.gforge.inria.fr
#
###############################################################################

from openalea.vpltk.qt import QtGui, QtCore

from openalea.core.observer import AbstractListener

from openalea.oalab.widget.control.constraint import IntConstraintWidget, FloatConstraintWidget
from openalea.oalab.widget.control import IntSimpleSlider, IntSpinBox, IntSlider, IntDial
from openalea.oalab.widget.control import FloatSlider, FloatSpinBox, FloatSimpleSlider
from openalea.oalab.widget.control import BoolCheckBox
from openalea.oalab.widget.control import IntRangeSpinBoxes, IntRangeSimpleSlider, IntRangeSlider
from openalea.oalab.widget.control import ColormapRectangle, ColormapSwitcher

from openalea.oalab.painter import PainterColormap


[docs]class IntWidgetSelector(object): @classmethod
[docs] def edit(cls, control, shape=None): if shape is None: shape = 'hline' if shape == 'hline': widget = IntSlider() elif shape == 'vline': widget = IntSimpleSlider() widget.setOrientation(QtCore.Qt.Vertical) elif shape in ('large', 'small', 'responsive'): widget = IntDial() else: widget = None return widget
@classmethod
[docs] def edit_constraints(cls): widget = IntConstraintWidget() return widget
[docs]class FloatWidgetSelector(object): @classmethod
[docs] def edit(cls, control, shape=None): if shape is None: shape = 'hline' elif shape in ('large', 'hline'): # widget = FloatSimpleSlider() widget = FloatSlider() # widget = FloatSpinBox() elif shape == 'vline': widget = FloatSimpleSlider() widget.setOrientation(QtCore.Qt.Vertical) # widget = FloatSpinBox() elif shape in ('small', 'responsive'): widget = FloatSpinBox() else: widget = None return widget
@classmethod
[docs] def edit_constraints(cls): widget = FloatConstraintWidget() return widget
[docs]class IntRangeWidgetSelector(object): @classmethod
[docs] def edit(cls, control, shape=None): if shape is None: shape = 'hline' elif shape in ('large', 'hline'): widget = IntRangeSimpleSlider() elif shape == 'vline': widget = IntRangeSimpleSlider() widget.setOrientation(QtCore.Qt.Vertical) elif shape in ('small', 'responsive'): widget = IntRangeSpinBoxes() else: widget = None return widget
@classmethod
[docs] def edit_constraints(cls): widget = IntConstraintWidget() return widget
[docs]class ColormapWidgetSelector(object): @classmethod
[docs] def edit(cls, control, shape=None): if shape is None: shape = 'hline' elif shape in ('hline', 'responsive', 'large'): widget = ColormapSwitcher() elif shape == 'vline': widget = ColormapRectangle() widget.setOrientation(QtCore.Qt.Vertical) elif shape in ('small'): widget = ColormapRectangle() else: widget = None return widget
@classmethod
[docs] def paint(self, control, shape=None): if shape == 'hline': return PainterColormap()