Example #1
0
    def addRow(self):
        self.tblParameters.setRowCount(self.tblParameters.rowCount() + 1)

        row = self.tblParameters.rowCount() - 1
        column = 0
        for param in self.alg.parameters:
            if param.hidden:
                continue

            self.tblParameters.setCellWidget(
                row, column, self.getWidgetFromParameter(param, row, column))
            column += 1

        for out in self.alg.outputs:
            if out.hidden:
                continue

            self.tblParameters.setCellWidget(
                row, column, BatchOutputSelectionPanel(
                    out, self.alg, row, column, self))
            column += 1

        if self.alg.getVisibleOutputsCount():
            item = QComboBox()
            item.addItem(self.tr('Yes'))
            item.addItem(self.tr('No'))
            item.setCurrentIndex(0)
            self.tblParameters.setCellWidget(row, column, item)
class GoogleFinanceUrlSetupDialog(QDialog):

    SETTING_GOOGLE_URL = 'googleUrl'
    SETTING_GOOGLE_COUNTRY = 'googleCountry'

    def __init__(self, parent):

        QDialog.__init__(self, parent)

        self.prop = MaeMoneyProperties.instance()
        self.urls = {}
        self.urls[self.prop.GOOGLE_COUNTRY_HK] = 'www.google.com.hk'
        self.urls[self.prop.GOOGLE_COUNTRY_CN] = 'www.google.com.cn'
        self.urls[self.prop.GOOGLE_COUNTRY_CAN] = 'www.google.ca'
        self.urls[self.prop.GOOGLE_COUNTRY_UK] = 'www.google.co.uk'
        self.urls[self.prop.GOOGLE_COUNTRY_US] = 'www.google.com'

        self.setupUi()

    def setupUi(self):
        self.setWindowModality(Qt.WindowModal)
        self.buttonBox = QDialogButtonBox(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)

        self.gridLayout = QGridLayout()
        self.setLayout(self.gridLayout)

        self.labelGFinanceUrl = QLabel(self.tr("Google URL"))
        self.gridLayout.addWidget(self.labelGFinanceUrl, 0, 1, 1, 1)
        self.comboBoxGFinanceUrl = QComboBox()
        for [country, url] in sorted(self.urls.iteritems()):
            self.comboBoxGFinanceUrl.addItem(country, url)

        googleCountry = self.prop.getGoogleCountry()
        index = self.comboBoxGFinanceUrl.findText(googleCountry)
        self.comboBoxGFinanceUrl.setCurrentIndex(index)
        self.gridLayout.addWidget(self.comboBoxGFinanceUrl, 0, 2, 1, 1)

        self.gridLayout.addWidget(QLabel(self.tr("Current setting")), 1, 1, 1, 1)
        self.gridLayout.addWidget(QLabel(self.prop.getGoogleCountry()),
                                  1, 2, 1, 1)

        self.setUrlButton = QPushButton(self.tr("Set URL"))
        self.gridLayout.addWidget(self.setUrlButton, 2, 1, 1, 2)

        self.loginErrorMsgLabel = QLabel("")
        self.gridLayout.addWidget(self.loginErrorMsgLabel, 3, 1, 1, 2)

        self.setWindowTitle(self.tr("Setup"))

        self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept)
        self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject)
        self.connect(self.setUrlButton, SIGNAL("clicked()"), self.setUrl)

    def setUrl(self):
        indexSelected = self.comboBoxGFinanceUrl.currentIndex()
        country = self.comboBoxGFinanceUrl.itemText(indexSelected)
        url = self.comboBoxGFinanceUrl.itemData(indexSelected).toString().toAscii()
        self.prop.setGoogleCountryUrl(country, url)
        self.accept()
Example #3
0
class ComboBox(QWidget):
    def __init__(self, caption, values, default_value, caption_size=None, expand_combo=False):
        QWidget.__init__(self)

        self.values = values

        description = QLabel(caption)
        description.setWordWrap(True)
        if caption_size:
            description.setMaximumWidth(caption_size)

        self.combo = QComboBox()
        for item in values:
            self.combo.addItem(item, item)

        for i in range(0, len(values)):
            if values[i] == default_value:
                self.combo.setCurrentIndex(i)
                break

        hbox = QHBoxLayout()
        hbox.addWidget(description)
        hbox.addSpacing(10)
        if expand_combo:
            hbox.addWidget(self.combo, 1)
        else:
            hbox.addWidget(self.combo)
        hbox.setMargin(0)
        self.setLayout(hbox)
        self.setContentsMargins(0, 0, 0, 0)

    def get_value(self):
        return str(self.values[self.combo.currentIndex()])
Example #4
0
class FormComboWidget(QWidget):

    def __init__(self, datalist, comment="", parent=None):
        QWidget.__init__(self, parent)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QComboBox()
        layout.addWidget(self.combobox)

        self.stackwidget = QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        self.connect(self.combobox, SIGNAL("currentIndexChanged(int)"),
                     self.stackwidget, SLOT("setCurrentIndex(int)"))

        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append(widget)

    def setup(self):
        for widget in self.widgetlist:
            widget.setup()

    def get(self):
        return [widget.get() for widget in self.widgetlist]
Example #5
0
    def __init__(self, parent, configuration):
        QTableWidget.__init__(self, 5, 1, parent)
        self._configuration = configuration
        self._manual_change = True
        self.setVerticalHeaderLabels(
            ["Duration (cycles)", "Duration (ms)", "Cycles / ms",
             'RAM access time', 'Execution Time Model'])
        self.horizontalHeader().setStretchLastSection(True)
        self.horizontalHeader().hide()
        self.setItem(0, 0, QTableWidgetItem(str(configuration.duration)))
        self.setItem(1, 0, QTableWidgetItem(str(
            float(configuration.duration) / configuration.cycles_per_ms)))
        self.setItem(2, 0, QTableWidgetItem(str(configuration.cycles_per_ms)))
        self.setItem(
            3, 0, QTableWidgetItem(str(configuration.memory_access_time)))

        item = QComboBox(self)
        selected = 0
        for i, (etm_name, etm_code) in \
                enumerate(execution_time_model_names.items()):
            item.addItem(etm_name)
            if etm_code == configuration.etm:
                selected = i
        item.setCurrentIndex(selected)
        self.setCellWidget(4, 0, item)

        def activation_handler(x):
            configuration.etm = execution_time_model_names[str(x)]
            configuration.conf_changed()
        item.activated['QString'].connect(activation_handler)

#        self._update_observe_window()

        self.cellChanged.connect(self._cell_changed)
Example #6
0
    def lineEditor(self, name, item, props, parent):
        """ Creates a new editor suitable for selecting a series or index.

        @param name item parameter name, as string, to receive value updates
        @param item IndexItem instance
        @param props mapping of index class constructor properties
        @param parent ancestor of new widget
        @return QComboBox widget
        """
        children = list(item.root().children(True))
        editor = QComboBox(parent)
        editor.addItem('')
        exclude = [item.text(), self.defaultText]
        items = [c.text() for c in children if c.text() not in exclude]
        editor.addItems(items)
        try:
            editor.setCurrentIndex(editor.findText(item.parameters[name]))
        except (KeyError, ):
            item.parameters[name] = ''
        @pyqtSignature('int')
        def onChange(index):
            item.parameters[name] = str(editor.currentText())
            self.emit(Signals.modified)
        editor.onChange = onChange
        editor.connect(editor, Signals.currentIndexChanged, onChange)
        return editor
Example #7
0
    def __init__(self, iterable=False, load_all = False, help_link=""):
        QWidget.__init__(self)
        self._iterable = iterable

        addHelpToWidget(self, help_link)

        layout = QHBoxLayout()

        analysis_module_combo = QComboBox()

        self._module_names = getAnalysisModuleNames(self._iterable)
        if load_all:
            self._module_names += getAnalysisModuleNames(not self._iterable)

        for module_name in self._module_names:
            analysis_module_combo.addItem(module_name)

        self._current_module_name = self._getCurrentAnalysisModuleName()
        if self._current_module_name is not None:
            analysis_module_combo.setCurrentIndex(self._module_names.index(self._current_module_name))

        analysis_module_combo.currentIndexChanged[int].connect(self.analysisModuleChanged)

        variables_popup_button = QToolButton()
        variables_popup_button.setIcon(resourceIcon("ide/small/cog_edit.png"))
        variables_popup_button.clicked.connect(self.showVariablesPopup)
        variables_popup_button.setMaximumSize(20, 20)

        layout.addWidget(analysis_module_combo, 0, Qt.AlignLeft)
        layout.addWidget(variables_popup_button, 0, Qt.AlignLeft)
        layout.setContentsMargins(QMargins(0, 0, 0, 0))
        layout.addStretch()

        self.setLayout(layout)
Example #8
0
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        # codeCompletionBlock start
        from PyQt4.QtGui import QComboBox, QToolButton, QStackedWidget

        self.accountSelection = QComboBox()
        self.accountButton = QToolButton()
        self.accountStack = QStackedWidget()
        # codeCompletionBlock end

        uic.loadUi(getUiFile('MainWindow'), self)

        self.model = Model()
        self.model.loadLastSession()

        self.actionAdd_Account.triggered.connect(self.addSubAccount)
        self.accountSelection.currentIndexChanged.connect(self.accountStack.setCurrentIndex)

    def addSubAccount(self):
        data = inquireAccountData()
        account = self.model.createNewAccount(data['name'],
                                              data['description'],
                                              data['numbers'])
        self.model.addNewAccount(account)

        self.accountSelection.addItem(account.description)
        self.accountStack.addWidget(AccountWidget())
Example #9
0
class WidgetSelector(QWidget):
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.key_text = QLineEdit(self)
        self.widget_select = QComboBox(self)
        self.value_widget = None
        self.layout = QHBoxLayout(self)
        self.layout.addWidget(self.key_text)
        self.layout.addWidget(self.widget_select)

        self.options = NodeWidget.get_simple_widgets()
        for i, option in enumerate(self.options):
            self.widget_select.addItem(option.get_description(), i)

        self.widget_select.currentIndexChanged.connect(self.change_widget)


    def get_item(self):
        return {
            "key":unicode(self.key_text.text()),
            "value":self.value_widget.data
        }

    def change_widget(self):

        w_class = self.options[self.widget_select.currentIndex()]
        if self.value_widget:
            self.layout.removeWidget(self.value_widget)
            self.value_widget.setParent(None)
            self.value_widget = None

        element_scheme = StructuredNode({"Type":w_class.data_type})
        new_data = NodeWidget.get_default_data(element_scheme, None)
        self.value_widget = NodeWidget.create_node_widget("__not_exist", new_data, element_scheme)
        self.layout.addWidget(self.value_widget)
Example #10
0
class choixSonSortieWidget(QGroupBox) :
    """Class pour faire le widget standard de sélection du format de sortie son + réglages experts"""
    def __init__(self, soxSuppFormat, parent=None) :
      super(choixSonSortieWidget, self).__init__(parent)
      self.setObjectName("groupBox")
      self.horizontalLayout = QHBoxLayout(self)
      self.horizontalLayout.setObjectName("horizontalLayout")
      self.label = QLabel(self)
      self.label.setObjectName("label")
      self.horizontalLayout.addWidget(self.label)
      self.formatSound = QComboBox(self)
      for x in soxSuppFormat :
        self.formatSound.addItem(QString(x))
      self.formatSound.setObjectName("formatSound")
      self.horizontalLayout.addWidget(self.formatSound)
      spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
      self.horizontalLayout.addItem(spacerItem)
      self.reglageExp = reglageExpert(soxSuppFormat, self.formatSound)
      self.horizontalLayout.addWidget(self.reglageExp)
      self.setTitle(_(u"Réglage du format de sortie"))
      self.label.setText(_(u"Format du fichier de sortie :"))
      self.formatSound.setToolTip(_(u"Format du fichier son de sortie"))

    def getFileExt(self) :
      return unicode(self.formatSound.currentText())
Example #11
0
class AddAddressColumnDialog(utils.Dialog):
    def __init__(self, parent, hex_widget, column):
        utils.Dialog.__init__(self, parent, name='add_address_column_dialog')
        self.hexWidget = hex_widget
        self.column = column
        self.setWindowTitle(utils.tr('Add address bar'))

        self.setLayout(QVBoxLayout())

        self.configWidget = AddressColumnConfigurationWidget(self, hex_widget, None)
        self.layout().addWidget(self.configWidget)

        self.txtName = QLineEdit(self)
        self.configWidget.layout().insertRow(0, utils.tr('Name:'), self.txtName)

        self.cmbAlignment = QComboBox(self)
        self.cmbAlignment.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        self.cmbAlignment.addItem(utils.tr('To the left'), Qt.AlignLeft)
        self.cmbAlignment.addItem(utils.tr('To the right'), Qt.AlignRight)
        self.configWidget.layout().insertRow(1, utils.tr('Position:'), self.cmbAlignment)

        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel, Qt.Horizontal, self)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.layout().addWidget(self.buttonBox)

    def addColumn(self):
        model = self.configWidget.createColumnModel(self.hexWidget)
        model.name = self.txtName.text()
        self.hexWidget.addAddressColumn(model, self.cmbAlignment.itemData(self.cmbAlignment.currentIndex()))
Example #12
0
class H5VolumeSelectionDlg(QDialog):
    """
    A window to ask the user to choose between multiple HDF5 datasets in a single file.
    """

    def __init__(self, datasetNames, parent):
        super(H5VolumeSelectionDlg, self).__init__(parent)
        label = QLabel(
            "Your HDF5 File contains multiple image volumes.\n" "Please select the one you would like to open."
        )

        self.combo = QComboBox()
        for name in datasetNames:
            self.combo.addItem(name)

        buttonbox = QDialogButtonBox(Qt.Horizontal, parent=self)
        buttonbox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        buttonbox.accepted.connect(self.accept)
        buttonbox.rejected.connect(self.reject)

        layout = QVBoxLayout()
        layout.addWidget(label)
        layout.addWidget(self.combo)
        layout.addWidget(buttonbox)

        self.setLayout(layout)
Example #13
0
class SizeRequest(Request):
  def __init__(self, parent):
    Request.__init__(self, parent)
    self.setOperators()
    self.setContent()
    self.setSizeType()

  def setOperators(self):
    self.operatorCombo = OperatorCombo(self)
    self.hlayout.addWidget(self.operatorCombo)

  def setContent(self):
    self.content = QLineEdit(self)
    self.validator = QIntValidator(0,2147483647, self)
    self.content.setValidator(self.validator)
    self.hlayout.addWidget(self.content)

  def setSizeType(self):
    self.stype = QComboBox(self)
    self.stype.addItem(QString("KB"))
    self.stype.addItem(QString("MB"))
    self.stype.addItem(QString("GB"))
    self.hlayout.addWidget(self.stype)

  def request(self):
    operator = str(self.operatorCombo.currentText())
    factor = SIZE_T[self.stype.currentIndex()]
    size = self.content.text().toULongLong()[0]
    size = size * factor
    res = "(size " + operator + " " + str(size) + ")"
    return res
    def createPresets(self):
        preset_combo = QComboBox()
        for preset in self._presets:
            preset_combo.addItem(preset)

        preset_combo.currentIndexChanged.connect(self.presetSelected)
        return preset_combo
Example #15
0
    def __init__(self, parent, message, title, options, default):
        super(OptionDialog, self).__init__(parent)

        self.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
        self.setIcon(QMessageBox.Question)
        self.setText(message)
        self.setWindowTitle(title)

        self.selection = default

        box = QWidget()
        box.setLayout(QGridLayout())
        box.setFixedHeight(40)

        box_combo = QWidget()
        combo = QComboBox(box_combo)
        combo.setEditable(False)
        combo.box = box_combo
        for item in options:
            combo.addItem(str(item))
        combo.setCurrentIndex(default)
        combo.currentIndexChanged.connect(self.set_selection)

        box.layout().addWidget(QLabel("Select Option"), 0, 0, 1, 1)
        box.layout().addWidget(box_combo, 0, 1, 1, 1)

        self.layout().addWidget(box, 1, 1, 1, 2)
 def _getShpFieldsCombobox(self, qgisfield, selected_shpfield = None):
     '''
     Get a combobox filled with the SHP layer fields to insert in a table widget
     
     :param qgisfield: The SHP field
     :type qgisfield: QgsField
     
     :param selected_shpfield: The QGIS field to select
     :type selected_shpfield: QString, str
     
     :returns: A combobox with the QGIS layer fields
     :rtype: QWidget
     '''
     # Datatype mapping allowed while checking. For a given SHP type, several QGIS type may be allowed or compatible
     SHP_QGIS_ALLOWED_DATATYPE_MAP = [(QVariant.String, QVariant.String),
                                      (QVariant.LongLong, QVariant.LongLong),
                                      (QVariant.LongLong, QVariant.Double),
                                      (QVariant.LongLong, QVariant.String),
                                      (QVariant.Int, QVariant.Int),
                                      (QVariant.Int, QVariant.LongLong),
                                      (QVariant.Int, QVariant.Double),
                                      (QVariant.Int, QVariant.String),
                                      (QVariant.Double, QVariant.Double),
                                      (QVariant.Double, QVariant.String)]
     
     widget = QWidget()
     combobox = QComboBox()
     layout = QHBoxLayout(widget)
     layout.addWidget(combobox, 1);
     layout.setAlignment(Qt.AlignCenter);
     layout.setContentsMargins(5,0,5,0);
     widget.setLayout(layout);
     
     shplayer = self.shplayer
     shplayer_fields = shplayer.dataProvider().fields()
     
     current_item_index = 0
     selected_index = 0
     
     combobox.addItem(QCoreApplication.translate('ImportShpDialog','<None>'), None)
     current_item_index += 1
     
     for field in shplayer_fields:
         # Include only fields with compatible data type
         for shp_type, qgis_type in SHP_QGIS_ALLOWED_DATATYPE_MAP:
             if field.type() == shp_type and qgisfield.type() == qgis_type:
                 combobox.addItem(field.name(), field.name())
                 # Select field if same name
                 if field.name() == qgisfield.name() and selected_index == 0:
                     selected_index = current_item_index
                 if field.name() == selected_shpfield:
                     selected_index = current_item_index
                 current_item_index += 1
                 break;
     
     combobox.setCurrentIndex(selected_index)
     combobox.currentIndexChanged.connect(self._comboboxShpFieldIndexChanged)
     
     return widget
Example #17
0
class RunConfigDialog(BaseRunConfigDialog):
    """Run configuration dialog box: multiple file version"""
    def __init__(self, parent=None):
        BaseRunConfigDialog.__init__(self, parent)
        self.file_to_run = None
        self.combo = None
        self.stack = None
        
    def run_btn_clicked(self):
        """Run button was just clicked"""
        self.file_to_run = unicode(self.combo.currentText())
        
    def setup(self, fname):
        """Setup Run Configuration dialog with filename *fname*"""
        combo_label = QLabel(_("Select a run configuration:"))
        self.combo = QComboBox()
        self.combo.setMaxVisibleItems(20)
        self.combo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
        self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        
        self.stack = QStackedWidget()

        configurations = _get_run_configurations()
        for index, (filename, options) in enumerate(configurations):
            if fname == filename:
                break
        else:
            # There is no run configuration for script *fname*:
            # creating a temporary configuration that will be kept only if
            # dialog changes are accepted by the user
            configurations.insert(0, (fname, RunConfiguration(fname).get()))
            index = 0
        for filename, options in configurations:
            widget = RunConfigOptions(self)
            widget.set(options)
            self.combo.addItem(filename)
            self.stack.addWidget(widget)
        self.connect(self.combo, SIGNAL("currentIndexChanged(int)"),
                     self.stack.setCurrentIndex)
        self.combo.setCurrentIndex(index)

        self.add_widgets(combo_label, self.combo, 10, self.stack)
        self.add_button_box(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)

        self.setWindowTitle(_("Run Settings"))
        
    def accept(self):
        """Reimplement Qt method"""
        configurations = []
        for index in range(self.stack.count()):
            filename = unicode(self.combo.itemText(index))
            runconfigoptions = self.stack.widget(index)
            if index == self.stack.currentIndex() and\
               not runconfigoptions.is_valid():
                return
            options = runconfigoptions.get()
            configurations.append( (filename, options) )
        _set_run_configurations(configurations)
        QDialog.accept(self)
Example #18
0
class ComboTabWidget(QWidget):
    def __init__(self, parent):
        super(ComboTabWidget, self).__init__(parent)
        layout = QVBoxLayout(self)
        layout.setSpacing(0)
        
        self.switchCombo = QComboBox(self)
        layout.addWidget(self.switchCombo, 0, Qt.AlignCenter)
        
        groupBox = QGroupBox(self)
        groupBoxLayout = QVBoxLayout(groupBox)
        groupBoxLayout.setSpacing(0)
        
        self.pageArea = QStackedWidget(groupBox)
        groupBoxLayout.addWidget(self.pageArea)
        
        layout.addWidget(groupBox, 1)
        
        self.switchCombo.currentIndexChanged.connect(self.pageArea.setCurrentIndex)
        
    def setTabPosition(self, tabPos):
        pass
        
    def addTab(self, w, tabText):
        self.pageArea.addWidget(w)
        self.switchCombo.addItem(tabText)
    
    def insertTab(self, pos, w, tabText):
        self.pageArea.insertWidget(pos, w)
        self.switchCombo.insertItem(pos, tabText)
        
    def removeTab(self, index=-1):
        if index < 0:
            index = self.currentIndex()
        
        w = self.pageArea.widget(index)
        
        self.pageArea.removeWidget(w)
        self.switchCombo.removeItem(index)
        
    def updateTab(self, w, tabText, index=-1):
        if index < 0:
            index = self.switchCombo.currentIndex()
        
        self.removeTab(index)
        self.insertTab(index, w, tabText)
        self.setCurrentIndex(index)
        
    def setCurrentIndex(self, index):
        self.switchCombo.setCurrentIndex(index)
        
    def widget(self, index):
        return self.pageArea.widget(index)
        
    def currentIndex(self):
        return self.switchCombo.currentIndex()
    
    def count(self):
        return self.switchCombo.count()
Example #19
0
 def createEditor(self, parent, option, index):
     # special combobox for field type
     if index.column() == self.column:
         cbo = QComboBox(parent)
         for item in self.itemsDict:
             cbo.addItem(item, self.itemsDict[item])
         return cbo
     return QItemDelegate.createEditor(self, parent, option, index)
Example #20
0
class FloatColumnConfigurationWidget(QWidget, columnproviders.AbstractColumnConfigurationWidget):
    def __init__(self, parent, hex_widget, column):
        QWidget.__init__(self, parent)
        columnproviders.AbstractColumnConfigurationWidget.__init__(self)
        self.hexWidget = hex_widget
        self.column = column

        self.cmbBinaryFormat = QComboBox(self)
        self.cmbBinaryFormat.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

        for fmt in (valuecodecs.FloatCodec.FormatFloat, valuecodecs.FloatCodec.FormatDouble):
            self.cmbBinaryFormat.addItem(valuecodecs.FloatCodec.formatName(fmt), fmt)
            if column is not None and column.valuecodec.binaryFormat == fmt:
                self.cmbBinaryFormat.setCurrentIndex(self.cmbBinaryFormat.count() - 1)

        self.spnPrecision = QSpinBox(self)
        self.spnPrecision.setMinimum(0)
        self.spnPrecision.setMaximum(12)
        if column is not None:
            self.spnPrecision.setValue(column.formatter.precision)
        else:
            self.spnPrecision.setValue(6)

        self.spnColumnsOnRow = QSpinBox(self)
        self.spnColumnsOnRow.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        self.spnColumnsOnRow.setMinimum(1)
        self.spnColumnsOnRow.setMaximum(32)
        if column is not None:
            self.spnColumnsOnRow.setValue(column.columnsOnRow)
        else:
            self.spnColumnsOnRow.setValue(4)

        self.setLayout(QFormLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().addRow(utils.tr('Binary format:'), self.cmbBinaryFormat)
        self.layout().addRow(utils.tr('Digits after point:'), self.spnPrecision)
        self.layout().addRow(utils.tr('Columns on row:'), self.spnColumnsOnRow)

    @property
    def _valueCodec(self):
        c = valuecodecs.FloatCodec()
        c.binaryFormat = self.cmbBinaryFormat.itemData(self.cmbBinaryFormat.currentIndex())
        return c

    @property
    def _formatter(self):
        f = formatters.FloatFormatter()
        f.precision = self.spnPrecision.value()
        return f

    def createColumnModel(self, hex_widget):
        return FloatColumnModel(hex_widget.document, self._valueCodec, self._formatter, self.spnColumnsOnRow.value())

    def saveToColumn(self, column):
        column.valuecodec = self._valueCodec
        column.formatter = self._formatter
        column.columnsOnRow = self.spnColumnsOnRow.value()
        column.reset()
Example #21
0
    def addMixer(self, tabs):
        tab_mixer = QWidget(tabs)
        tabs.addTab(tab_mixer, "Mixer")
        tab_mixer_layout = QGridLayout()
        tab_mixer.setLayout(tab_mixer_layout)

        for i in range(len(self.inputs)):
            col = 2 * i;
            label = QLabel(tab_mixer)
            tab_mixer_layout.addWidget(label, 0, col, 1, 2, Qt.AlignHCenter)

            label.setText(self.inputs[i][0])
            label.setAlignment(Qt.AlignCenter)
            label.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

            link = self.getLink(tab_mixer)
            tab_mixer_layout.addWidget(link, 3, col, 1, 2, Qt.AlignHCenter)

            if self.inputs[i][2] > 0:
                for j in range(1, 3):
                    button = QToolButton(tab_mixer)
                    tab_mixer_layout.addWidget(button, 1, col + j - 1, Qt.AlignHCenter)
                    button.setText('+12dB')
                    button.setCheckable(True)
                    button.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
                    path = "/Mixer/Feature_Volume_%d" % self.inputs[i][2]
                    self.MicBoosts[button] = [path, j]

            elif self.inputs[i][0].find('Stream') >= 0:
                cmb = QComboBox(tab_mixer)
                tab_mixer_layout.addWidget(cmb, 1, col, 1, 2, Qt.AlignHCenter)
                for i in range(len(self.streams)):
                    cmb.addItem(self.streams[i][0], self.streams[i][1])
                self.Selectors[cmb] = ["/Mixer/Selector_6"]

            l_sld = self.getSlider(tab_mixer)
            r_sld = self.getSlider(tab_mixer)
            tab_mixer_layout.addWidget(l_sld, 2, col, Qt.AlignHCenter)
            tab_mixer_layout.addWidget(r_sld, 2, col + 1, Qt.AlignHCenter)

            mute = self.getMute(tab_mixer)
            tab_mixer_layout.addWidget(mute, 4, col, 1, 2, Qt.AlignHCenter)

            path = "/Mixer/Feature_Volume_%d" % self.inputs[i][1]
            self.Volumes[l_sld] = [path, 1, r_sld, link, mute]
            self.Volumes[r_sld] = [path, 2, l_sld, link, mute]
            self.Mutes[mute] = [path, l_sld, r_sld]

            for j in range(0, 2):
                dial = self.getDial(tab_mixer)
                tab_mixer_layout.addWidget(dial, 5, col + j, Qt.AlignHCenter)
                if self.inputs[i][2] > 0:
                    path = "/Mixer/Feature_LRBalance_%d" % self.inputs[i][1]
                    self.Balances[dial] = [path, j + 1]
                # to keep width
                else:
                    dial.setDisabled(True)
Example #22
0
class configWidget(QWidget):

    def __init__(self, parent=None):
        super(configWidget, self).__init__()
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setWindowTitle('LoL Server Status - Config')
        self.setMinimumWidth(parent.width())
        self.move(parent.pos())
        self.setFocus(False)

        #label_title
        label_title = QLabel('Configurations')
        label_title.setObjectName('label_title')
        label_title.setAlignment(Qt.AlignCenter)

        #combo_update_time
        self.combo_update_time = QComboBox()
        for item in ("1 minute", "2 minutes", "5 minutes", "10 minutes",
                     "20 minutes"):
            self.combo_update_time.addItem(item)

        #LAYOUTS
        #layout_update_time
        layout_update_time = QHBoxLayout()
        layout_update_time.addWidget(QLabel('Update time:'))
        layout_update_time.addWidget(self.combo_update_time)

        #General layout
        vbox = QVBoxLayout(self)
        vbox.addWidget(label_title)  # Add label_title
        vbox.addLayout(layout_update_time)  # Add layout_update_time

        self.load_config()

    def save_config(self):
        """This function save settings"""

        qsettings = QSettings()
        qsettings.setValue('configs/update_time',
                           self.combo_update_time.currentIndex())

    def load_config(self):
        """This function load settings"""

        qsettings = QSettings()
        self.combo_update_time.setCurrentIndex(
                    qsettings.value('configs/update_time', 0, type=int))

    def mouseDoubleClickEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.save_config()
            self.close()

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.save_config()
            self.close()
Example #23
0
class DropDownRadioBooleanFilter(QWidget, Control):
    """Container for multiple boolean filters
    """

    def __init__(self, tree, dataset, master, parent=None):
        QWidget.__init__(self, parent)
        Control.__init__(self, tree, dataset, master)

        self.setLayout(QHBoxLayout())
        self.cb = QComboBox(self)

        self.layout().addWidget(self.cb)

        rblayout = QVBoxLayout()
        self.radioButtons = [QRadioButton("Only", self),
                             QRadioButton("Excluded", self)
                             ]

        for b in self.radioButtons:
            rblayout.addWidget(b)

        self.radioButtons[0].setChecked(True)

        self.layout().addLayout(rblayout)

        self.options = []

        self.setOptions(tree.subelements_top("Option"))

    def setOptions(self, options):
        self.cb.clear()
        self.options = []
        for option in options:
            self.cb.addItem(option.displayName)
            self.options.append(option)

        for op, rb in zip(self.options[0].subelements_top("Option"),
                          self.radioButtons):
            rb.setText(op.displayName)
            rb.setChecked(getattr(op, "default", "false") == "true")

    def value(self):
        return {"excluded": "0" if self.radioButtons[0].isChecked() else "1"}

    def query(self):
        filter = self.options[self.cb.currentIndex()]
        filter = biomart.FilterDescription(
            self.tree.registry, "FilterDescription",
            filter.attributes, filter.children)
        return [("Filter", filter, self.value())]

    def setControlValue(self, name, value):
        for i, option in enumerate(self.options):
            if option.internalName == name:
                self.cb.setCurrentIndex(i)
                if value == "Only":
                    self.radioButtons[0].setChecked(True)
Example #24
0
class SelectFriendDialog(ModalDialog):
    def __init__(self, base):
        ModalDialog.__init__(self, 290, 110)
        self.base = base
        self.setWindowTitle(i18n.get('select_friend_to_send_message'))

        self.accounts_combo = QComboBox()
        accounts = self.base.core.get_registered_accounts()
        for account in accounts:
            protocol = get_protocol_from(account.id_)
            icon = QIcon(base.get_image_path('%s.png' % protocol))
            self.accounts_combo.addItem(icon, get_username_from(account.id_), account.id_)

        completer = QCompleter(self.base.load_friends_list())
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.friend = QLineEdit()
        self.friend.setCompleter(completer)
        select_button = QPushButton(i18n.get('select'))
        select_button.clicked.connect(self.__validate)

        friend_caption = "%s (@)" % i18n.get('friend')
        form = QFormLayout()
        form.addRow(friend_caption, self.friend)
        form.addRow(i18n.get('account'), self.accounts_combo)
        form.setContentsMargins(30, 10, 10, 5)
        form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)

        button = QPushButton(i18n.get('search'))
        button_box = QHBoxLayout()
        button_box.addStretch(0)
        button_box.addWidget(select_button)
        button_box.setContentsMargins(0, 0, 15, 15)

        layout = QVBoxLayout()
        layout.addLayout(form)
        layout.addLayout(button_box)
        layout.setSpacing(5)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        #load_button = ImageButton(base, 'action-status-menu.png',
        #        i18n.get('load_friends_list'))

        self.exec_()

    def __validate(self):
        if self.get_username() != '':
            self.accept()


    def get_account(self):
        index = self.accounts_combo.currentIndex()
        return str(self.accounts_combo.itemData(index).toPyObject())

    def get_username(self):
        return str(self.friend.text())
Example #25
0
class CurrentTaskView(QTableView):
    def __init__(self):
        super().__init__()
        self._triggers = []

    def setModel(self, model):
        super().setModel(model)

        current_task = patts.get_active_task()
        if current_task:
            parent_id = current_task[list(current_task.keys())[0]]['typeID']
        else:
            parent_id = '0'

        child_tasks = patts.get_child_types(parent_id)
        self._select_box = QComboBox()

        i = 0
        self._task_map = {}
        for task in child_tasks:
            self._select_box.addItem(child_tasks[task]['displayName'])
            self._task_map[i] = task
            i += 1

        self.setIndexWidget(model.createIndex(0, 0), self._select_box)

        clockInButton = QPushButton(_('TaskTable.clockIn'))
        clockInButton.clicked.connect(self._clock_in)
        self.setIndexWidget(model.createIndex(0, 1), clockInButton)

        if parent_id != '0':
            clockOutButton = QPushButton(_('TaskTable.clockOut'))
            clockOutButton.clicked.connect(self._clock_out)
            self.setIndexWidget(model.createIndex(1, 2), clockOutButton)

        self.resizeColumnsToContents()

    def add_trigger(self, f):
        self._triggers.append(f)

    def _clock_in(self):
        try:
            patts.clockin(self._task_map[self._select_box.currentIndex()])
            for trigger in self._triggers:
                trigger()
        except Exception as e:
            if not (type(e) is KeyError and str(e) == '-1'):
                ExceptionDialog(format_exc()).exec_()

    def _clock_out(self):
        try:
            patts.clockout(list(patts.get_active_task().keys())[0])
            for trigger in self._triggers:
                trigger()
        except:
            ExceptionDialog(format_exc()).exec_()
Example #26
0
class DarkeningLaw(Triplet):

    items = ('Linear', 'linear'), ('Quadratic', 'quadratic'), ('Square root', 'squareroot'), ('Logarithmic', 'logarithmic')

    def __init__(self):
        Triplet.__init__(self, 'Darkening law:', QComboBox(), '', True)

        self.value = QComboBox()
        for item in self.items:
            self.value.addItem(item[0], item[1])
Example #27
0
    def createEditor(self, parent, option, index):
        '''
        Important, otherwise an editor is created if the user clicks in this cell.
        '''
        if index.isValid():
            editor=QComboBox(parent)
            for item in self.items_list:
                editor.addItem(str(item))

        return editor
Example #28
0
class InterfacePage(QWizardPage):
    """
    Allows the user to choose one among networkable interfaces to build a net upon.
    """
    def __init__(self, parent=None):
        QWizardPage.__init__(self, parent)
        self.__make_gui()
        self.__populate()
        self.connect(self.__dropdown, SIGNAL("currentIndexChanged(int)"), self.propagate)

    def __make_gui(self):
        self.setTitle(tr("Network Editor"))
        self.setSubTitle(tr("Select the interface to which you want to add a network"))
        box = QVBoxLayout(self)
        self.__dropdown = QComboBox()
        box.addWidget(self.__dropdown)

    def __candidates(self):
        candidates = list(
            QNetObject.getInstance().netcfg.iterNetworkables()
            )
        candidates.sort()
        return candidates

    def __populate(self):
        candidates = self.__candidates()
        for interface in candidates:
            variant = QVariant(interface)
            self.__dropdown.addItem(interface.fullName(), variant)

    def propagate(self):
        """
        propagate: emits a "changed" SIGNAL with the chosen interface as content
        """
        self.emit(SIGNAL("changed"), self.interface())

    def interface(self):
        """
        returns the currently selected interface
        """
        #QVariant with custom content
        variant = self.__dropdown.itemData(
            self.__dropdown.currentIndex()
            )
        interface = variant.toPyObject()
        return interface

    def setInterface(self, target):
        for index in xrange(self.__dropdown.count()):
            variant = self.__dropdown.itemData(index)
            interface = variant.toPyObject()
            if interface is target:
                break
        self.__dropdown.setCurrentIndex(index)
Example #29
0
class NewSensorgroupPage0(QWizardPage):
    """WizardPage to select sensorgroup name, title and importer"""
    def __init__(self, parent, project):
        QWizardPage.__init__(self, parent)
        self.setTitle(QCoreApplication.translate('DataStorageBrowser',
            'Select name, title and data type'))
        self.project = project
        self.mainLayout = QGridLayout()
        self.setLayout(self.mainLayout)

        nameLabel = QLabel(self)
        nameLabel.setText(QCoreApplication.translate('DataStorageBrowser', 'Name'))
        self.mainLayout.addWidget(nameLabel, 0, 0)
        self.nameInput = QLineEdit(self)
        self.nameInput.setText(uniqueName('unnamed', project.keys()))
        self.registerField('name', self.nameInput, 'text')
        self.mainLayout.addWidget(self.nameInput, 0, 1)

        titleLabel = QLabel(self)
        titleLabel.setText(QCoreApplication.translate('DataStorageBrowser', 'Title'))
        self.mainLayout.addWidget(titleLabel, 1, 0)
        self.titleInput = QLineEdit(self)
        self.titleInput.setText('...')
        self.registerField('title', self.titleInput, 'text')
        self.mainLayout.addWidget(self.titleInput, 1, 1)

        typeLabel = QLabel(self)
        typeLabel.setText(QCoreApplication.translate('DataStorageBrowser', 'Data type'))
        self.mainLayout.addWidget(typeLabel, 2, 0)
        self.typeSelect = QComboBox(self)
        self.typeSelect.addItem('CSV')
        self.typeSelect.addItem('Remus')
        self.registerField('type', self.typeSelect, 'currentText')
        self.mainLayout.addWidget(self.typeSelect, 2, 1)

        self.importFilesButton = QCheckBox(self)
        self.importFilesButton.setChecked(True)
        self.importFilesButton.setText(QCoreApplication.translate('DataStorageBrowser',
            'Import files after creation'))
        self.registerField('importFiles', self.importFilesButton, 'checked')
        self.mainLayout.addWidget(self.importFilesButton, 3, 0, 3, 2)


    def validatePage(self):
        n = str(self.field('name').toString())
        if not n:
            return False
        if n in self.project.keys():
            b = QMessageBox.question(self, QCoreApplication.translate('DataStorageBrowser',
                'Sensorgroup already exists!'), QCoreApplication.translate('DataStorageBrowser',
                'A sensorgroup with this name already exists. Do you really want to overwrite it?'),
                QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
            return b == QMessageBox.Yes
        return True
Example #30
0
 def createEditor(self, parent, option, index):
     # special combobox for field type
     if index.column() == 1:
         cbo = QComboBox(parent)
         cbo.setEditable(True)
         cbo.setAutoCompletion(True)
         cbo.setFrame(False)
         for item in self.fieldTypes:
             cbo.addItem(item)
         return cbo
     return QItemDelegate.createEditor(self, parent, option, index)
Example #31
0
 def _change_2nd_row(self, mi):
     combo = self.IDB.sender()
     row, tbl = combo.itemData(self.other_tbls.index(mi))
     colums = self.db_dict[self.tbl_names[tbl]]['col']
     c_box = QComboBox()
     c_box2 = QComboBox()
     for j, tbl_name in enumerate(colums):
         c_box.addItem(tbl_name, (row, tbl, j))
         c_box2.addItem(tbl_name, (row, tbl, j))
     self.IDB.TWFinalExample.setCellWidget(2, row, c_box2)
     c_box2.currentIndexChanged[str].connect(self._update_joins)
     self.IDB.TWFinalExample.setCellWidget(1, row, c_box)
     self.temp_col = colums
Example #32
0
 def addCutFunc(self):
     self.cutTable.insertRow(self.cutTable.rowCount())
     numRows = self.cutTable.rowCount()
     varNameComboBox = QComboBox()
     cutTypeComboBox = QComboBox()
     operators = ['==', '<', '<=', '>', '>=', '!=']
     for name in self.varNames:
         varNameComboBox.addItem(name)
     for operator in operators:
         cutTypeComboBox.addItem(operator)
     self.cutTable.setCellWidget(numRows - 1, 0, varNameComboBox)
     self.cutTable.setCellWidget(numRows - 1, 1, cutTypeComboBox)
     self.cutTable.setCellWidget(numRows - 1, 3, QCheckBox())
Example #33
0
class OptionsDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)

        self._langs = get_langs()
        self._lang_selection = QComboBox()

        langs = list(self._langs.keys())
        langs.sort()

        i = 0
        lang_index = None
        for lang in langs:
            self._lang_selection.addItem(lang)
            if self._langs[lang] == get('Global', 'lang'):
                lang_index = i

            i += 1

        try:
            self._lang_selection.setCurrentIndex(lang_index)
        except TypeError:
            pass

        langBox = QHBoxLayout()
        langBox.addWidget(QLabel(_('OptionsDialog.lang')))
        langBox.addStretch(1)
        langBox.addWidget(self._lang_selection)

        cancelButton = QPushButton(_('cancel'))
        cancelButton.clicked.connect(self.reject)

        okButton = QPushButton(_('OK'))
        okButton.clicked.connect(self.accept)

        buttonBox = QHBoxLayout()
        buttonBox.addStretch(1)
        buttonBox.addWidget(cancelButton)
        buttonBox.addWidget(okButton)

        layout = QVBoxLayout()
        layout.addLayout(langBox)
        layout.addLayout(buttonBox)

        self.accepted.connect(self._save)

        self.setLayout(layout)
        self.setWindowTitle(_('OptionsDialog.title'))

    def _save(self):
        set_lang(self._langs[self._lang_selection.currentText()])
Example #34
0
def main():
    app = QApplication(sys.argv)

    window = QMainWindow()
    central_widget = QWidget(window)

    start_action = QAction('Start', window)
    stop_action = QAction('Stop', window)
    toolbar = window.addToolBar('Monitor')
    toolbar.addAction(start_action)
    toolbar.addAction(stop_action)

    central_layout = QVBoxLayout(central_widget)

    monitor_name = QLabel(central_widget)
    central_layout.addWidget(monitor_name)

    state_label = QLabel(central_widget)
    central_layout.addWidget(state_label)

    combo_box = QComboBox(central_widget)
    items = [('No keys', AbstractKeyboardMonitor.IGNORE_NO_KEYS),
             ('Modifiers', AbstractKeyboardMonitor.IGNORE_MODIFIER_KEYS),
             ('Modifier combos',
              AbstractKeyboardMonitor.IGNORE_MODIFIER_COMBOS)]
    for label, userdata in items:
        combo_box.addItem(label, userdata)

    def _update_ignore_keys(index):
        monitor.keys_to_ignore = combo_box.itemData(index).toPyObject()

    combo_box.currentIndexChanged[int].connect(_update_ignore_keys)
    central_layout.addWidget(combo_box)

    central_widget.setLayout(central_layout)
    window.setCentralWidget(central_widget)

    monitor = create_keyboard_monitor(window)
    monitor_name.setText('Using monitor class {0}'.format(
        monitor.__class__.__name__))
    monitor.typingStarted.connect(partial(state_label.setText, 'typing'))
    monitor.typingStopped.connect(partial(state_label.setText, 'not typing'))
    start_action.triggered.connect(monitor.start)
    stop_action.triggered.connect(monitor.stop)
    stop_action.setEnabled(False)
    monitor.started.connect(partial(start_action.setEnabled, False))
    monitor.started.connect(partial(stop_action.setEnabled, True))
    monitor.stopped.connect(partial(start_action.setEnabled, True))
    monitor.stopped.connect(partial(stop_action.setEnabled, False))
    window.show()
    app.exec_()
Example #35
0
class DarkeningLaw(Triplet):

    items = ('Linear',
             'linear'), ('Quadratic',
                         'quadratic'), ('Square root',
                                        'squareroot'), ('Logarithmic',
                                                        'logarithmic')

    def __init__(self):
        Triplet.__init__(self, 'Darkening law:', QComboBox(), '', True)

        self.value = QComboBox()
        for item in self.items:
            self.value.addItem(item[0], item[1])
Example #36
0
class Form(QDialog):
    def __init__(self, parent=None):
        super(Form, self).__init__(parent)

        principalLabel = QLabel("Principal:")
        self.principalSpinBox = QDoubleSpinBox()
        self.principalSpinBox.setRange(1, 1000000000)
        self.principalSpinBox.setValue(1000)
        self.principalSpinBox.setPrefix("$ ")
        rateLabel = QLabel("Rate:")
        self.rateSpinBox = QDoubleSpinBox()
        self.rateSpinBox.setRange(1, 100)
        self.rateSpinBox.setValue(5)
        self.rateSpinBox.setSuffix(" %")
        yearsLabel = QLabel("Years:")
        self.yearsComboBox = QComboBox()
        self.yearsComboBox.addItem("1 year")
        self.yearsComboBox.addItems(
            ["{0} years".format(x) for x in range(2, 26)])
        amountLabel = QLabel("Amount")
        self.amountLabel = QLabel()

        grid = QGridLayout()
        grid.addWidget(principalLabel, 0, 0)
        grid.addWidget(self.principalSpinBox, 0, 1)
        grid.addWidget(rateLabel, 1, 0)
        grid.addWidget(self.rateSpinBox, 1, 1)
        grid.addWidget(yearsLabel, 2, 0)
        grid.addWidget(self.yearsComboBox, 2, 1)
        grid.addWidget(amountLabel, 3, 0)
        grid.addWidget(self.amountLabel, 3, 1)
        self.setLayout(grid)

        self.connect(self.principalSpinBox, SIGNAL("valueChanged(double)"),
                     self.updateUi)
        self.connect(self.rateSpinBox, SIGNAL("valueChanged(double)"),
                     self.updateUi)
        self.connect(self.yearsComboBox, SIGNAL("currentIndexChanged(int)"),
                     self.updateUi)

        self.setWindowTitle("Interest")
        self.updateUi()

    def updateUi(self):
        """Calculates compound interest"""
        principal = self.principalSpinBox.value()
        rate = self.rateSpinBox.value()
        years = self.yearsComboBox.currentIndex() + 1
        amount = principal * ((1 + (rate / 100.0))**years)
        self.amountLabel.setText("$ {0:.2f}".format(amount))
Example #37
0
class PartyForeignKeyMapper(ForeignKeyMapper):
    """
    ForeignKeyMapper wrapper class for party entity.
    """

    def __init__(self, *args, **kwargs):
        """
        Initializes PartyForeignKeyMapper.
        :param args:
        :type args:
        :param kwargs:
        :type kwargs:
        """
        super(PartyForeignKeyMapper, self).__init__(*args, **kwargs)
        self.init_party_entity_combo()

    def init_party_entity_combo(self):
        """
        Creates the party entity combobox.
        """
        self.entity_combo_label = QLabel()
        combo_text = QApplication.translate(
            'PartyForeignKeyMapper', 'Select a party entity'
        )
        self.entity_combo_label.setText(combo_text)

        self.entity_combo = QComboBox()
        self.spacer_item = QSpacerItem(
            288,
            20,
            QSizePolicy.Expanding,
            QSizePolicy.Minimum
        )
        self.grid_layout.addItem(self.spacer_item, 0, 4, 1, 1)

        self.grid_layout.addWidget(self.entity_combo_label, 0, 5, 1, 1)
        self.grid_layout.addWidget(self.entity_combo, 0, 6, 1, 1)

        self.populate_parties()

    def populate_parties(self):
        """
        Populates the party entities in the entities combobox.
        """
        self.parties = current_profile().social_tenure.parties

        for entity in self.parties:
            self.entity_combo.addItem(
                entity.short_name, entity.name
            )
Example #38
0
 def plotSettingsPage(self):
     page = QWidget()
     layout = QGridLayout()
     page.setLayout(layout)
     index = 0
     for key, values in self.plotFieldMap.iteritems():
         label = QLabel(key, page)
         combo = QComboBox(page)
         for value in values:
             combo.addItem(value)
         layout.addWidget(label, index, 0, Qt.Qt.AlignRight)
         layout.addWidget(combo, index, 1, Qt.Qt.AlignLeft)
         index += 1
     return page
Example #39
0
    def createEditor(self, parent, option, index):
        # Create combobox editor for sort order column
        if index.column() == self._sort_cold_idx:
            combo = QComboBox(parent)
            for enum, txt in SORT_ORDER_NAME.iteritems():
                combo.addItem(txt, enum)

            return combo
        else:
            return QStyledItemDelegate.createEditor(
                self,
                parent,
                option,
                index
            )
Example #40
0
class SizeRequest(Request):
    def __init__(self, parent):
        Request.__init__(self, parent)
        self.setOperators()
        self.setContent()
        self.setSizeType()

    def setOperators(self):
        self.operatorCombo = OperatorCombo(self)
        self.hlayout.addWidget(self.operatorCombo)
        self.connect(self.operatorCombo, SIGNAL("currentIndexChanged ( int )"),
                     self.updateQuery)
        self.connect(self.operatorCombo,
                     SIGNAL("currentIndexChanged ( const QString &)"),
                     self.updateQuery)

    def updateQuery(self, data):
        self.emit(SIGNAL("queryUpdated"))

    def setContent(self):
        self.content = QLineEdit(self)
        self.validator = QIntValidator(0, 2147483647, self)
        self.content.setValidator(self.validator)
        self.hlayout.addWidget(self.content)
        self.connect(self.content, SIGNAL("textChanged(const QString &)"),
                     self.updateQuery)
        self.connect(self.content, SIGNAL("textEdited(const QString &)"),
                     self.updateQuery)

    def setSizeType(self):
        self.stype = QComboBox(self)
        self.stype.addItem(QString("KB"))
        self.stype.addItem(QString("MB"))
        self.stype.addItem(QString("GB"))
        self.hlayout.addWidget(self.stype)
        self.connect(self.stype, SIGNAL("currentIndexChanged ( int )"),
                     self.updateQuery)
        self.connect(self.stype,
                     SIGNAL("currentIndexChanged ( const QString &)"),
                     self.updateQuery)

    def request(self):
        operator = str(self.operatorCombo.currentText())
        factor = SIZE_T[self.stype.currentIndex()]
        size = self.content.text().toULongLong()[0]
        size = size * factor
        res = "(size " + operator + " " + str(size) + ")"
        return res
Example #41
0
 def addSinglePath(self, key, predefs, editable=False, config=None):
     if config:
         predefs.push_front(config[0])
     if not self.overwriteKeys(key) and type(key).__name__ == 'str':
         vbox = QVBoxLayout()
         layout = QHBoxLayout()
         pathcontainer = ComboItem(self)
         self.connect(pathcontainer, SIGNAL("editTextChanged(QString)"),
                      self.argumentChanged)
         self.connect(pathcontainer, SIGNAL("currentIndexChanged(QString)"),
                      self.argumentChanged)
         if len(predefs) > 0:
             if config:
                 for value in predefs:
                     val = value.value()
                     name = val.path
                     pathcontainer.addSingleItem(name)
             else:
                 category = self.tr("Predefined parameters")
                 pathcontainer.setEditable(editable)
                 pathcontainer.addParentItem(category)
                 for value in predefs:
                     val = value.value()
                     name = val.path
                     pathcontainer.addChildItem(name)
         combo = QComboBox()
         browse = PathSelectionButton(self,
                                      key,
                                      pathcontainer,
                                      inputchoice=combo)
         self.connect(combo, SIGNAL("editTextChanged(QString)"),
                      self.argumentChanged)
         self.connect(combo, SIGNAL("currentIndexChanged(QString)"),
                      self.argumentChanged)
         combo.addItem(self.inputFile)
         combo.addItem(self.inputDirectory)
         vbox.addWidget(combo)
         layout.addWidget(pathcontainer, 2)
         layout.addWidget(browse, 0)
         vbox.addLayout(layout)
         if not self.displaykey:
             self.layout.addRow(vbox)
         else:
             self.layout.addRow(key, vbox)
         self.widgets[key] = pathcontainer
         return 1
     else:
         return -1
Example #42
0
 def add_combo_box( self, choicesL, index_init=0, name='cycle_desc',
                     advance_n=True, fulldesc='Select Engine Cycle', 
                     text_align='right', text_font=ARIAL_10, col=0, width=100,
                     parent=None, layout=None):
                    
     # if parent is input, add widget to parent
     if parent is None:
         parent = self
     
     
     if layout is None:
         NRow = parent.get_next_row_number(advance_n)
     
     lbl = QLabel("    %s "%fulldesc, parent)
     combo_box = QComboBox(parent)    
     lbl.setFont( text_font )
     combo_box.setFont( text_font )
     
     self.objectD['%s_combo_box'%name] = combo_box
     for choice in choicesL:
         combo_box.addItem(choice)
     combo_box.setCurrentIndex(index_init)
     if layout is None:
         parent.grid.addWidget(lbl,      NRow, col)
     else:
         layout.addWidget( lbl )
     
     
         
     hbox = QHBoxLayout()
     hbox.addWidget(combo_box)
     hbox.addStretch(1)
     widget = QWidget()
     widget.setLayout(hbox)
     
     if layout is None:
         parent.grid.addWidget(widget, NRow, col+1)
     
         if text_align=='right':
             parent.grid.setAlignment(lbl, Qt.AlignRight )
     else:
         layout.addWidget( widget )
     
     combo_box.setFixedWidth( width )
         
     combo_box.activated[str].connect( lambda: self.combo_box_changed( '%s_combo_box'%name ) )   
         
     self.input_widget_by_nameD[name] = (combo_box, 'combo_box')
Example #43
0
    def addPathList(self, key, typeid, predefs, selectednodes):
        if not self.overwriteKeys(key) and type(key).__name__=='str':
            layout = QVBoxLayout()
            listpathcontainer = QListWidget() ##XXX
            listpathcontainer.setDragDropMode(QAbstractItemView.InternalMove)
            if len(predefs) > 0:
                if not self.checkUnifiedTypes(predefs):
                    return -1
                for predef in predefs:
                    listpathcontainer.insertItem(listpathcontainer.count() + 1, str(predef))
            if selectednodes and len(selectednodes) > 0:
                for node in selectednodes:
		   if type(node) == Node and typeid == typeId.Node:
                        listpathcontainer.insertItem(listpathcontainer.count() + 1, QString.fromUtf8(node.absolute())) 
		   elif type(node) != Node:
			listpathcontainer.insertItem(listpathcontainer.count() + 1, node)
            hbox = QHBoxLayout()
            buttonbox = QDialogButtonBox()
            if typeid == typeId.Path:
                combo = QComboBox()
	        self.connect(combo, SIGNAL("editTextChanged(QString)"), self.argumentChanged)
		self.connect(combo, SIGNAL("currentIndexChanged(QString)"), self.argumentChanged)
                combo.addItem(self.inputFile)
                combo.addItem(self.inputDirectory)
                add = addLocalPathButton(self, key, listpathcontainer, combo)
            else:
                add = addLocalPathButton(self, key, listpathcontainer, nodetype=True)
            buttonbox.addButton(add, QDialogButtonBox.ActionRole)
            rm = rmLocalPathButton(self, listpathcontainer)
            buttonbox.addButton(rm, QDialogButtonBox.ActionRole)

            self.connect(add, SIGNAL("clicked()"), self.argumentChanged)
            self.connect(rm, SIGNAL("clicked()"), self.argumentChanged)

            hbox.addWidget(buttonbox, 3, Qt.AlignLeft)
            if typeid == typeId.Path:
                hbox.addWidget(combo, 1, Qt.AlignRight)
            layout.addLayout(hbox, 0)
            layout.addWidget(listpathcontainer, 2)

            if not self.displaykey:
                self.layout.addRow(layout)
            else:
                self.layout.addRow(key, layout)
            self.widgets[key] = listpathcontainer
            return 1
        else:
            return -1
Example #44
0
 def __init__(self, parent, text, choices=None, option=None, tip=None):
     super(MyComboBox, self).__init__(parent)
     """choices: couples (name, key)"""
     label = QLabel(text)
     combobox = QComboBox(parent)
     if tip is not None:
         combobox.setToolTip(tip)
     if choices:
         for name, key in choices:
             combobox.addItem(name, QVariant(key))
     layout = QHBoxLayout()
     for subwidget in (label, combobox):
         layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
     self.box = combobox
Example #45
0
    def createAnimationBox(self):
        animationComboBox = QComboBox()

        animationComboBox.addItem("No Animations", QChart.NoAnimation)
        animationComboBox.addItem("GridAxis Animations",
                                  QChart.GridAxisAnimations)
        animationComboBox.addItem("Series Animations", QChart.SeriesAnimations)
        animationComboBox.addItem("All Animations", QChart.AllAnimations)

        return animationComboBox
Example #46
0
class DropDownIdListFilter(QWidget, Control):

    """Container for multiple id list filters
    """

    def __init__(self, tree, dataset, master, parent=None):
        QWidget.__init__(self, parent)
        Control.__init__(self, tree, dataset, master)

        self.setLayout(QVBoxLayout())
        self.setContentsMargins(0, 0, 0, 0)
        self.cb = QComboBox()
        self.idsEdit = QPlainTextEdit()

        self.layout().addWidget(self.cb)
        self.layout().addWidget(self.idsEdit)

        self.options = []
        self.setOptions(tree.subelements_top("Option"))

    def setOptions(self, options):
        self.cb.clear()
        self.options = []
        for option in options:
            self.cb.addItem(option.displayName)
            self.options.append(option)

    def value(self):
        return str(self.idsEdit.toPlainText()).split()

    def query(self):
        filter = self.options[self.cb.currentIndex()]
        filter = biomart.FilterDescription(
            self.tree.registry, "FilterDescription",
            filter.attributes, filter.children)
        return [("Filter", filter, self.value())]

    def setControlValue(self, name, value):
        if isinstance(value, list):
            value = "\n".join(value)

        for i, op in enumerate(self.options):
            if name == op.internalName:
                self.cb.setCurrentIndex(i)
                self.idsEdit.setPlainText(value)
Example #47
0
    def addPath(self, key, typeid, predefs, selectednodes, editable=False, config=None):
        if config:
	  predefs.push_front(config[0]) 
        if not self.overwriteKeys(key) and type(key).__name__=='str':
            vbox = QVBoxLayout()
            if typeid == typeId.Path:
                combo = QComboBox()
	        self.connect(combo, SIGNAL("editTextChanged(QString)"), self.argumentChanged)
		self.connect(combo, SIGNAL("currentIndexChanged(QString)"), self.argumentChanged)
                combo.addItem(self.inputFile)
                combo.addItem(self.inputDirectory)
                vbox.addWidget(combo)
            layout = QHBoxLayout()
            if len(predefs) > 0 or len(selectednodes) > 0:
                pathcontainer = QComboBox()
	        self.connect(pathcontainer, SIGNAL("editTextChanged(QString)"), self.argumentChanged)
		self.connect(pathcontainer, SIGNAL("currentIndexChanged(QString)"), self.argumentChanged)
                pathcontainer.setEditable(editable)
                for value in predefs:
                    if typeid == typeId.Node:
                        pathcontainer.addItem(value.value().name())
                    else:
                        pathcontainer.addItem(value.toString())
                if typeid == typeId.Node:
                    for node in selectednodes:
                        pathcontainer.addItem(QString.fromUtf8(node.absolute()))
            else:
                pathcontainer = QLineEdit()
                pathcontainer.setReadOnly(not editable)
		self.connect(pathcontainer, SIGNAL("editingFinished()"), self.argumentChanged)
            if typeid == typeId.Path:
                browse = addLocalPathButton(self, key, pathcontainer, inputchoice=combo)
            else:
                browse = addLocalPathButton(self, key, pathcontainer, nodetype=True)
            layout.addWidget(pathcontainer, 2)
            layout.addWidget(browse, 0)
            vbox.addLayout(layout)
            if not self.displaykey:
                self.layout.addRow(vbox)
            else:
                self.layout.addRow(key, vbox)
            self.widgets[key] = pathcontainer
            return 1
        else:
            return -1
Example #48
0
class OIMainToolbar(QWidget):
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.setMaximumHeight(35)
        self.setMinimumHeight(35)
        self.__layout = QGridLayout(self)
        self.__mode_box = None
        self.init_gui()

    def init_gui(self):
        self.__layout.setMargin(0)

        self.__mode_box = QComboBox(self)
        self.__mode_box.addItem('Logic')
        self.__mode_box.addItem('GUI')
        # self.__mode_box.setMaximumWidth(100)

        self.__layout.addWidget(self.__mode_box, 0, 0)
Example #49
0
 def create_combobox(self, text, choices, option, tip=None):
     """choices: couples (name, key)"""
     label = QLabel(text)
     combobox = QComboBox()
     if tip is not None:
         combobox.setToolTip(tip)
     for name, key in choices:
         combobox.addItem(name, QVariant(key))
     self.comboboxes[combobox] = option
     layout = QHBoxLayout()
     for subwidget in (label, combobox):
         layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     widget.box = combobox
     return widget
class LabelControlItems(QWidget):
    def __init__(self):
        super(LabelControlItems, self).__init__()
        
        nlabels = 5
        
        self.combobox_labels = QComboBox()
        self.label_label = QLabel("Label: ")
        self.label_text = QLabel("Text: ")
        self.text_label = QLineEdit("Label1")
        self.button_label = QPushButton("On/Off")
        
        self.scale_labelsize = QSlider(Qt.Horizontal)
        self.label_labelsize = QLabel("Label Size")
        self.scale_labelsize.setMinimum(1)
        self.scale_labelsize.setValue(20)
        
        self.button_label.setCheckable(True)
        
        for i in range(nlabels):
            self.combobox_labels.addItem("Label"+str(i+1))
            
        layout = QGridLayout()
        
        layout.addWidget(self.label_label,0,0)
        layout.addWidget(self.combobox_labels,1,0)
        layout.addWidget(self.label_text,0,1)
        layout.addWidget(self.text_label,1,1)
        layout.addWidget(self.button_label,1,2)

        layout.addWidget(self.label_labelsize,0,3)
        layout.addWidget(self.scale_labelsize,1,3)        


            
        
            
        for col, stretch in enumerate((5,5,5,5)):
            layout.setColumnStretch(col, stretch)            
        
        layout.setMargin(5)
        layout.setHorizontalSpacing(5)       
        layout.setVerticalSpacing(0)                  
        self.setLayout(layout)
Example #51
0
class DisplayContainer(QWidget, DisplayContainerGeneric):
    def __init__(self, main):
        QWidget.__init__(self)
        DisplayContainerGeneric.__init__(self)
        self._main = main
        vbox = QVBoxLayout(self)
        self.stack = StackedWidget()

        vbox.addWidget(self.stack)
        self._console = ConsoleWidget()
        self.stack.addWidget(self._console)

        self.runWidget = RunWidget()
        self.stack.addWidget(self.runWidget)

        self.web = WebRender()
        self.stack.addWidget(self.web)

        self.combo = QComboBox()
        self.combo.addItem(QIcon(resources.images['console']), '')
        self.combo.addItem(QIcon(resources.images['play']), '')
        self.combo.addItem(QIcon(resources.images['web']), '')
        self.connect(self.combo, SIGNAL("currentIndexChanged(int)"),
                     self._item_changed)

    def gain_focus(self):
        self._console.setFocus()

    @pyqtSignature('int')
    def _item_changed(self, val):
        if not self.isVisible():
            self._main.containerIsVisible = True
            self.show()
        self.stack.show_display(val)

    def load_toolbar(self, toolbar):
        toolbar.addSeparator()
        toolbar.addWidget(self.combo)

    def run_application(self, fileName, pythonPath=False):
        self.combo.setCurrentIndex(1)
        self.runWidget.start_process(fileName, pythonPath)

    def kill_application(self):
        self.runWidget.kill_process()

    def render_web_page(self, url):
        self.combo.setCurrentIndex(2)
        self.web.render_page(url)

    def add_to_stack(self, widget, icon):
        self.stack.addWidget(widget)
        self.combo.addItem(QIcon(icon), '')
Example #52
0
    def createEditor(self, parent, option, index):
        """
        Create the editor

        @param parent: 
        @type parent:

        @param option: 
        @type option:

        @param index: 
        @type index:

        @return:
        @rtype:
        """
        value = self.getValue(index)
        if index.column() == COL_VALUE:
            editor = QComboBox(parent)
            editor.activated.connect(self.onItemActivated)
            editor.addItem(value)
            editor.insertSeparator(1)

            # get running agents from context
            runningAgents = ServerAgents.instance().getRunningAgents()
            runningAgents = sorted(
                runningAgents)  # sort agents list, new in v12.2

            for i in xrange(len(runningAgents)):
                if len(runningAgents[i]) == 0:
                    editor.insertSeparator(i + 2)
                else:
                    editor.addItem(runningAgents[i])
            editor.insertSeparator(len(runningAgents) + 2)

            # add alias
            params = []
            for pr in self.parent.model.getData():
                params.append(pr['name'])
            editor.addItems(params)

            return editor
        return QItemDelegate.createEditor(self, parent, option, index)
    def _getCombobox(self,
                     values,
                     primary_selected_value=None,
                     secondary_selected_value=None,
                     currentindex_changed_callback=None):
        '''
        Get a combobox filled with the given values
        
        :param values: The values as key = value, value = description or text
        :type values: Dict
        
        :returns: A combobox
        :rtype: QWidget
        '''

        widget = QWidget()
        combobox = QComboBox()
        layout = QHBoxLayout(widget)
        layout.addWidget(combobox, 1)
        layout.setAlignment(Qt.AlignCenter)
        layout.setContentsMargins(5, 0, 5, 0)
        widget.setLayout(layout)

        current_item_index = 0
        selected_index = 0

        for key, value in values.iteritems():
            combobox.addItem(value, key)

            # Select value
            if key == secondary_selected_value and selected_index == 0:
                selected_index = current_item_index
            if key == primary_selected_value:
                selected_index = current_item_index

            current_item_index += 1

        combobox.setCurrentIndex(selected_index)

        if currentindex_changed_callback is not None:
            combobox.currentIndexChanged.connect(currentindex_changed_callback)

        return widget
Example #54
0
    def createEditor(self, parent):
        """ Returns the correctly initialized editor for the item value. 
        
        @param parent: Parent widget of the created editor widget.
        @type parent: L{QWidget<PyQt4.QtGui.QWidget>}
        
        @return: Currently a combination box.
        @rtype: L{QComboBox<PyQt4.QtGui.QComboBox>}
        """

        editor = QComboBox(parent)
        currentName = unicode(self.text())
        index = 0
        for number, level in enumerate(self.accessLevels):
            editor.addItem(level.displayName)
            if level.displayName == currentName:
                index = number
        editor.setCurrentIndex(index)
        editor.setEditable(False)
        return editor
Example #55
0
class RecentPathsWComboMixin(RecentPathsWidgetMixin):
    """
    Adds file combo handling to :obj:`RecentPathsWidgetMixin`.

    The mixin constructs a combo box `self.file_combo` and provides a method
    `set_file_list` for updating its content. The mixin also overloads the
    inherited `add_path` and `select_file` to call `set_file_list`.
    """
    def __init__(self):
        super().__init__()
        self.file_combo = \
            QComboBox(self, sizeAdjustPolicy=QComboBox.AdjustToContents)

    def add_path(self, filename):
        """Add (or move) a file name to the top of recent paths"""
        super().add_path(filename)
        self.set_file_list()

    def select_file(self, n):
        """Move the n-th file to the top of the list"""
        super().select_file(n)
        self.set_file_list()

    def set_file_list(self):
        """
        Sets the items in the file list combo
        """
        self._check_init()
        self.file_combo.clear()
        if not self.recent_paths:
            self.file_combo.addItem("(none)")
            self.file_combo.model().item(0).setEnabled(False)
        else:
            for i, recent in enumerate(self.recent_paths):
                self.file_combo.addItem(recent.basename)
                self.file_combo.model().item(i).setToolTip(recent.abspath)

    def workflowEnvChanged(self, key, value, oldvalue):
        super().workflowEnvChanged(key, value, oldvalue)
        if key == "basedir":
            self.set_file_list()
Example #56
0
class QuickWatch(QToolBar):
    def __init__(self, parent, distributedObjects):
        QToolBar.__init__(self, "QuickWatch")
        self.config = QuickWatchConfig()
        distributedObjects.configStore.registerConfigSet(self.config)

        self.setObjectName("QuickWatch")
        parent.addToolBar(self)
        self.watchedit = QComboBox()
        self.watchedit.setFixedHeight(28)
        self.watchedit.setInsertPolicy(QComboBox.NoInsert)
        self.watchedit.setEditable(True)
        self.watchedit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.addWidget(self.watchedit)
        self.distributedObjects = distributedObjects
        self.addAction(Icons.watch, "Add to Watch", self.addToWatch)
        self.addAction(Icons.datagraph, "Add to Data Graph", self.addToDG)
        self.watchedit.lineEdit().returnPressed.connect(self.returnPressed)

    def __addCurrentText(self):
        text = self.watchedit.lineEdit().text()
        idx = self.watchedit.findText(text)
        if idx == -1:
            self.watchedit.addItem(text)
        self.watchedit.setEditText("")

    def returnPressed(self):
        if self.config.addTo.value == "Watch View":
            self.addToWatch()
        elif self.config.addTo.value == "Data Graph View":
            self.addToDG()

    def addToWatch(self):
        self.distributedObjects.watchModel.addVar(
            self.watchedit.lineEdit().text())
        self.__addCurrentText()

    def addToDG(self):
        self.distributedObjects.datagraphController.addWatch(
            self.watchedit.lineEdit().text())
        self.__addCurrentText()
Example #57
0
    def __init__(self, parent, configuration):
        QTableWidget.__init__(self, 5, 1, parent)
        self._configuration = configuration
        self._manual_change = True
        self.setVerticalHeaderLabels([
            "Duration (cycles)", "Duration (ms)", "Cycles / ms",
            'RAM access time', 'Execution Time Model'
        ])
        self.horizontalHeader().setStretchLastSection(True)
        self.horizontalHeader().hide()
        self.setItem(0, 0, QTableWidgetItem(str(configuration.duration)))
        self.setItem(
            1, 0,
            QTableWidgetItem(
                str(
                    float(configuration.duration) /
                    configuration.cycles_per_ms)))
        self.setItem(2, 0, QTableWidgetItem(str(configuration.cycles_per_ms)))
        self.setItem(3, 0,
                     QTableWidgetItem(str(configuration.memory_access_time)))

        item = QComboBox(self)
        selected = 0
        for i, (etm_name, etm_code) in \
                enumerate(execution_time_model_names.items()):
            item.addItem(etm_name)
            if etm_code == configuration.etm:
                selected = i
        item.setCurrentIndex(selected)
        self.setCellWidget(4, 0, item)

        def activation_handler(x):
            configuration.etm = execution_time_model_names[str(x)]
            configuration.conf_changed()

        item.activated['QString'].connect(activation_handler)

        #        self._update_observe_window()

        self.cellChanged.connect(self._cell_changed)
Example #58
0
 def setRockPropertyType(self):
     c_Row = self.dlg.bedRockSetTable.currentRow()
     box = self.dlg.bedRockSetTable.cellWidget(c_Row, 0)
     if box.currentIndex() == 0:
         self.dlg.bedRockSetTable.setItem(
             c_Row, 1, QTableWidgetItem('d_cover'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 2, QTableWidgetItem('K_h'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 3, QTableWidgetItem('TAU_cri'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 4, QTableWidgetItem('K_a'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 5, QTableWidgetItem('Young'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 6, QTableWidgetItem('Tensile'))
         if self.dlg.bedRockSetTable.cellWidget(c_Row+1, 5):
             self.dlg.bedRockSetTable.removeCellWidget(c_Row+1, 5)
             self.dlg.bedRockSetTable.setItem(
                 c_Row+1, 5, QTableWidgetItem(u''))
     elif box.currentIndex() == 1:
         self.dlg.bedRockSetTable.setItem(
             c_Row, 1, QTableWidgetItem('d_cover'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 2, QTableWidgetItem('E_h'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 3, QTableWidgetItem('Alpha'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 4, QTableWidgetItem('Beta'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 5, QTableWidgetItem('kh'))
         self.dlg.bedRockSetTable.setItem(
             c_Row, 6, QTableWidgetItem(''))
         KhSelector = QComboBox()
         KhSelector.setEditable(True)
         KhSelector.addItem(u'')
         KhSelector.addItem('Use File')
         KhSelector.currentIndexChanged.connect(self.useKhFile)
         self.dlg.bedRockSetTable.setCellWidget(c_Row+1, 5, KhSelector)
         self.dlg.bedRockSetTable.setItem(c_Row+1, 6, QTableWidgetItem(''))
Example #59
0
    def __init__(self):
        super(ActionBar, self).__init__()
        self.setObjectName("actionbar")
        hbox = QHBoxLayout(self)
        hbox.setContentsMargins(1, 1, 1, 1)

        combo = QComboBox()
        combo.setObjectName("combotab")
        hbox.addWidget(combo)
        combo.addItem("main_container.py")
        combo.addItem("ide.py")
        combo.addItem("editor.py")

        self.lbl_checks = QLabel('')
        self.lbl_checks.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        hbox.addWidget(self.lbl_checks)

        self._pos_text = "Ln: %d, Col: %d"
        self.lbl_position = QLabel(self._pos_text % (0, 0))
        self.lbl_position.setObjectName("position")
        self.lbl_position.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        hbox.addWidget(self.lbl_position)

        self.btn_close = QPushButton(
            self.style().standardIcon(QStyle.SP_DialogCloseButton), '')
        self.btn_close.setObjectName('navigation_button')
        self.btn_close.setToolTip(translations.TR_CLOSE_SPLIT)
        self.btn_close.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        hbox.addWidget(self.btn_close)
Example #60
0
class FormComboWidget(QWidget):
    def __init__(self, datalist, comment="", parent=None):
        super(FormComboWidget, self).__init__(parent)
        layout = QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QComboBox()
        layout.addWidget(self.combobox)
        
        self.stackwidget = QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        self.connect(self.combobox, SIGNAL("currentIndexChanged(int)"),
                     self.stackwidget, SLOT("setCurrentIndex(int)"))
        
        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append(widget)

    def get(self):
        return [ widget.get() for widget in self.widgetlist]