cafe079910
* Improve HistogramLUTItem docs, a few cosmetic changes * Initial implementation of horizontally-oriented HistogramLUTItem - Also adds support in HistogramLUTWidget - Fixes AxisItem orientation bug for vertical orientation - Make use of GradientEditorItem orientation (fixes another bug for vertical orientation) - Use horizontal orientation in an example for demonstration * Remove unused HistogramLUTItem option * A few more minor fixups * Copy paste bug * Use f-strings * Update from review and a couple more minor updates * Woops * Add doc for orientation arg * Add top/bottom orientation to doc. Expand on levelMode doc a bit
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Widget displaying an image histogram along with gradient editor. Can be used to adjust
|
|
the appearance of images. This is a wrapper around HistogramLUTItem
|
|
"""
|
|
|
|
from ..Qt import QtGui, QtCore
|
|
from .GraphicsView import GraphicsView
|
|
from ..graphicsItems.HistogramLUTItem import HistogramLUTItem
|
|
|
|
__all__ = ['HistogramLUTWidget']
|
|
|
|
|
|
class HistogramLUTWidget(GraphicsView):
|
|
"""QWidget wrapper for :class:`~pyqtgraph.HistogramLUTItem`.
|
|
|
|
All parameters are passed along in creating the HistogramLUTItem.
|
|
"""
|
|
|
|
def __init__(self, parent=None, *args, **kargs):
|
|
background = kargs.pop('background', 'default')
|
|
GraphicsView.__init__(self, parent, useOpenGL=False, background=background)
|
|
self.item = HistogramLUTItem(*args, **kargs)
|
|
self.setCentralItem(self.item)
|
|
|
|
self.orientation = kargs.get('orientation', 'vertical')
|
|
if self.orientation == 'vertical':
|
|
self.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
|
|
self.setMinimumWidth(95)
|
|
else:
|
|
self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
|
self.setMinimumHeight(95)
|
|
|
|
def sizeHint(self):
|
|
if self.orientation == 'vertical':
|
|
return QtCore.QSize(115, 200)
|
|
else:
|
|
return QtCore.QSize(200, 115)
|
|
|
|
def __getattr__(self, attr):
|
|
return getattr(self.item, attr)
|