def createDataSelectorWidgets(self, parent, parent_layout): """Creates toolbuttons for complex values and Vells selection""" #print('in createDataSelectionWidgets') self._ds_top = top = QWidget(parent) parent_layout.addWidget(top) self._ds_lo = lotop = QVBoxLayout(top) lotop.setContentsMargins(0, 0, 0, 0) self._ds_complex = QWidget(top) self._ds_complex.setVisible(False) lotop.addWidget(self._ds_complex) lo = QVBoxLayout(self._ds_complex) lo.setContentsMargins(0, 0, 0, 0) lab = QLabel("complex:") lab.setAlignment(Qt.AlignHCenter) lo.addWidget(lab) # add complex selector lo0 = QHBoxLayout() lo0.setContentsMargins(0, 0, 0, 0) lo.addLayout(lo0) lo1 = QGridLayout() lo1.setContentsMargins(0, 0, 0, 0) lo1.setHorizontalSpacing(0) lo1.setVerticalSpacing(0) # lo0.addStretch(1); lo0.addLayout(lo1) # lo0.addStretch(1); bgrp = QButtonGroup(self._ds_complex) # tbdesc = { self.AMP:(u"\u007Ca\u007C",0,0),self.PHASE:(u"\u03D5",0,1),self.REAL:("Re",1,0),self.IMAG:("Im",1,1) }; # tbdesc = { self.AMP:("\\u007Ca\\u007C",0,0),self.PHASE:("\\u0278",0,1),self.REAL:("Re",1,0),self.IMAG:("Im",1,1) }; tbdesc = { self.AMP: ("Amp", 0, 0), self.PHASE: ("Pha", 0, 1), self.REAL: ("Re", 1, 0), self.IMAG: ("Im", 1, 1) } for label, qa in list(self._qas_complex.items()): tbtext, row, col = tbdesc[label] tb = QToolButton(self._ds_complex) lo1.addWidget(tb, row, col) bgrp.addButton(tb) tb.setText(tbtext) tb.setToolButtonStyle(Qt.ToolButtonTextOnly) tb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) tb.setCheckable(True) tb.setChecked(label is self.complex_component) tb.setMinimumWidth(32) tb.clicked[bool].connect(qa.setChecked) tb.clicked[bool].connect(self._change_complex) qa.triggered[bool].connect(tb.setChecked) self._tbs_complex[label] = tb
def __init__(self, parent=None): QwtAbstractLegend.__init__(self, parent) self.setFrameStyle(QFrame.NoFrame) self.__data = QwtLegend_PrivateData() self.__data.view = LegendView(self) self.__data.view.setObjectName("QwtLegendView") self.__data.view.setFrameStyle(QFrame.NoFrame) gridLayout = QwtDynGridLayout(self.__data.view.contentsWidget) gridLayout.setAlignment(Qt.AlignHCenter|Qt.AlignTop) self.__data.view.gridLayout = gridLayout self.__data.view.contentsWidget.installEventFilter(self) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.__data.view)
def setVellsElementLabels(self, labels, dims): # do nothing when only one label, or when already set if len(labels) < 2 or self._qas_vells: return # make menu items # print 'in setVellsElementLabels, labels = ', labels for label in labels: # make menu action self._qas_vells[label] = va = self._qag_vells.addAction(str(label)) va.setCheckable(True) # if first QAction, then check it if len(self._qas_vells) == 1: va.setChecked(True) self.vells_component = label self.vells_menu.addAction(va) self.vells_menu.menuAction().setVisible(True) # following does nothing at the moment for label in self.StokesComponents: self._qas_stokes[label] = vs = self._qag_stokes.addAction(label) vs.setCheckable(True) self.stokes_menu.addAction(vs) self.stokes_menu.menuAction().setVisible(True) # make grid of selector buttons, if dims are not too big if len(dims) == 1: dims = (1, dims[0]) if len(dims) == 2 and min(*dims) >= 2 and max(*dims) <= 6: # for dims=1, make it 1xN # add vells selector self._ds_lo.addSpacing(16) self._ds_vells = QWidget(self._ds_top) self._ds_lo.addWidget(self._ds_vells) self._ds_stokes = QWidget(self._ds_top) self._ds_lo.addWidget(self._ds_stokes) self._ds_stokes.setVisible(False) lo = QVBoxLayout(self._ds_vells) lo.setContentsMargins(0, 0, 0, 0) lab = QLabel("element:") lab.setAlignment(Qt.AlignHCenter) lo.addWidget(lab) # add data selectors for correlations and Stokes lo0 = QVBoxLayout() lo0.setContentsMargins(0, 0, 0, 0) lo.addLayout(lo0) lo1 = QGridLayout() lo1.setContentsMargins(0, 0, 0, 0) lo1.setHorizontalSpacing(0) lo1.setVerticalSpacing(0) lo0.addLayout(lo1) bgrp = QButtonGroup(self._ds_vells) # make the labels for ilabel, label in enumerate(labels): # make toolbutton tb = QToolButton(self._ds_vells) bgrp.addButton(tb) self._tbs_vells[label] = tb tb.setText(str(label)) tb.setToolButtonStyle(Qt.ToolButtonTextOnly) tb.setCheckable(True) tb.setChecked(label is self.vells_component) tb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) # tb.setMinimumWidth(32); qa = self._qas_vells[label] tb.clicked[bool].connect(qa.setChecked) tb.clicked[bool].connect(self._change_vells) qa.triggered[bool].connect(tb.setChecked) # add to layout in correct place row, col = divmod(ilabel, dims[1]) if dims[1] > 3: col, row = row, col lo1.addWidget(tb, row, col) # show/hide controls self._ds_vells.setVisible(len(labels) > 1) lab = QLabel("stokes:") lab.setAlignment(Qt.AlignHCenter) lo0.addWidget(lab) lo2 = QGridLayout() lo2.setContentsMargins(0, 0, 0, 0) lo2.setHorizontalSpacing(0) lo2.setVerticalSpacing(0) lo0.addLayout(lo2) bgrp = QButtonGroup(self._ds_stokes) stdesc = { self.STOKES_I: ("I", 0, 0), self.STOKES_Q: ("Q", 0, 1), self.STOKES_U: ("U", 1, 0), self.STOKES_V: ("V", 1, 1) } for label, qa in list(self._qas_stokes.items()): tbtext, row, col = stdesc[label] tb = QToolButton(self._ds_stokes) lo2.addWidget(tb, row, col) bgrp.addButton(tb) tb.setText(tbtext) tb.setToolButtonStyle(Qt.ToolButtonTextOnly) tb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) tb.setCheckable(True) tb.setChecked(label is self.stokes_component) qa = self._qas_stokes[label] tb.clicked[bool].connect(qa.setChecked) tb.clicked[bool].connect(self._change_stokes) qa.triggered[bool].connect(tb.setChecked) self._tbs_complex[label] = tb # show/hide controls self._ds_stokes.setVisible(len(labels) > 1)