Changed my mind
This commit is contained in:
parent
0703e3db9b
commit
8519efdd8d
@ -1,5 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
import warnings
|
|
||||||
|
|
||||||
from ..Qt import QtCore, QtGui
|
from ..Qt import QtCore, QtGui
|
||||||
from ..python2_3 import asUnicode
|
from ..python2_3 import asUnicode
|
||||||
@ -96,16 +95,6 @@ class WidgetParameterItem(ParameterItem):
|
|||||||
# shrink row heights a bit for more compact look
|
# shrink row heights a bit for more compact look
|
||||||
sw.setHeight(int(sw.height() * 0.9))
|
sw.setHeight(int(sw.height() * 0.9))
|
||||||
sb.setHeight(int(sb.height() * 0.9))
|
sb.setHeight(int(sb.height() * 0.9))
|
||||||
# manually override size hints for certain parameter types
|
|
||||||
t = self.param.opts['type']
|
|
||||||
if t == 'text':
|
|
||||||
sw.setWidth(100)
|
|
||||||
sw.setHeight(100)
|
|
||||||
elif t == 'color':
|
|
||||||
sw.setWidth(100)
|
|
||||||
elif t == 'colormap':
|
|
||||||
sw.setWidth(100)
|
|
||||||
sw.setHeight(35)
|
|
||||||
if self.asSubItem:
|
if self.asSubItem:
|
||||||
self.setSizeHint(1, sb)
|
self.setSizeHint(1, sb)
|
||||||
self.subItem.setSizeHint(0, sw)
|
self.subItem.setSizeHint(0, sw)
|
||||||
@ -162,17 +151,10 @@ class WidgetParameterItem(ParameterItem):
|
|||||||
w.value = lambda: asUnicode(w.text())
|
w.value = lambda: asUnicode(w.text())
|
||||||
w.setValue = lambda v: w.setText(asUnicode(v))
|
w.setValue = lambda v: w.setText(asUnicode(v))
|
||||||
w.sigChanging = w.textChanged
|
w.sigChanging = w.textChanged
|
||||||
elif t == 'text':
|
|
||||||
w = QtGui.QTextEdit()
|
|
||||||
w.setMaximumHeight(100)
|
|
||||||
w.setReadOnly(opts.get('readonly', False))
|
|
||||||
w.value = lambda: str(w.toPlainText())
|
|
||||||
w.setValue = w.setPlainText
|
|
||||||
w.sigChanged = w.textChanged
|
|
||||||
self.hideWidget = False
|
|
||||||
self.asSubItem = True
|
|
||||||
elif t == 'color':
|
elif t == 'color':
|
||||||
w = ColorButton()
|
w = ColorButton()
|
||||||
|
h = w.sizeHint().height()
|
||||||
|
w.sizeHint = lambda: QtCore.QSize(100, h)
|
||||||
w.sigChanged = w.sigColorChanged
|
w.sigChanged = w.sigColorChanged
|
||||||
w.sigChanging = w.sigColorChanging
|
w.sigChanging = w.sigColorChanging
|
||||||
w.value = w.color
|
w.value = w.color
|
||||||
@ -183,6 +165,7 @@ class WidgetParameterItem(ParameterItem):
|
|||||||
elif t == 'colormap':
|
elif t == 'colormap':
|
||||||
from ..widgets.GradientWidget import GradientWidget ## need this here to avoid import loop
|
from ..widgets.GradientWidget import GradientWidget ## need this here to avoid import loop
|
||||||
w = GradientWidget(orientation='bottom')
|
w = GradientWidget(orientation='bottom')
|
||||||
|
w.sizeHint = lambda: QtCore.QSize(300, 35)
|
||||||
w.sigChanged = w.sigGradientChangeFinished
|
w.sigChanged = w.sigGradientChangeFinished
|
||||||
w.sigChanging = w.sigGradientChanged
|
w.sigChanging = w.sigGradientChanged
|
||||||
w.value = w.colorMap
|
w.value = w.colorMap
|
||||||
@ -377,7 +360,6 @@ class SimpleParameter(Parameter):
|
|||||||
'float': float,
|
'float': float,
|
||||||
'bool': bool,
|
'bool': bool,
|
||||||
'str': asUnicode,
|
'str': asUnicode,
|
||||||
'text': asUnicode,
|
|
||||||
'color': self._interpColor,
|
'color': self._interpColor,
|
||||||
'colormap': self._interpColormap,
|
'colormap': self._interpColormap,
|
||||||
}[self.opts['type']]
|
}[self.opts['type']]
|
||||||
@ -396,7 +378,6 @@ registerParameterType('int', SimpleParameter, override=True)
|
|||||||
registerParameterType('float', SimpleParameter, override=True)
|
registerParameterType('float', SimpleParameter, override=True)
|
||||||
registerParameterType('bool', SimpleParameter, override=True)
|
registerParameterType('bool', SimpleParameter, override=True)
|
||||||
registerParameterType('str', SimpleParameter, override=True)
|
registerParameterType('str', SimpleParameter, override=True)
|
||||||
registerParameterType('text', SimpleParameter, override=True)
|
|
||||||
registerParameterType('color', SimpleParameter, override=True)
|
registerParameterType('color', SimpleParameter, override=True)
|
||||||
registerParameterType('colormap', SimpleParameter, override=True)
|
registerParameterType('colormap', SimpleParameter, override=True)
|
||||||
|
|
||||||
@ -681,49 +662,21 @@ registerParameterType('action', ActionParameter, override=True)
|
|||||||
|
|
||||||
|
|
||||||
class TextParameterItem(WidgetParameterItem):
|
class TextParameterItem(WidgetParameterItem):
|
||||||
def __init__(self, param, depth):
|
|
||||||
warnings.warn(
|
|
||||||
"This functionality is now handled directly by WidgetParameterItem.",
|
|
||||||
DeprecationWarning, stacklevel=2
|
|
||||||
)
|
|
||||||
WidgetParameterItem.__init__(self, param, depth)
|
|
||||||
self.hideWidget = False
|
|
||||||
self.subItem = QtGui.QTreeWidgetItem()
|
|
||||||
self.addChild(self.subItem)
|
|
||||||
|
|
||||||
def treeWidgetChanged(self):
|
|
||||||
## TODO: fix so that superclass method can be called
|
|
||||||
## (WidgetParameter should just natively support this style)
|
|
||||||
#WidgetParameterItem.treeWidgetChanged(self)
|
|
||||||
tw = self.treeWidget()
|
|
||||||
if tw is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
tw.setFirstItemColumnSpanned(self.subItem, True)
|
|
||||||
tw.setItemWidget(self.subItem, 0, self.textBox)
|
|
||||||
|
|
||||||
# for now, these are copied from ParameterItem.treeWidgetChanged
|
|
||||||
self.setHidden(not self.param.opts.get('visible', True))
|
|
||||||
self.setExpanded(self.param.opts.get('expanded', True))
|
|
||||||
|
|
||||||
def makeWidget(self):
|
def makeWidget(self):
|
||||||
self.textBox = QtGui.QTextEdit()
|
self.hideWidget = False
|
||||||
self.textBox.setMaximumHeight(100)
|
self.asSubItem = True
|
||||||
self.textBox.setReadOnly(self.param.opts.get('readonly', False))
|
self.textBox = w = QtGui.QTextEdit()
|
||||||
self.textBox.value = lambda: str(self.textBox.toPlainText())
|
w.sizeHint = lambda: QtCore.QSize(300, 100)
|
||||||
self.textBox.setValue = self.textBox.setPlainText
|
w.setReadOnly(self.param.opts.get('readonly', False))
|
||||||
self.textBox.sigChanged = self.textBox.textChanged
|
w.value = lambda: str(w.toPlainText())
|
||||||
return self.textBox
|
w.setValue = w.setPlainText
|
||||||
|
w.sigChanged = w.textChanged
|
||||||
|
return w
|
||||||
|
|
||||||
|
|
||||||
class TextParameter(Parameter):
|
class TextParameter(Parameter):
|
||||||
"""Editable string; displayed as large text box in the tree."""
|
"""Editable string; displayed as large text box in the tree."""
|
||||||
itemClass = TextParameterItem
|
itemClass = TextParameterItem
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
warnings.warn(
|
|
||||||
"This functionality is now handled directly by SimpleParameter.",
|
|
||||||
DeprecationWarning, stacklevel=2
|
|
||||||
)
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
# registerParameterType('text', TextParameter, override=True)
|
|
||||||
|
registerParameterType('text', TextParameter, override=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user