Hello,
on matplotlib 1.0, using qt4agg backend, the 'edit curves and lines' option
doesn't works.
This is a quick patch that fix that problem.
It doesn't fix this snippet though:
(on lib/matplotlib/backends/qt4_editor/formlayout.py, FormWidget.setup)
elif isinstance(value, (list, tuple)):
selindex = value.pop(0)
tuple don't have pop.
However with the patch this bug is not triggered anymore.
Thanks!
Riccardo
From 73620d96694dbd5af49825c726232b67cd568fee Mon Sep 17 00:00:00 2001
From: Riccardo Gori <goricca...@gmail.com>
Date: Sat, 18 Sep 2010 12:10:35 +0200
Subject: [PATCH] Fix color tuples for qt4
---
lib/matplotlib/backends/qt4_editor/formlayout.py | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/lib/matplotlib/backends/qt4_editor/formlayout.py b/lib/matplotlib/backends/qt4_editor/formlayout.py
index 0accdbb..ddd956b 100644
--- a/lib/matplotlib/backends/qt4_editor/formlayout.py
+++ b/lib/matplotlib/backends/qt4_editor/formlayout.py
@@ -116,6 +116,19 @@ def text_to_qcolor(text):
color.setNamedColor(text)
return color
+def tuple_to_qcolor(tup):
+ """
+ Convert a tuple of floats to QColor
+ """
+ color = QColor()
+ if not isinstance(tup, tuple) or len(tup) != 3:
+ return color
+ if not all(map(lambda x: isinstance(x, float) and \
+ (x <= 1.) and \
+ (x >= 0.), tup)):
+ return color
+ color.setRgbF(*tup)
+ return color
class ColorLayout(QHBoxLayout):
"""Color-specialized QLineEdit layout"""
@@ -252,6 +265,10 @@ class FormWidget(QWidget):
field = ColorLayout(QColor(value), self)
elif isinstance(value, (str, unicode)):
field = QLineEdit(value, self)
+ elif tuple_to_qcolor(value).isValid():
+ col = QColor()
+ col.setRgbF(*value)
+ field = ColorLayout(col, self)
elif isinstance(value, (list, tuple)):
selindex = value.pop(0)
field = QComboBox(self)
@@ -300,6 +317,8 @@ class FormWidget(QWidget):
continue
elif tuple_to_qfont(value) is not None:
value = field.get_font()
+ elif tuple_to_qcolor(value).isValid():
+ value = str(field.text())
elif isinstance(value, (str, unicode)):
value = unicode(field.text())
elif isinstance(value, (list, tuple)):
--
1.7.2.3
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel