示例#1
0
文件: qtctis.py 项目: xyt556/argos
    def __init__(self, nodeName, defaultFamily='Helvetica'):
        """ Constructor.

            :param defaultFamily: A string representing the defaultValue.
            :editable: True if the underlying QFontComboBox is editable. The default is False as
                it does not work well with the FontCti.

            For the (other) parameters see the AbstractCti constructor documentation.
        """
        check_is_a_string(defaultFamily)

        # Get a list of of configValues by reading them from a temporary QFontComboBox.
        tempFontComboBox = QtWidgets.QFontComboBox()
        configValues = []
        defaultData = 0
        for idx in range(tempFontComboBox.count()):
            fontFamily = tempFontComboBox.itemText(idx)
            configValues.append(fontFamily)
            if fontFamily.lower() == defaultFamily.lower():
                defaultData = idx

        # Set after self._displayValues are defined. The parent constructor calls _enforceDataType
        super(FontChoiceCti, self).__init__(nodeName,
                                            defaultData,
                                            configValues=configValues)
示例#2
0
文件: qtctis.py 项目: whigg/argos
    def __init__(self, cti, delegate, parent=None):
        """ See the AbstractCtiEditor for more info on the parameters
        """
        super(FontChoiceCtiEditor, self).__init__(cti, delegate, parent=parent)

        comboBox = QtWidgets.QFontComboBox()
        # The QFontCombobox is not editable. because an non-existing value resulted in a QFont()
        # without parameter whose font family was probably some style sheet value. This didn't
        # work well with the extra options of the automatic configValue generation and with the
        # a possible parent FontCti: a non-exisiting family yields a QFont() with a non-existing
        # family, proably a style-sheet name, which I don't know how to handle.
        comboBox.setEditable(False)

        # The current font family is not properly selected when the combobox is created (at least
        # on OS-X). Setting the setMaxVisibleItems didn't help.
        # http://stackoverflow.com/questions/11252299/pyqt-qcombobox-setting-number-of-visible-items-in-dropdown
        # comboBox.setMaxVisibleItems(15)
        # comboBox.setStyleSheet("QComboBox { combobox-popup: 0; }");

        comboBox.activated.connect(self.comboBoxActivated)
        self.comboBox = self.addSubEditor(comboBox, isFocusProxy=True)