From 2ab38e44c2627d8d2f5d7a0e6d6f8791b34559f4 Mon Sep 17 00:00:00 2001 From: rhoef Date: Sun, 5 May 2013 19:00:30 +0200 Subject: [PATCH 1/7] subplottool customized --- lib/matplotlib/backends/backend_qt4.py | 191 ++++----- .../backends/qt4_editor/formsubplottool.py | 197 +++++++++ .../backends/qt4_editor/subplot_conftool.ui | 390 ++++++++++++++++++ 3 files changed, 673 insertions(+), 105 deletions(-) create mode 100644 lib/matplotlib/backends/qt4_editor/formsubplottool.py create mode 100644 lib/matplotlib/backends/qt4_editor/subplot_conftool.ui diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index 65a06e0da12c..345a1c6f7667 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -39,6 +39,7 @@ figureoptions = None from .qt4_compat import QtCore, QtGui, _getSaveFileName, __version__ +from matplotlib.backends.qt4_editor.formsubplottool import Ui_SubplotTool backend_version = __version__ @@ -558,6 +559,7 @@ class NavigationToolbar2QT(NavigationToolbar2, QtGui.QToolBar): def __init__(self, canvas, parent, coordinates=True): """ coordinates: should we show the coordinates on the right? """ self.canvas = canvas + self.parent = parent self.coordinates = coordinates self._actions = {} """A mapping of toolitem method names to their QActions""" @@ -613,29 +615,18 @@ def edit_parameters(self): axes = allaxes[0] else: titles = [] - for axes in allaxes: - title = axes.get_title() + for i, axes in enumerate(allaxes): ylabel = axes.get_ylabel() - if title: - fmt = "%(title)s" - if ylabel: - fmt += ": %(ylabel)s" - fmt += " (%(axes_repr)s)" - elif ylabel: - fmt = "%(axes_repr)s (%(ylabel)s)" - else: - fmt = "%(axes_repr)s" - titles.append(fmt % dict(title=title, - ylabel=ylabel, - axes_repr=repr(axes))) - item, ok = QtGui.QInputDialog.getItem(self, 'Customize', - 'Select axes:', titles, - 0, False) + text = "_axes%d" % i + if ylabel: + text += " %s" % ylabel + titles.append(text) + item, ok = QtGui.QInputDialog.getItem( + self.parent, 'Customize', 'Select axes:', titles, 0, False) if ok: axes = allaxes[titles.index(six.text_type(item))] else: return - figureoptions.figure_edit(axes, self) def _update_buttons_checked(self): @@ -676,20 +667,11 @@ def draw_rubberband(self, event, x0, y0, x1, y1): self.canvas.drawRectangle(rect) def configure_subplots(self): - self.adj_window = QtGui.QMainWindow() - win = self.adj_window - - win.setWindowTitle("Subplot Configuration Tool") image = os.path.join(matplotlib.rcParams['datapath'], - 'images', 'matplotlib.png') - win.setWindowIcon(QtGui.QIcon(image)) - - tool = SubplotToolQt(self.canvas.figure, win) - win.setCentralWidget(tool) - win.setSizePolicy(QtGui.QSizePolicy.Preferred, - QtGui.QSizePolicy.Preferred) - - win.show() + 'images','matplotlib.png') + dia = SubplotToolQt(self.canvas.figure, self.parent) + dia.setWindowIcon(QtGui.QIcon(image)) + dia.exec_() def _get_canvas(self, fig): return FigureCanvasQT(fig) @@ -712,8 +694,9 @@ def save_figure(self, *args): selectedFilter = filter filters.append(filter) filters = ';;'.join(filters) - fname = _getSaveFileName(self, "Choose a filename to save to", - start, filters, selectedFilter) + + fname = _getSaveFileName(self.parent, "Choose a filename to save to", + start, filters, selectedFilter) if fname: if startpath == '': # explicitly missing key or empty str signals to use cwd @@ -730,93 +713,82 @@ def save_figure(self, *args): QtGui.QMessageBox.Ok, QtGui.QMessageBox.NoButton) -class SubplotToolQt(SubplotTool, QtGui.QWidget): +class SubplotToolQt(SubplotTool, QtGui.QDialog, Ui_SubplotTool): def __init__(self, targetfig, parent): - QtGui.QWidget.__init__(self, None) - + QtGui.QDialog.__init__(self, None) + self.setupUi(self) self.targetfig = targetfig self.parent = parent - - self.sliderleft = QtGui.QSlider(QtCore.Qt.Horizontal) - self.sliderbottom = QtGui.QSlider(QtCore.Qt.Vertical) - self.sliderright = QtGui.QSlider(QtCore.Qt.Horizontal) - self.slidertop = QtGui.QSlider(QtCore.Qt.Vertical) - self.sliderwspace = QtGui.QSlider(QtCore.Qt.Horizontal) - self.sliderhspace = QtGui.QSlider(QtCore.Qt.Vertical) - - # constraints - self.sliderleft.valueChanged.connect(self.sliderright.setMinimum) - self.sliderright.valueChanged.connect(self.sliderleft.setMaximum) - self.sliderbottom.valueChanged.connect(self.slidertop.setMinimum) - self.slidertop.valueChanged.connect(self.sliderbottom.setMaximum) + self.connect(self.doneButton, QtCore.SIGNAL("clicked()"), self.close) + self.connect(self.resetButton, QtCore.SIGNAL("clicked()"), self.reset) + self.connect(self.tightLayout, QtCore.SIGNAL("clicked()"), self.functight) sliders = (self.sliderleft, self.sliderbottom, self.sliderright, self.slidertop, self.sliderwspace, self.sliderhspace,) - adjustments = ('left:', 'bottom:', 'right:', - 'top:', 'wspace:', 'hspace:') - for slider, adjustment in zip(sliders, adjustments): + for slider in sliders: slider.setMinimum(0) slider.setMaximum(1000) slider.setSingleStep(5) - layout = QtGui.QGridLayout() - - leftlabel = QtGui.QLabel('left') - layout.addWidget(leftlabel, 2, 0) - layout.addWidget(self.sliderleft, 2, 1) - - toplabel = QtGui.QLabel('top') - layout.addWidget(toplabel, 0, 2) - layout.addWidget(self.slidertop, 1, 2) - layout.setAlignment(self.slidertop, QtCore.Qt.AlignHCenter) - - bottomlabel = QtGui.QLabel('bottom') # this might not ever be used - layout.addWidget(bottomlabel, 4, 2) - layout.addWidget(self.sliderbottom, 3, 2) - layout.setAlignment(self.sliderbottom, QtCore.Qt.AlignHCenter) - - rightlabel = QtGui.QLabel('right') - layout.addWidget(rightlabel, 2, 4) - layout.addWidget(self.sliderright, 2, 3) - - hspacelabel = QtGui.QLabel('hspace') - layout.addWidget(hspacelabel, 0, 6) - layout.setAlignment(hspacelabel, QtCore.Qt.AlignHCenter) - layout.addWidget(self.sliderhspace, 1, 6) - layout.setAlignment(self.sliderhspace, QtCore.Qt.AlignHCenter) - - wspacelabel = QtGui.QLabel('wspace') - layout.addWidget(wspacelabel, 4, 6) - layout.setAlignment(wspacelabel, QtCore.Qt.AlignHCenter) - layout.addWidget(self.sliderwspace, 3, 6) - layout.setAlignment(self.sliderwspace, QtCore.Qt.AlignBottom) - - layout.setRowStretch(1, 1) - layout.setRowStretch(3, 1) - layout.setColumnStretch(1, 1) - layout.setColumnStretch(3, 1) - layout.setColumnStretch(6, 1) - - self.setLayout(layout) - - self.sliderleft.setSliderPosition(int(targetfig.subplotpars.left*1000)) + # constraints + self.connect(self.sliderleft, + QtCore.SIGNAL("valueChanged(int)"), + self.sliderright.setMinimum) + self.connect(self.sliderright, + QtCore.SIGNAL("valueChanged(int)"), + self.sliderleft.setMaximum) + self.connect(self.sliderbottom, + QtCore.SIGNAL("valueChanged(int)"), + self.slidertop.setMinimum) + self.connect(self.slidertop, + QtCore.SIGNAL("valueChanged(int)"), + self.sliderbottom.setMaximum) + + self._read_defaults() + self._setSliderPositions() + + self.connect(self.sliderleft, + QtCore.SIGNAL("valueChanged(int)"), + self.funcleft) + self.connect(self.sliderbottom, + QtCore.SIGNAL("valueChanged(int)"), + self.funcbottom) + self.connect(self.sliderright, + QtCore.SIGNAL("valueChanged(int)"), + self.funcright) + self.connect(self.slidertop, + QtCore.SIGNAL("valueChanged(int)"), + self.functop) + self.connect(self.sliderwspace, + QtCore.SIGNAL("valueChanged(int)"), + self.funcwspace) + self.connect(self.sliderhspace, + QtCore.SIGNAL("valueChanged(int)"), + self.funchspace) + + def _read_defaults(self): + self.defaults = {'left': self.targetfig.subplotpars.left, + 'bottom': self.targetfig.subplotpars.bottom, + 'right': self.targetfig.subplotpars.right, + 'top':self.targetfig.subplotpars.top, + 'wspace': self.targetfig.subplotpars.wspace, + 'hspace': self.targetfig.subplotpars.hspace + } + + def _setSliderPositions(self): + self.sliderleft.setSliderPosition( + int(self.targetfig.subplotpars.left*1000)) self.sliderbottom.setSliderPosition( - int(targetfig.subplotpars.bottom*1000)) + int(self.targetfig.subplotpars.bottom*1000)) self.sliderright.setSliderPosition( - int(targetfig.subplotpars.right*1000)) - self.slidertop.setSliderPosition(int(targetfig.subplotpars.top*1000)) + int(self.targetfig.subplotpars.right*1000)) + self.slidertop.setSliderPosition(int( + self.targetfig.subplotpars.top*1000)) self.sliderwspace.setSliderPosition( - int(targetfig.subplotpars.wspace*1000)) + int(self.targetfig.subplotpars.wspace*1000)) self.sliderhspace.setSliderPosition( - int(targetfig.subplotpars.hspace*1000)) - - self.sliderleft.valueChanged.connect(self.funcleft) - self.sliderbottom.valueChanged.connect(self.funcbottom) - self.sliderright.valueChanged.connect(self.funcright) - self.slidertop.valueChanged.connect(self.functop) - self.sliderwspace.valueChanged.connect(self.funcwspace) - self.sliderhspace.valueChanged.connect(self.funchspace) + int(self.targetfig.subplotpars.hspace*1000)) def funcleft(self, val): if val == self.sliderright.value(): @@ -856,6 +828,15 @@ def funchspace(self, val): if self.drawon: self.targetfig.canvas.draw() + def functight(self): + self.targetfig.tight_layout() + self.targetfig.canvas.draw() + + def reset(self): + self.targetfig.subplots_adjust(**self.defaults) + self._setSliderPositions() + self.targetfig.canvas.draw() + def error_msg_qt(msg, parent=None): if not is_string_like(msg): diff --git a/lib/matplotlib/backends/qt4_editor/formsubplottool.py b/lib/matplotlib/backends/qt4_editor/formsubplottool.py new file mode 100644 index 000000000000..36652a434116 --- /dev/null +++ b/lib/matplotlib/backends/qt4_editor/formsubplottool.py @@ -0,0 +1,197 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'subplot_conftool.ui' +# +# Created: Sun May 5 09:49:09 2013 +# by: PyQt4 UI code generator 4.9.3 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + _fromUtf8 = lambda s: s + +class Ui_SubplotTool(object): + def setupUi(self, SubplotTool): + SubplotTool.setObjectName(_fromUtf8("SubplotTool")) + SubplotTool.resize(447, 241) + self.horizontalLayout = QtGui.QHBoxLayout(SubplotTool) + self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) + self.gridLayout = QtGui.QGridLayout() + self.gridLayout.setObjectName(_fromUtf8("gridLayout")) + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setSpacing(0) + self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) + self.tightLayout = QtGui.QPushButton(SubplotTool) + self.tightLayout.setObjectName(_fromUtf8("tightLayout")) + self.horizontalLayout_2.addWidget(self.tightLayout) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem) + self.resetButton = QtGui.QPushButton(SubplotTool) + self.resetButton.setObjectName(_fromUtf8("resetButton")) + self.horizontalLayout_2.addWidget(self.resetButton) + spacerItem1 = QtGui.QSpacerItem(5, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem1) + self.doneButton = QtGui.QPushButton(SubplotTool) + self.doneButton.setEnabled(True) + self.doneButton.setFlat(False) + self.doneButton.setObjectName(_fromUtf8("doneButton")) + self.horizontalLayout_2.addWidget(self.doneButton) + self.gridLayout.addLayout(self.horizontalLayout_2, 8, 0, 1, 1) + self.groupBox = QtGui.QGroupBox(SubplotTool) + self.groupBox.setObjectName(_fromUtf8("groupBox")) + self.verticalLayout = QtGui.QVBoxLayout(self.groupBox) + self.verticalLayout.setSpacing(0) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.hboxtop = QtGui.QHBoxLayout() + self.hboxtop.setObjectName(_fromUtf8("hboxtop")) + self.labeltop = QtGui.QLabel(self.groupBox) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labeltop.sizePolicy().hasHeightForWidth()) + self.labeltop.setSizePolicy(sizePolicy) + self.labeltop.setMinimumSize(QtCore.QSize(50, 0)) + self.labeltop.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labeltop.setObjectName(_fromUtf8("labeltop")) + self.hboxtop.addWidget(self.labeltop) + self.slidertop = QtGui.QSlider(self.groupBox) + self.slidertop.setOrientation(QtCore.Qt.Horizontal) + self.slidertop.setInvertedAppearance(False) + self.slidertop.setInvertedControls(False) + self.slidertop.setTickPosition(QtGui.QSlider.TicksAbove) + self.slidertop.setTickInterval(10) + self.slidertop.setObjectName(_fromUtf8("slidertop")) + self.hboxtop.addWidget(self.slidertop) + self.verticalLayout.addLayout(self.hboxtop) + self.hboxbottom = QtGui.QHBoxLayout() + self.hboxbottom.setObjectName(_fromUtf8("hboxbottom")) + self.labelbottom = QtGui.QLabel(self.groupBox) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labelbottom.sizePolicy().hasHeightForWidth()) + self.labelbottom.setSizePolicy(sizePolicy) + self.labelbottom.setMinimumSize(QtCore.QSize(50, 0)) + self.labelbottom.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelbottom.setObjectName(_fromUtf8("labelbottom")) + self.hboxbottom.addWidget(self.labelbottom) + self.sliderbottom = QtGui.QSlider(self.groupBox) + self.sliderbottom.setOrientation(QtCore.Qt.Horizontal) + self.sliderbottom.setInvertedAppearance(False) + self.sliderbottom.setTickPosition(QtGui.QSlider.TicksAbove) + self.sliderbottom.setTickInterval(10) + self.sliderbottom.setObjectName(_fromUtf8("sliderbottom")) + self.hboxbottom.addWidget(self.sliderbottom) + self.verticalLayout.addLayout(self.hboxbottom) + self.hboxleft = QtGui.QHBoxLayout() + self.hboxleft.setObjectName(_fromUtf8("hboxleft")) + self.labelleft = QtGui.QLabel(self.groupBox) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labelleft.sizePolicy().hasHeightForWidth()) + self.labelleft.setSizePolicy(sizePolicy) + self.labelleft.setMinimumSize(QtCore.QSize(50, 0)) + self.labelleft.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelleft.setObjectName(_fromUtf8("labelleft")) + self.hboxleft.addWidget(self.labelleft) + self.sliderleft = QtGui.QSlider(self.groupBox) + self.sliderleft.setOrientation(QtCore.Qt.Horizontal) + self.sliderleft.setInvertedAppearance(False) + self.sliderleft.setTickPosition(QtGui.QSlider.TicksAbove) + self.sliderleft.setTickInterval(10) + self.sliderleft.setObjectName(_fromUtf8("sliderleft")) + self.hboxleft.addWidget(self.sliderleft) + self.verticalLayout.addLayout(self.hboxleft) + self.hboxright = QtGui.QHBoxLayout() + self.hboxright.setObjectName(_fromUtf8("hboxright")) + self.labelright = QtGui.QLabel(self.groupBox) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labelright.sizePolicy().hasHeightForWidth()) + self.labelright.setSizePolicy(sizePolicy) + self.labelright.setMinimumSize(QtCore.QSize(50, 0)) + self.labelright.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelright.setObjectName(_fromUtf8("labelright")) + self.hboxright.addWidget(self.labelright) + self.sliderright = QtGui.QSlider(self.groupBox) + self.sliderright.setOrientation(QtCore.Qt.Horizontal) + self.sliderright.setInvertedAppearance(False) + self.sliderright.setTickPosition(QtGui.QSlider.TicksAbove) + self.sliderright.setTickInterval(10) + self.sliderright.setObjectName(_fromUtf8("sliderright")) + self.hboxright.addWidget(self.sliderright) + self.verticalLayout.addLayout(self.hboxright) + self.gridLayout.addWidget(self.groupBox, 5, 0, 1, 1) + self.groupBox_2 = QtGui.QGroupBox(SubplotTool) + self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) + self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox_2) + self.verticalLayout_2.setSpacing(0) + self.verticalLayout_2.setMargin(0) + self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) + self.hboxhspace = QtGui.QHBoxLayout() + self.hboxhspace.setObjectName(_fromUtf8("hboxhspace")) + self.labelhspace = QtGui.QLabel(self.groupBox_2) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labelhspace.sizePolicy().hasHeightForWidth()) + self.labelhspace.setSizePolicy(sizePolicy) + self.labelhspace.setMinimumSize(QtCore.QSize(50, 0)) + self.labelhspace.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelhspace.setObjectName(_fromUtf8("labelhspace")) + self.hboxhspace.addWidget(self.labelhspace) + self.sliderhspace = QtGui.QSlider(self.groupBox_2) + self.sliderhspace.setOrientation(QtCore.Qt.Horizontal) + self.sliderhspace.setInvertedAppearance(False) + self.sliderhspace.setTickPosition(QtGui.QSlider.TicksAbove) + self.sliderhspace.setTickInterval(10) + self.sliderhspace.setObjectName(_fromUtf8("sliderhspace")) + self.hboxhspace.addWidget(self.sliderhspace) + self.verticalLayout_2.addLayout(self.hboxhspace) + self.hboxwspace = QtGui.QHBoxLayout() + self.hboxwspace.setObjectName(_fromUtf8("hboxwspace")) + self.labelwspace = QtGui.QLabel(self.groupBox_2) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.labelwspace.sizePolicy().hasHeightForWidth()) + self.labelwspace.setSizePolicy(sizePolicy) + self.labelwspace.setMinimumSize(QtCore.QSize(50, 0)) + self.labelwspace.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.labelwspace.setObjectName(_fromUtf8("labelwspace")) + self.hboxwspace.addWidget(self.labelwspace) + self.sliderwspace = QtGui.QSlider(self.groupBox_2) + self.sliderwspace.setOrientation(QtCore.Qt.Horizontal) + self.sliderwspace.setInvertedAppearance(False) + self.sliderwspace.setTickPosition(QtGui.QSlider.TicksAbove) + self.sliderwspace.setTickInterval(10) + self.sliderwspace.setObjectName(_fromUtf8("sliderwspace")) + self.hboxwspace.addWidget(self.sliderwspace) + self.verticalLayout_2.addLayout(self.hboxwspace) + self.gridLayout.addWidget(self.groupBox_2, 6, 0, 1, 1) + self.horizontalLayout.addLayout(self.gridLayout) + + self.retranslateUi(SubplotTool) + QtCore.QObject.connect(self.doneButton, QtCore.SIGNAL(_fromUtf8("clicked()")), SubplotTool.accept) + QtCore.QMetaObject.connectSlotsByName(SubplotTool) + + def retranslateUi(self, SubplotTool): + SubplotTool.setWindowTitle(QtGui.QApplication.translate("SubplotTool", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) + self.tightLayout.setText(QtGui.QApplication.translate("SubplotTool", "tight layout", None, QtGui.QApplication.UnicodeUTF8)) + self.resetButton.setText(QtGui.QApplication.translate("SubplotTool", "reset", None, QtGui.QApplication.UnicodeUTF8)) + self.doneButton.setText(QtGui.QApplication.translate("SubplotTool", "close", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("SubplotTool", "Borders", None, QtGui.QApplication.UnicodeUTF8)) + self.labeltop.setText(QtGui.QApplication.translate("SubplotTool", "top", None, QtGui.QApplication.UnicodeUTF8)) + self.labelbottom.setText(QtGui.QApplication.translate("SubplotTool", "bottom", None, QtGui.QApplication.UnicodeUTF8)) + self.labelleft.setText(QtGui.QApplication.translate("SubplotTool", "left", None, QtGui.QApplication.UnicodeUTF8)) + self.labelright.setText(QtGui.QApplication.translate("SubplotTool", "right", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox_2.setTitle(QtGui.QApplication.translate("SubplotTool", "Spaces", None, QtGui.QApplication.UnicodeUTF8)) + self.labelhspace.setText(QtGui.QApplication.translate("SubplotTool", "hspace", None, QtGui.QApplication.UnicodeUTF8)) + self.labelwspace.setText(QtGui.QApplication.translate("SubplotTool", "wspace", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui b/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui new file mode 100644 index 000000000000..25c1e6c19ca3 --- /dev/null +++ b/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui @@ -0,0 +1,390 @@ + + + SubplotTool + + + + 0 + 0 + 447 + 241 + + + + Dialog + + + + + + + + 0 + + + + + tight layout + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + reset + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 5 + 20 + + + + + + + + true + + + close + + + false + + + + + + + + + Borders + + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + top + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + false + + + false + + + QSlider::TicksAbove + + + 10 + + + + + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + bottom + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + false + + + QSlider::TicksAbove + + + 10 + + + + + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + left + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + false + + + QSlider::TicksAbove + + + 10 + + + + + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + right + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + false + + + QSlider::TicksAbove + + + 10 + + + + + + + + + + + + Spaces + + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + hspace + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + false + + + QSlider::TicksAbove + + + 10 + + + + + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + wspace + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + false + + + QSlider::TicksAbove + + + 10 + + + + + + + + + + + + + + + + doneButton + clicked() + SubplotTool + accept() + + + 274 + 246 + + + 163 + 135 + + + + + From 98d56f0b228cbcd0d072cfb5fe5793bacbaca608 Mon Sep 17 00:00:00 2001 From: rhoef Date: Sun, 5 May 2013 20:35:41 +0200 Subject: [PATCH 2/7] hexcolors in figureoptions and function col2hex fixed --- .../backends/qt4_editor/figureoptions.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/matplotlib/backends/qt4_editor/figureoptions.py b/lib/matplotlib/backends/qt4_editor/figureoptions.py index f9dc2f838cbc..a8732bd93217 100644 --- a/lib/matplotlib/backends/qt4_editor/figureoptions.py +++ b/lib/matplotlib/backends/qt4_editor/figureoptions.py @@ -17,6 +17,7 @@ import matplotlib.backends.qt4_editor.formlayout as formlayout from matplotlib.backends.qt4_compat import QtGui from matplotlib import markers +from matplotlib.colors import rgb2hex def get_icon(name): import matplotlib @@ -34,6 +35,21 @@ def get_icon(name): MARKERS = markers.MarkerStyle.markers +COLORS = {'c': '#00bfbf', 'b': '#0000ff', 'w': '#ffffff', 'g': '#008000', + 'y': '#bfbf00', 'k': '#000000', 'r': '#ff0000', 'm': '#bf00bf'} + +def col2hex(color): + # default colors and hex colors + if isinstance(color, basestring): + try: + chex = COLORS[color] + except KeyError: + chex = color + else: # rgb tuples + chex = rgb2hex(color) + return chex + + def figure_edit(axes, parent=None): """Edit matplotlib figure options""" sep = (None, None) # separator From 30f3d31389a85ac96ccbb6c17475bf09ea8366e8 Mon Sep 17 00:00:00 2001 From: rhoef Date: Sun, 5 May 2013 20:37:08 +0200 Subject: [PATCH 3/7] tick delta in sliders changed --- .../backends/qt4_editor/formsubplottool.py | 17 +++++++++-------- .../backends/qt4_editor/subplot_conftool.ui | 17 ++++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/backends/qt4_editor/formsubplottool.py b/lib/matplotlib/backends/qt4_editor/formsubplottool.py index 36652a434116..23ef279de648 100644 --- a/lib/matplotlib/backends/qt4_editor/formsubplottool.py +++ b/lib/matplotlib/backends/qt4_editor/formsubplottool.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'subplot_conftool.ui' # -# Created: Sun May 5 09:49:09 2013 +# Created: Sun May 5 20:30:44 2013 # by: PyQt4 UI code generator 4.9.3 # # WARNING! All changes made in this file will be lost! @@ -17,7 +17,7 @@ class Ui_SubplotTool(object): def setupUi(self, SubplotTool): SubplotTool.setObjectName(_fromUtf8("SubplotTool")) - SubplotTool.resize(447, 241) + SubplotTool.resize(447, 265) self.horizontalLayout = QtGui.QHBoxLayout(SubplotTool) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.gridLayout = QtGui.QGridLayout() @@ -64,7 +64,7 @@ def setupUi(self, SubplotTool): self.slidertop.setInvertedAppearance(False) self.slidertop.setInvertedControls(False) self.slidertop.setTickPosition(QtGui.QSlider.TicksAbove) - self.slidertop.setTickInterval(10) + self.slidertop.setTickInterval(100) self.slidertop.setObjectName(_fromUtf8("slidertop")) self.hboxtop.addWidget(self.slidertop) self.verticalLayout.addLayout(self.hboxtop) @@ -84,7 +84,7 @@ def setupUi(self, SubplotTool): self.sliderbottom.setOrientation(QtCore.Qt.Horizontal) self.sliderbottom.setInvertedAppearance(False) self.sliderbottom.setTickPosition(QtGui.QSlider.TicksAbove) - self.sliderbottom.setTickInterval(10) + self.sliderbottom.setTickInterval(100) self.sliderbottom.setObjectName(_fromUtf8("sliderbottom")) self.hboxbottom.addWidget(self.sliderbottom) self.verticalLayout.addLayout(self.hboxbottom) @@ -104,7 +104,7 @@ def setupUi(self, SubplotTool): self.sliderleft.setOrientation(QtCore.Qt.Horizontal) self.sliderleft.setInvertedAppearance(False) self.sliderleft.setTickPosition(QtGui.QSlider.TicksAbove) - self.sliderleft.setTickInterval(10) + self.sliderleft.setTickInterval(100) self.sliderleft.setObjectName(_fromUtf8("sliderleft")) self.hboxleft.addWidget(self.sliderleft) self.verticalLayout.addLayout(self.hboxleft) @@ -124,7 +124,7 @@ def setupUi(self, SubplotTool): self.sliderright.setOrientation(QtCore.Qt.Horizontal) self.sliderright.setInvertedAppearance(False) self.sliderright.setTickPosition(QtGui.QSlider.TicksAbove) - self.sliderright.setTickInterval(10) + self.sliderright.setTickInterval(100) self.sliderright.setObjectName(_fromUtf8("sliderright")) self.hboxright.addWidget(self.sliderright) self.verticalLayout.addLayout(self.hboxright) @@ -151,7 +151,7 @@ def setupUi(self, SubplotTool): self.sliderhspace.setOrientation(QtCore.Qt.Horizontal) self.sliderhspace.setInvertedAppearance(False) self.sliderhspace.setTickPosition(QtGui.QSlider.TicksAbove) - self.sliderhspace.setTickInterval(10) + self.sliderhspace.setTickInterval(100) self.sliderhspace.setObjectName(_fromUtf8("sliderhspace")) self.hboxhspace.addWidget(self.sliderhspace) self.verticalLayout_2.addLayout(self.hboxhspace) @@ -168,10 +168,11 @@ def setupUi(self, SubplotTool): self.labelwspace.setObjectName(_fromUtf8("labelwspace")) self.hboxwspace.addWidget(self.labelwspace) self.sliderwspace = QtGui.QSlider(self.groupBox_2) + self.sliderwspace.setTracking(True) self.sliderwspace.setOrientation(QtCore.Qt.Horizontal) self.sliderwspace.setInvertedAppearance(False) self.sliderwspace.setTickPosition(QtGui.QSlider.TicksAbove) - self.sliderwspace.setTickInterval(10) + self.sliderwspace.setTickInterval(100) self.sliderwspace.setObjectName(_fromUtf8("sliderwspace")) self.hboxwspace.addWidget(self.sliderwspace) self.verticalLayout_2.addLayout(self.hboxwspace) diff --git a/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui b/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui index 25c1e6c19ca3..08bc198ea3a8 100644 --- a/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui +++ b/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui @@ -7,7 +7,7 @@ 0 0 447 - 241 + 265 @@ -130,7 +130,7 @@ QSlider::TicksAbove - 10 + 100 @@ -172,7 +172,7 @@ QSlider::TicksAbove - 10 + 100 @@ -214,7 +214,7 @@ QSlider::TicksAbove - 10 + 100 @@ -256,7 +256,7 @@ QSlider::TicksAbove - 10 + 100 @@ -313,7 +313,7 @@ QSlider::TicksAbove - 10 + 100 @@ -345,6 +345,9 @@ + + true + Qt::Horizontal @@ -355,7 +358,7 @@ QSlider::TicksAbove - 10 + 100 From 2364f4794c793dd6d33530310e10c2874b8c43a4 Mon Sep 17 00:00:00 2001 From: rhoef Date: Mon, 3 Jun 2013 01:53:28 +0200 Subject: [PATCH 4/7] value labels in subplottool added --- lib/matplotlib/backends/backend_qt4.py | 29 +++-- .../backends/qt4_editor/formsubplottool.py | 79 +++++++++++--- .../backends/qt4_editor/subplot_conftool.ui | 102 ++++++++++++++++++ 3 files changed, 186 insertions(+), 24 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index 345a1c6f7667..f852331fa5c7 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -783,8 +783,8 @@ def _setSliderPositions(self): int(self.targetfig.subplotpars.bottom*1000)) self.sliderright.setSliderPosition( int(self.targetfig.subplotpars.right*1000)) - self.slidertop.setSliderPosition(int( - self.targetfig.subplotpars.top*1000)) + self.slidertop.setSliderPosition( + int(self.targetfig.subplotpars.top*1000)) self.sliderwspace.setSliderPosition( int(self.targetfig.subplotpars.wspace*1000)) self.sliderhspace.setSliderPosition( @@ -793,43 +793,56 @@ def _setSliderPositions(self): def funcleft(self, val): if val == self.sliderright.value(): val -= 1 - self.targetfig.subplots_adjust(left=val/1000.) + val /= 1000 + self.targetfig.subplots_adjust(left=val) + self.leftvalue.setText("%.2f" %val) if self.drawon: self.targetfig.canvas.draw() def funcright(self, val): if val == self.sliderleft.value(): val += 1 - self.targetfig.subplots_adjust(right=val/1000.) + val /= 1000. + self.targetfig.subplots_adjust(right=val) + self.rightvalue.setText("%.2f" %val) if self.drawon: self.targetfig.canvas.draw() def funcbottom(self, val): if val == self.slidertop.value(): val -= 1 - self.targetfig.subplots_adjust(bottom=val/1000.) + val /= 1000. + self.targetfig.subplots_adjust(bottom=val) + self.bottomvalue.setText("%.2f" %val) if self.drawon: self.targetfig.canvas.draw() def functop(self, val): if val == self.sliderbottom.value(): val += 1 - self.targetfig.subplots_adjust(top=val/1000.) + val /= 1000.0 + self.targetfig.subplots_adjust(top=val) + self.topvalue.setText("%.2f" %val) if self.drawon: self.targetfig.canvas.draw() def funcwspace(self, val): - self.targetfig.subplots_adjust(wspace=val/1000.) + val /= 1000. + self.targetfig.subplots_adjust(wspace=val) + self.wspacevalue.setText("%.2f" %val) if self.drawon: self.targetfig.canvas.draw() def funchspace(self, val): - self.targetfig.subplots_adjust(hspace=val/1000.) + val /= 1000. + self.targetfig.subplots_adjust(hspace=val) + self.hspacevalue.setText("%.2f" %val) if self.drawon: self.targetfig.canvas.draw() def functight(self): self.targetfig.tight_layout() + self._setSliderPositions() self.targetfig.canvas.draw() def reset(self): diff --git a/lib/matplotlib/backends/qt4_editor/formsubplottool.py b/lib/matplotlib/backends/qt4_editor/formsubplottool.py index 23ef279de648..37ce31f34d36 100644 --- a/lib/matplotlib/backends/qt4_editor/formsubplottool.py +++ b/lib/matplotlib/backends/qt4_editor/formsubplottool.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'subplot_conftool.ui' +# Form implementation generated from reading ui file 'lib/matplotlib/backends/qt4_editor/subplot_conftool.ui' # -# Created: Sun May 5 20:30:44 2013 -# by: PyQt4 UI code generator 4.9.3 +# Created: Mon Jun 3 01:47:41 2013 +# by: PyQt4 UI code generator 4.10.1 # # WARNING! All changes made in this file will be lost! @@ -12,7 +12,16 @@ try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: - _fromUtf8 = lambda s: s + def _fromUtf8(s): + return s + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig, _encoding) +except AttributeError: + def _translate(context, text, disambig): + return QtGui.QApplication.translate(context, text, disambig) class Ui_SubplotTool(object): def setupUi(self, SubplotTool): @@ -60,6 +69,8 @@ def setupUi(self, SubplotTool): self.labeltop.setObjectName(_fromUtf8("labeltop")) self.hboxtop.addWidget(self.labeltop) self.slidertop = QtGui.QSlider(self.groupBox) + self.slidertop.setMouseTracking(False) + self.slidertop.setProperty("value", 0) self.slidertop.setOrientation(QtCore.Qt.Horizontal) self.slidertop.setInvertedAppearance(False) self.slidertop.setInvertedControls(False) @@ -67,6 +78,11 @@ def setupUi(self, SubplotTool): self.slidertop.setTickInterval(100) self.slidertop.setObjectName(_fromUtf8("slidertop")) self.hboxtop.addWidget(self.slidertop) + self.topvalue = QtGui.QLabel(self.groupBox) + self.topvalue.setMinimumSize(QtCore.QSize(30, 0)) + self.topvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.topvalue.setObjectName(_fromUtf8("topvalue")) + self.hboxtop.addWidget(self.topvalue) self.verticalLayout.addLayout(self.hboxtop) self.hboxbottom = QtGui.QHBoxLayout() self.hboxbottom.setObjectName(_fromUtf8("hboxbottom")) @@ -87,6 +103,11 @@ def setupUi(self, SubplotTool): self.sliderbottom.setTickInterval(100) self.sliderbottom.setObjectName(_fromUtf8("sliderbottom")) self.hboxbottom.addWidget(self.sliderbottom) + self.bottomvalue = QtGui.QLabel(self.groupBox) + self.bottomvalue.setMinimumSize(QtCore.QSize(30, 0)) + self.bottomvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.bottomvalue.setObjectName(_fromUtf8("bottomvalue")) + self.hboxbottom.addWidget(self.bottomvalue) self.verticalLayout.addLayout(self.hboxbottom) self.hboxleft = QtGui.QHBoxLayout() self.hboxleft.setObjectName(_fromUtf8("hboxleft")) @@ -107,6 +128,11 @@ def setupUi(self, SubplotTool): self.sliderleft.setTickInterval(100) self.sliderleft.setObjectName(_fromUtf8("sliderleft")) self.hboxleft.addWidget(self.sliderleft) + self.leftvalue = QtGui.QLabel(self.groupBox) + self.leftvalue.setMinimumSize(QtCore.QSize(30, 0)) + self.leftvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.leftvalue.setObjectName(_fromUtf8("leftvalue")) + self.hboxleft.addWidget(self.leftvalue) self.verticalLayout.addLayout(self.hboxleft) self.hboxright = QtGui.QHBoxLayout() self.hboxright.setObjectName(_fromUtf8("hboxright")) @@ -127,6 +153,11 @@ def setupUi(self, SubplotTool): self.sliderright.setTickInterval(100) self.sliderright.setObjectName(_fromUtf8("sliderright")) self.hboxright.addWidget(self.sliderright) + self.rightvalue = QtGui.QLabel(self.groupBox) + self.rightvalue.setMinimumSize(QtCore.QSize(30, 0)) + self.rightvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.rightvalue.setObjectName(_fromUtf8("rightvalue")) + self.hboxright.addWidget(self.rightvalue) self.verticalLayout.addLayout(self.hboxright) self.gridLayout.addWidget(self.groupBox, 5, 0, 1, 1) self.groupBox_2 = QtGui.QGroupBox(SubplotTool) @@ -154,6 +185,11 @@ def setupUi(self, SubplotTool): self.sliderhspace.setTickInterval(100) self.sliderhspace.setObjectName(_fromUtf8("sliderhspace")) self.hboxhspace.addWidget(self.sliderhspace) + self.hspacevalue = QtGui.QLabel(self.groupBox_2) + self.hspacevalue.setMinimumSize(QtCore.QSize(30, 0)) + self.hspacevalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.hspacevalue.setObjectName(_fromUtf8("hspacevalue")) + self.hboxhspace.addWidget(self.hspacevalue) self.verticalLayout_2.addLayout(self.hboxhspace) self.hboxwspace = QtGui.QHBoxLayout() self.hboxwspace.setObjectName(_fromUtf8("hboxwspace")) @@ -175,6 +211,11 @@ def setupUi(self, SubplotTool): self.sliderwspace.setTickInterval(100) self.sliderwspace.setObjectName(_fromUtf8("sliderwspace")) self.hboxwspace.addWidget(self.sliderwspace) + self.wspacevalue = QtGui.QLabel(self.groupBox_2) + self.wspacevalue.setMinimumSize(QtCore.QSize(30, 0)) + self.wspacevalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.wspacevalue.setObjectName(_fromUtf8("wspacevalue")) + self.hboxwspace.addWidget(self.wspacevalue) self.verticalLayout_2.addLayout(self.hboxwspace) self.gridLayout.addWidget(self.groupBox_2, 6, 0, 1, 1) self.horizontalLayout.addLayout(self.gridLayout) @@ -184,15 +225,21 @@ def setupUi(self, SubplotTool): QtCore.QMetaObject.connectSlotsByName(SubplotTool) def retranslateUi(self, SubplotTool): - SubplotTool.setWindowTitle(QtGui.QApplication.translate("SubplotTool", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) - self.tightLayout.setText(QtGui.QApplication.translate("SubplotTool", "tight layout", None, QtGui.QApplication.UnicodeUTF8)) - self.resetButton.setText(QtGui.QApplication.translate("SubplotTool", "reset", None, QtGui.QApplication.UnicodeUTF8)) - self.doneButton.setText(QtGui.QApplication.translate("SubplotTool", "close", None, QtGui.QApplication.UnicodeUTF8)) - self.groupBox.setTitle(QtGui.QApplication.translate("SubplotTool", "Borders", None, QtGui.QApplication.UnicodeUTF8)) - self.labeltop.setText(QtGui.QApplication.translate("SubplotTool", "top", None, QtGui.QApplication.UnicodeUTF8)) - self.labelbottom.setText(QtGui.QApplication.translate("SubplotTool", "bottom", None, QtGui.QApplication.UnicodeUTF8)) - self.labelleft.setText(QtGui.QApplication.translate("SubplotTool", "left", None, QtGui.QApplication.UnicodeUTF8)) - self.labelright.setText(QtGui.QApplication.translate("SubplotTool", "right", None, QtGui.QApplication.UnicodeUTF8)) - self.groupBox_2.setTitle(QtGui.QApplication.translate("SubplotTool", "Spaces", None, QtGui.QApplication.UnicodeUTF8)) - self.labelhspace.setText(QtGui.QApplication.translate("SubplotTool", "hspace", None, QtGui.QApplication.UnicodeUTF8)) - self.labelwspace.setText(QtGui.QApplication.translate("SubplotTool", "wspace", None, QtGui.QApplication.UnicodeUTF8)) + SubplotTool.setWindowTitle(_translate("SubplotTool", "Dialog", None)) + self.tightLayout.setText(_translate("SubplotTool", "tight layout", None)) + self.resetButton.setText(_translate("SubplotTool", "reset", None)) + self.doneButton.setText(_translate("SubplotTool", "close", None)) + self.groupBox.setTitle(_translate("SubplotTool", "Borders", None)) + self.labeltop.setText(_translate("SubplotTool", "top", None)) + self.topvalue.setText(_translate("SubplotTool", "0", None)) + self.labelbottom.setText(_translate("SubplotTool", "bottom", None)) + self.bottomvalue.setText(_translate("SubplotTool", "0", None)) + self.labelleft.setText(_translate("SubplotTool", "left", None)) + self.leftvalue.setText(_translate("SubplotTool", "0", None)) + self.labelright.setText(_translate("SubplotTool", "right", None)) + self.rightvalue.setText(_translate("SubplotTool", "0", None)) + self.groupBox_2.setTitle(_translate("SubplotTool", "Spaces", None)) + self.labelhspace.setText(_translate("SubplotTool", "hspace", None)) + self.hspacevalue.setText(_translate("SubplotTool", "0", None)) + self.labelwspace.setText(_translate("SubplotTool", "wspace", None)) + self.wspacevalue.setText(_translate("SubplotTool", "0", None)) diff --git a/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui b/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui index 08bc198ea3a8..b528de641e86 100644 --- a/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui +++ b/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui @@ -117,6 +117,12 @@ + + false + + + 0 + Qt::Horizontal @@ -134,6 +140,22 @@ + + + + + 30 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -176,6 +198,22 @@ + + + + + 30 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -218,6 +256,22 @@ + + + + + 30 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -260,6 +314,22 @@ + + + + + 30 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -317,6 +387,22 @@ + + + + + 30 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -362,6 +448,22 @@ + + + + + 30 + 0 + + + + 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + From 2bb4bddd6c3585ba53ea4f4c302115b32ff0fa60 Mon Sep 17 00:00:00 2001 From: rhoef Date: Sun, 9 Jun 2013 11:14:25 +0200 Subject: [PATCH 5/7] removed ui file for sublplot for pyside-pyqt4 compat. Conflicts: lib/matplotlib/backends/backend_qt4.py lib/matplotlib/backends/qt4_editor/formsubplottool.py --- lib/matplotlib/backends/backend_qt4.py | 7 +- .../backends/qt4_editor/formsubplottool.py | 390 +++++++------- .../backends/qt4_editor/subplot_conftool.ui | 495 ------------------ 3 files changed, 190 insertions(+), 702 deletions(-) delete mode 100644 lib/matplotlib/backends/qt4_editor/subplot_conftool.ui diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index f852331fa5c7..97f01933acf7 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -39,7 +39,7 @@ figureoptions = None from .qt4_compat import QtCore, QtGui, _getSaveFileName, __version__ -from matplotlib.backends.qt4_editor.formsubplottool import Ui_SubplotTool +from matplotlib.backends.qt4_editor.formsubplottool import UiSubplotTool backend_version = __version__ @@ -713,10 +713,9 @@ def save_figure(self, *args): QtGui.QMessageBox.Ok, QtGui.QMessageBox.NoButton) -class SubplotToolQt(SubplotTool, QtGui.QDialog, Ui_SubplotTool): +class SubplotToolQt(SubplotTool, UiSubplotTool): def __init__(self, targetfig, parent): - QtGui.QDialog.__init__(self, None) - self.setupUi(self) + UiSubplotTool.__init__(self, None) self.targetfig = targetfig self.parent = parent self.connect(self.doneButton, QtCore.SIGNAL("clicked()"), self.close) diff --git a/lib/matplotlib/backends/qt4_editor/formsubplottool.py b/lib/matplotlib/backends/qt4_editor/formsubplottool.py index 37ce31f34d36..e55595e53566 100644 --- a/lib/matplotlib/backends/qt4_editor/formsubplottool.py +++ b/lib/matplotlib/backends/qt4_editor/formsubplottool.py @@ -1,74 +1,41 @@ # -*- coding: utf-8 -*- +""" +formsubplottool.py -# Form implementation generated from reading ui file 'lib/matplotlib/backends/qt4_editor/subplot_conftool.ui' -# -# Created: Mon Jun 3 01:47:41 2013 -# by: PyQt4 UI code generator 4.10.1 -# -# WARNING! All changes made in this file will be lost! - -from PyQt4 import QtCore, QtGui - -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - def _fromUtf8(s): - return s - -try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) -except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) - -class Ui_SubplotTool(object): - def setupUi(self, SubplotTool): - SubplotTool.setObjectName(_fromUtf8("SubplotTool")) - SubplotTool.resize(447, 265) - self.horizontalLayout = QtGui.QHBoxLayout(SubplotTool) - self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) - self.gridLayout = QtGui.QGridLayout() - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setSpacing(0) - self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) - self.tightLayout = QtGui.QPushButton(SubplotTool) - self.tightLayout.setObjectName(_fromUtf8("tightLayout")) - self.horizontalLayout_2.addWidget(self.tightLayout) - spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem) - self.resetButton = QtGui.QPushButton(SubplotTool) - self.resetButton.setObjectName(_fromUtf8("resetButton")) - self.horizontalLayout_2.addWidget(self.resetButton) - spacerItem1 = QtGui.QSpacerItem(5, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) - self.horizontalLayout_2.addItem(spacerItem1) - self.doneButton = QtGui.QPushButton(SubplotTool) - self.doneButton.setEnabled(True) - self.doneButton.setFlat(False) - self.doneButton.setObjectName(_fromUtf8("doneButton")) - self.horizontalLayout_2.addWidget(self.doneButton) - self.gridLayout.addLayout(self.horizontalLayout_2, 8, 0, 1, 1) - self.groupBox = QtGui.QGroupBox(SubplotTool) - self.groupBox.setObjectName(_fromUtf8("groupBox")) - self.verticalLayout = QtGui.QVBoxLayout(self.groupBox) +backend.qt4 (PyQt4|PySide) independend form form the subplot tool. + +""" + +__author__ = 'rudolf.hoefler@gmail.com' + +from matplotlib.backends.qt4_compat import QtCore, QtGui + +class UiSubplotTool(QtGui.QDialog): + + def __init__(self, *args, **kwargs): + super(UiSubplotTool, self).__init__(*args, **kwargs) + self.setObjectName('SubplotTool') + self.resize(450, 265) + + gbox = QtGui.QGridLayout(self) + self.setLayout(gbox) + + # groupbox borders + groupbox = QtGui.QGroupBox('Borders', self) + gbox.addWidget(groupbox, 6, 0, 1, 1) + self.verticalLayout = QtGui.QVBoxLayout(groupbox) self.verticalLayout.setSpacing(0) - self.verticalLayout.setMargin(0) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + + # slider top self.hboxtop = QtGui.QHBoxLayout() - self.hboxtop.setObjectName(_fromUtf8("hboxtop")) - self.labeltop = QtGui.QLabel(self.groupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.labeltop.sizePolicy().hasHeightForWidth()) - self.labeltop.setSizePolicy(sizePolicy) + self.labeltop = QtGui.QLabel('top', self) self.labeltop.setMinimumSize(QtCore.QSize(50, 0)) - self.labeltop.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labeltop.setObjectName(_fromUtf8("labeltop")) - self.hboxtop.addWidget(self.labeltop) - self.slidertop = QtGui.QSlider(self.groupBox) + self.labeltop.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.slidertop = QtGui.QSlider(self) self.slidertop.setMouseTracking(False) self.slidertop.setProperty("value", 0) self.slidertop.setOrientation(QtCore.Qt.Horizontal) @@ -76,170 +43,187 @@ def setupUi(self, SubplotTool): self.slidertop.setInvertedControls(False) self.slidertop.setTickPosition(QtGui.QSlider.TicksAbove) self.slidertop.setTickInterval(100) - self.slidertop.setObjectName(_fromUtf8("slidertop")) - self.hboxtop.addWidget(self.slidertop) - self.topvalue = QtGui.QLabel(self.groupBox) + + self.topvalue = QtGui.QLabel('0', self) self.topvalue.setMinimumSize(QtCore.QSize(30, 0)) - self.topvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.topvalue.setObjectName(_fromUtf8("topvalue")) - self.hboxtop.addWidget(self.topvalue) + self.topvalue.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + self.verticalLayout.addLayout(self.hboxtop) - self.hboxbottom = QtGui.QHBoxLayout() - self.hboxbottom.setObjectName(_fromUtf8("hboxbottom")) - self.labelbottom = QtGui.QLabel(self.groupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.labelbottom.sizePolicy().hasHeightForWidth()) - self.labelbottom.setSizePolicy(sizePolicy) - self.labelbottom.setMinimumSize(QtCore.QSize(50, 0)) - self.labelbottom.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelbottom.setObjectName(_fromUtf8("labelbottom")) - self.hboxbottom.addWidget(self.labelbottom) - self.sliderbottom = QtGui.QSlider(self.groupBox) + self.hboxtop.addWidget(self.labeltop) + self.hboxtop.addWidget(self.slidertop) + self.hboxtop.addWidget(self.topvalue) + + # slider bottom + hboxbottom = QtGui.QHBoxLayout() + labelbottom = QtGui.QLabel('bottom', self) + labelbottom.setMinimumSize(QtCore.QSize(50, 0)) + labelbottom.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.sliderbottom = QtGui.QSlider(self) + self.sliderbottom.setMouseTracking(False) + self.sliderbottom.setProperty("value", 0) self.sliderbottom.setOrientation(QtCore.Qt.Horizontal) self.sliderbottom.setInvertedAppearance(False) + self.sliderbottom.setInvertedControls(False) self.sliderbottom.setTickPosition(QtGui.QSlider.TicksAbove) self.sliderbottom.setTickInterval(100) - self.sliderbottom.setObjectName(_fromUtf8("sliderbottom")) - self.hboxbottom.addWidget(self.sliderbottom) - self.bottomvalue = QtGui.QLabel(self.groupBox) + + self.bottomvalue = QtGui.QLabel('0', self) self.bottomvalue.setMinimumSize(QtCore.QSize(30, 0)) - self.bottomvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.bottomvalue.setObjectName(_fromUtf8("bottomvalue")) - self.hboxbottom.addWidget(self.bottomvalue) - self.verticalLayout.addLayout(self.hboxbottom) - self.hboxleft = QtGui.QHBoxLayout() - self.hboxleft.setObjectName(_fromUtf8("hboxleft")) - self.labelleft = QtGui.QLabel(self.groupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.labelleft.sizePolicy().hasHeightForWidth()) - self.labelleft.setSizePolicy(sizePolicy) - self.labelleft.setMinimumSize(QtCore.QSize(50, 0)) - self.labelleft.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelleft.setObjectName(_fromUtf8("labelleft")) - self.hboxleft.addWidget(self.labelleft) - self.sliderleft = QtGui.QSlider(self.groupBox) + self.bottomvalue.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.verticalLayout.addLayout(hboxbottom) + hboxbottom.addWidget(labelbottom) + hboxbottom.addWidget(self.sliderbottom) + hboxbottom.addWidget(self.bottomvalue) + + # slider left + hboxleft = QtGui.QHBoxLayout() + labelleft = QtGui.QLabel('left', self) + labelleft.setMinimumSize(QtCore.QSize(50, 0)) + labelleft.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.sliderleft = QtGui.QSlider(self) + self.sliderleft.setMouseTracking(False) + self.sliderleft.setProperty("value", 0) self.sliderleft.setOrientation(QtCore.Qt.Horizontal) self.sliderleft.setInvertedAppearance(False) + self.sliderleft.setInvertedControls(False) self.sliderleft.setTickPosition(QtGui.QSlider.TicksAbove) self.sliderleft.setTickInterval(100) - self.sliderleft.setObjectName(_fromUtf8("sliderleft")) - self.hboxleft.addWidget(self.sliderleft) - self.leftvalue = QtGui.QLabel(self.groupBox) + + self.leftvalue = QtGui.QLabel('0', self) self.leftvalue.setMinimumSize(QtCore.QSize(30, 0)) - self.leftvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.leftvalue.setObjectName(_fromUtf8("leftvalue")) - self.hboxleft.addWidget(self.leftvalue) - self.verticalLayout.addLayout(self.hboxleft) - self.hboxright = QtGui.QHBoxLayout() - self.hboxright.setObjectName(_fromUtf8("hboxright")) - self.labelright = QtGui.QLabel(self.groupBox) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.labelright.sizePolicy().hasHeightForWidth()) - self.labelright.setSizePolicy(sizePolicy) + self.leftvalue.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.verticalLayout.addLayout(hboxleft) + hboxleft.addWidget(labelleft) + hboxleft.addWidget(self.sliderleft) + hboxleft.addWidget(self.leftvalue) + + # slider right + hboxright = QtGui.QHBoxLayout() + self.labelright = QtGui.QLabel('right', self) self.labelright.setMinimumSize(QtCore.QSize(50, 0)) - self.labelright.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelright.setObjectName(_fromUtf8("labelright")) - self.hboxright.addWidget(self.labelright) - self.sliderright = QtGui.QSlider(self.groupBox) + self.labelright.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.sliderright = QtGui.QSlider(self) + self.sliderright.setMouseTracking(False) + self.sliderright.setProperty("value", 0) self.sliderright.setOrientation(QtCore.Qt.Horizontal) self.sliderright.setInvertedAppearance(False) + self.sliderright.setInvertedControls(False) self.sliderright.setTickPosition(QtGui.QSlider.TicksAbove) self.sliderright.setTickInterval(100) - self.sliderright.setObjectName(_fromUtf8("sliderright")) - self.hboxright.addWidget(self.sliderright) - self.rightvalue = QtGui.QLabel(self.groupBox) + + self.rightvalue = QtGui.QLabel('0', self) self.rightvalue.setMinimumSize(QtCore.QSize(30, 0)) - self.rightvalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.rightvalue.setObjectName(_fromUtf8("rightvalue")) - self.hboxright.addWidget(self.rightvalue) - self.verticalLayout.addLayout(self.hboxright) - self.gridLayout.addWidget(self.groupBox, 5, 0, 1, 1) - self.groupBox_2 = QtGui.QGroupBox(SubplotTool) - self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) - self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox_2) - self.verticalLayout_2.setSpacing(0) - self.verticalLayout_2.setMargin(0) - self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) - self.hboxhspace = QtGui.QHBoxLayout() - self.hboxhspace.setObjectName(_fromUtf8("hboxhspace")) - self.labelhspace = QtGui.QLabel(self.groupBox_2) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.labelhspace.sizePolicy().hasHeightForWidth()) - self.labelhspace.setSizePolicy(sizePolicy) + self.rightvalue.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.verticalLayout.addLayout(hboxright) + hboxright.addWidget(self.labelright) + hboxright.addWidget(self.sliderright) + hboxright.addWidget(self.rightvalue) + + # groupbox spacings + groupbox = QtGui.QGroupBox('Spacings', self) + gbox.addWidget(groupbox, 7, 0, 1, 1) + self.verticalLayout = QtGui.QVBoxLayout(groupbox) + self.verticalLayout.setSpacing(0) + + # slider hspace + hboxhspace = QtGui.QHBoxLayout() + self.labelhspace = QtGui.QLabel('hspace', self) self.labelhspace.setMinimumSize(QtCore.QSize(50, 0)) - self.labelhspace.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelhspace.setObjectName(_fromUtf8("labelhspace")) - self.hboxhspace.addWidget(self.labelhspace) - self.sliderhspace = QtGui.QSlider(self.groupBox_2) + self.labelhspace.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.sliderhspace = QtGui.QSlider(self) + self.sliderhspace.setMouseTracking(False) + self.sliderhspace.setProperty("value", 0) self.sliderhspace.setOrientation(QtCore.Qt.Horizontal) self.sliderhspace.setInvertedAppearance(False) + self.sliderhspace.setInvertedControls(False) self.sliderhspace.setTickPosition(QtGui.QSlider.TicksAbove) self.sliderhspace.setTickInterval(100) - self.sliderhspace.setObjectName(_fromUtf8("sliderhspace")) - self.hboxhspace.addWidget(self.sliderhspace) - self.hspacevalue = QtGui.QLabel(self.groupBox_2) + + self.hspacevalue = QtGui.QLabel('0', self) self.hspacevalue.setMinimumSize(QtCore.QSize(30, 0)) - self.hspacevalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.hspacevalue.setObjectName(_fromUtf8("hspacevalue")) - self.hboxhspace.addWidget(self.hspacevalue) - self.verticalLayout_2.addLayout(self.hboxhspace) - self.hboxwspace = QtGui.QHBoxLayout() - self.hboxwspace.setObjectName(_fromUtf8("hboxwspace")) - self.labelwspace = QtGui.QLabel(self.groupBox_2) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.labelwspace.sizePolicy().hasHeightForWidth()) - self.labelwspace.setSizePolicy(sizePolicy) + self.hspacevalue.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.verticalLayout.addLayout(hboxhspace) + hboxhspace.addWidget(self.labelhspace) + hboxhspace.addWidget(self.sliderhspace) + hboxhspace.addWidget(self.hspacevalue) # slider hspace + + # slider wspace + hboxwspace = QtGui.QHBoxLayout() + self.labelwspace = QtGui.QLabel('wspace', self) self.labelwspace.setMinimumSize(QtCore.QSize(50, 0)) - self.labelwspace.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.labelwspace.setObjectName(_fromUtf8("labelwspace")) - self.hboxwspace.addWidget(self.labelwspace) - self.sliderwspace = QtGui.QSlider(self.groupBox_2) - self.sliderwspace.setTracking(True) + self.labelwspace.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.sliderwspace = QtGui.QSlider(self) + self.sliderwspace.setMouseTracking(False) + self.sliderwspace.setProperty("value", 0) self.sliderwspace.setOrientation(QtCore.Qt.Horizontal) self.sliderwspace.setInvertedAppearance(False) + self.sliderwspace.setInvertedControls(False) self.sliderwspace.setTickPosition(QtGui.QSlider.TicksAbove) self.sliderwspace.setTickInterval(100) - self.sliderwspace.setObjectName(_fromUtf8("sliderwspace")) - self.hboxwspace.addWidget(self.sliderwspace) - self.wspacevalue = QtGui.QLabel(self.groupBox_2) + + self.wspacevalue = QtGui.QLabel('0', self) self.wspacevalue.setMinimumSize(QtCore.QSize(30, 0)) - self.wspacevalue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.wspacevalue.setObjectName(_fromUtf8("wspacevalue")) - self.hboxwspace.addWidget(self.wspacevalue) - self.verticalLayout_2.addLayout(self.hboxwspace) - self.gridLayout.addWidget(self.groupBox_2, 6, 0, 1, 1) - self.horizontalLayout.addLayout(self.gridLayout) - - self.retranslateUi(SubplotTool) - QtCore.QObject.connect(self.doneButton, QtCore.SIGNAL(_fromUtf8("clicked()")), SubplotTool.accept) - QtCore.QMetaObject.connectSlotsByName(SubplotTool) - - def retranslateUi(self, SubplotTool): - SubplotTool.setWindowTitle(_translate("SubplotTool", "Dialog", None)) - self.tightLayout.setText(_translate("SubplotTool", "tight layout", None)) - self.resetButton.setText(_translate("SubplotTool", "reset", None)) - self.doneButton.setText(_translate("SubplotTool", "close", None)) - self.groupBox.setTitle(_translate("SubplotTool", "Borders", None)) - self.labeltop.setText(_translate("SubplotTool", "top", None)) - self.topvalue.setText(_translate("SubplotTool", "0", None)) - self.labelbottom.setText(_translate("SubplotTool", "bottom", None)) - self.bottomvalue.setText(_translate("SubplotTool", "0", None)) - self.labelleft.setText(_translate("SubplotTool", "left", None)) - self.leftvalue.setText(_translate("SubplotTool", "0", None)) - self.labelright.setText(_translate("SubplotTool", "right", None)) - self.rightvalue.setText(_translate("SubplotTool", "0", None)) - self.groupBox_2.setTitle(_translate("SubplotTool", "Spaces", None)) - self.labelhspace.setText(_translate("SubplotTool", "hspace", None)) - self.hspacevalue.setText(_translate("SubplotTool", "0", None)) - self.labelwspace.setText(_translate("SubplotTool", "wspace", None)) - self.wspacevalue.setText(_translate("SubplotTool", "0", None)) + self.wspacevalue.setAlignment( + QtCore.Qt.AlignRight | + QtCore.Qt.AlignTrailing | + QtCore.Qt.AlignVCenter) + + self.verticalLayout.addLayout(hboxwspace) + hboxwspace.addWidget(self.labelwspace) + hboxwspace.addWidget(self.sliderwspace) + hboxwspace.addWidget(self.wspacevalue) + + # button bar + hbox2 = QtGui.QHBoxLayout() + gbox.addLayout(hbox2, 8, 0, 1, 1) + self.tightLayout = QtGui.QPushButton('Thight Layout', self) + spacer = QtGui.QSpacerItem( + 5, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.resetButton = QtGui.QPushButton('Reset', self) + self.doneButton = QtGui.QPushButton('Close', self) + self.doneButton.setFocus(True) + hbox2.addWidget(self.tightLayout) + hbox2.addItem(spacer) + hbox2.addWidget(self.resetButton) + hbox2.addWidget(self.doneButton) + + self.connect(self.doneButton, QtCore.SIGNAL("clicked()"), self.accept) diff --git a/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui b/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui deleted file mode 100644 index b528de641e86..000000000000 --- a/lib/matplotlib/backends/qt4_editor/subplot_conftool.ui +++ /dev/null @@ -1,495 +0,0 @@ - - - SubplotTool - - - - 0 - 0 - 447 - 265 - - - - Dialog - - - - - - - - 0 - - - - - tight layout - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - reset - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 5 - 20 - - - - - - - - true - - - close - - - false - - - - - - - - - Borders - - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - top - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - false - - - 0 - - - Qt::Horizontal - - - false - - - false - - - QSlider::TicksAbove - - - 100 - - - - - - - - 30 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - bottom - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - false - - - QSlider::TicksAbove - - - 100 - - - - - - - - 30 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - left - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - false - - - QSlider::TicksAbove - - - 100 - - - - - - - - 30 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - right - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - false - - - QSlider::TicksAbove - - - 100 - - - - - - - - 30 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - Spaces - - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - hspace - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - false - - - QSlider::TicksAbove - - - 100 - - - - - - - - 30 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - wspace - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - true - - - Qt::Horizontal - - - false - - - QSlider::TicksAbove - - - 100 - - - - - - - - 30 - 0 - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - doneButton - clicked() - SubplotTool - accept() - - - 274 - 246 - - - 163 - 135 - - - - - From bf5dfcd87619b75e166928e4e48260b31dc26a23 Mon Sep 17 00:00:00 2001 From: Rudolf Hoefler Date: Fri, 19 Jul 2013 15:06:18 +0200 Subject: [PATCH 6/7] interdivsion fixed and spaces removed Conflicts: lib/matplotlib/backends/backend_qt4.py --- lib/matplotlib/backends/backend_qt4.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index 97f01933acf7..6d2f9312f53b 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -668,7 +668,7 @@ def draw_rubberband(self, event, x0, y0, x1, y1): def configure_subplots(self): image = os.path.join(matplotlib.rcParams['datapath'], - 'images','matplotlib.png') + 'images', 'matplotlib.png') dia = SubplotToolQt(self.canvas.figure, self.parent) dia.setWindowIcon(QtGui.QIcon(image)) dia.exec_() @@ -792,7 +792,7 @@ def _setSliderPositions(self): def funcleft(self, val): if val == self.sliderright.value(): val -= 1 - val /= 1000 + val /= 1000. self.targetfig.subplots_adjust(left=val) self.leftvalue.setText("%.2f" %val) if self.drawon: @@ -819,7 +819,7 @@ def funcbottom(self, val): def functop(self, val): if val == self.sliderbottom.value(): val += 1 - val /= 1000.0 + val /= 1000. self.targetfig.subplots_adjust(top=val) self.topvalue.setText("%.2f" %val) if self.drawon: From 2bffa69cf7dc6b571fc5fdea27dba560d55a37de Mon Sep 17 00:00:00 2001 From: Thomas Hisch Date: Sun, 27 Oct 2013 01:28:57 +0200 Subject: [PATCH 7/7] fix pep8 problems --- lib/matplotlib/backends/backend_qt4.py | 20 +++++++++---------- .../backends/qt4_editor/formsubplottool.py | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index 6d2f9312f53b..9bde3769ecfb 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -720,7 +720,8 @@ def __init__(self, targetfig, parent): self.parent = parent self.connect(self.doneButton, QtCore.SIGNAL("clicked()"), self.close) self.connect(self.resetButton, QtCore.SIGNAL("clicked()"), self.reset) - self.connect(self.tightLayout, QtCore.SIGNAL("clicked()"), self.functight) + self.connect(self.tightLayout, QtCore.SIGNAL("clicked()"), + self.functight) sliders = (self.sliderleft, self.sliderbottom, self.sliderright, self.slidertop, self.sliderwspace, self.sliderhspace,) @@ -770,10 +771,9 @@ def _read_defaults(self): self.defaults = {'left': self.targetfig.subplotpars.left, 'bottom': self.targetfig.subplotpars.bottom, 'right': self.targetfig.subplotpars.right, - 'top':self.targetfig.subplotpars.top, + 'top': self.targetfig.subplotpars.top, 'wspace': self.targetfig.subplotpars.wspace, - 'hspace': self.targetfig.subplotpars.hspace - } + 'hspace': self.targetfig.subplotpars.hspace} def _setSliderPositions(self): self.sliderleft.setSliderPosition( @@ -794,7 +794,7 @@ def funcleft(self, val): val -= 1 val /= 1000. self.targetfig.subplots_adjust(left=val) - self.leftvalue.setText("%.2f" %val) + self.leftvalue.setText("%.2f" % val) if self.drawon: self.targetfig.canvas.draw() @@ -803,7 +803,7 @@ def funcright(self, val): val += 1 val /= 1000. self.targetfig.subplots_adjust(right=val) - self.rightvalue.setText("%.2f" %val) + self.rightvalue.setText("%.2f" % val) if self.drawon: self.targetfig.canvas.draw() @@ -812,7 +812,7 @@ def funcbottom(self, val): val -= 1 val /= 1000. self.targetfig.subplots_adjust(bottom=val) - self.bottomvalue.setText("%.2f" %val) + self.bottomvalue.setText("%.2f" % val) if self.drawon: self.targetfig.canvas.draw() @@ -821,21 +821,21 @@ def functop(self, val): val += 1 val /= 1000. self.targetfig.subplots_adjust(top=val) - self.topvalue.setText("%.2f" %val) + self.topvalue.setText("%.2f" % val) if self.drawon: self.targetfig.canvas.draw() def funcwspace(self, val): val /= 1000. self.targetfig.subplots_adjust(wspace=val) - self.wspacevalue.setText("%.2f" %val) + self.wspacevalue.setText("%.2f" % val) if self.drawon: self.targetfig.canvas.draw() def funchspace(self, val): val /= 1000. self.targetfig.subplots_adjust(hspace=val) - self.hspacevalue.setText("%.2f" %val) + self.hspacevalue.setText("%.2f" % val) if self.drawon: self.targetfig.canvas.draw() diff --git a/lib/matplotlib/backends/qt4_editor/formsubplottool.py b/lib/matplotlib/backends/qt4_editor/formsubplottool.py index e55595e53566..dabb6b9e0f2d 100644 --- a/lib/matplotlib/backends/qt4_editor/formsubplottool.py +++ b/lib/matplotlib/backends/qt4_editor/formsubplottool.py @@ -10,6 +10,7 @@ from matplotlib.backends.qt4_compat import QtCore, QtGui + class UiSubplotTool(QtGui.QDialog): def __init__(self, *args, **kwargs):