Exemplo n.º 1
0
 def _addOptionToLayout(self, parent, grid, i, o, v):
     from PyQt4.QtGui import QLabel, QComboBox, QSpinBox, QLineEdit, QCheckBox
     from PyQt4.QtCore import Qt
     e = ""
     fillHorizontal = False
     choiceOptions = self._getChoiceOptions(o[0])
     if choiceOptions is not None:
         e = QComboBox(parent)
         self._initChoiceOption(o[0], e, choiceOptions, v)
     elif type(v) == types.IntType:
         e = QSpinBox(parent)
         e.setMinimum(0)
         e.setMaximum(1000000)
         e.setSingleStep(1)
         e.setValue(v)
     elif type(v) == types.BooleanType:
         e = QCheckBox(parent)
         e.setCheckState(Qt.Checked if v else Qt.Unchecked)
         fillHorizontal = True
     else:
         e = QLineEdit(v, parent)
         fillHorizontal = True
         
     grid.addWidget(QLabel(o[1]), i, 0, Qt.AlignRight)
     grid.addWidget(e, i, 1, Qt.AlignLeft if fillHorizontal is False else Qt.Alignment(0))
     self.option_widgets[o[0]] = e
Exemplo n.º 2
0
 def addGuiItem(self, ParentClass, parameters, width):
     """Defines a new set of Label and a box that can be a
     ComboBox, RComboBox, LineEdit, TextEdit or DoubleSpinBox."""
     widgetType=parameters[1]
     #check if there are default values:
     if len(parameters)>2:
         default=parameters[2]
     else:
         default=""
     skip = False
     notnull=parameters[3]
     #setting the right type of widget
     if widgetType=="comboBox":
         widget = QComboBox(ParentClass)
         widget.addItems(default.split(';'))
         widget.setFixedHeight(26)
     elif widgetType=="RComboBox":
         widget = RComboBox(ParentClass, default.split(';'))
         widget.setFixedHeight(26)
         self.hasRComboBox = True
         widget.setEditable(True)
     elif widgetType=="RListWidget":
         widget = RListWidget(ParentClass,
         default.split(';'), notnull)
         widget.setMinimumHeight(116)
         self.hasRComboBox = True
         widget.setSelectionMode(
         QAbstractItemView.ExtendedSelection)
     elif widgetType=="doubleSpinBox":
         widget = QDoubleSpinBox(ParentClass)
         widget.setValue(float(default))
         widget.setFixedHeight(26)
         widget.setMaximum(999999.9999)
         widget.setDecimals(4)
     elif widgetType=="textEdit":
         widget = QTextEdit(ParentClass)
         widget.setPlainText(default)
         widget.setMinimumHeight(116)
     elif widgetType=="helpString":
         self.helpString = default
         skip = True
     else:
         #if unknown assumes lineEdit
         widget = QLineEdit(ParentClass)
         widget.setText(default)
         widget.setFixedHeight(26)
     if not skip:
         hbox = QHBoxLayout()
         name="widget"+unicode(self.widgetCounter)
         widget.setObjectName(name)
         widget.setMinimumWidth(250)
         self.widgets.append(widget)
         name="label"+unicode(self.widgetCounter)
         self.widgetCounter += 1
         label = QLabel(ParentClass)
         label.setObjectName(name)
         label.setFixedWidth(width*8)
         label.setText(parameters[0])
         hbox.addWidget(label)
         hbox.addWidget(widget)
         self.vbox.addLayout(hbox)