Beispiel #1
0
    def paletteSelected(self):
        if not self.schemaCombo.count():
            return
        self.selectedSchemaIndex = self.schemaCombo.currentIndex()

        # if we selected "Save current palette as..." option then add another option to the list
        if self.selectedSchemaIndex == self.schemaCombo.count() - 1:
            message = "Please enter a name for the current color settings.\nPressing 'Cancel' will cancel your changes and close the dialog."
            ok = 0
            while not ok:
                text, ok = QInputDialog.getText(self, "Name Your Color Settings", message)
                if (ok):
                    newName = str(text)
                    oldNames = [str(self.schemaCombo.itemText(i)).lower() for i in range(self.schemaCombo.count() - 1)]
                    if newName.lower() == "default":
                        ok = False
                        message = "The 'Default' settings cannot be changed. Please enter a different name:"
                    elif newName.lower() in oldNames:
                        index = oldNames.index(newName.lower())
                        self.colorSchemas.pop(index)

                    if ok:
                        self.colorSchemas.insert(0, (newName, self.getCurrentState()))
                        self.schemaCombo.insertItem(0, newName)
                        self.schemaCombo.setCurrentIndex(0)
                        self.selectedSchemaIndex = 0
                else:
                    ok = 1
                    state = self.getCurrentState()  # if we pressed cancel we have to select a different item than the "Save current palette as..."
                    self.selectedSchemaIndex = 0
                    self.schemaCombo.setCurrentIndex(0)
                    self.setCurrentState(state)
        else:
            schema = self.colorSchemas[self.selectedSchemaIndex][1]
            self.setCurrentState(schema)
    def paletteSelected(self):
        if not self.schemaCombo.count():
            return
        self.selectedSchemaIndex = self.schemaCombo.currentIndex()

        # if we selected "Save current palette as..." option then add another option to the list
        if self.selectedSchemaIndex == self.schemaCombo.count() - 1:
            message = "Please enter a name for the current color settings.\nPressing 'Cancel' will cancel your changes and close the dialog."
            ok = 0
            while not ok:
                text, ok = QInputDialog.getText(self, "Name Your Color Settings", message)
                if (ok):
                    newName = str(text)
                    oldNames = [str(self.schemaCombo.itemText(i)).lower() for i in range(self.schemaCombo.count() - 1)]
                    if newName.lower() == "default":
                        ok = False
                        message = "The 'Default' settings cannot be changed. Please enter a different name:"
                    elif newName.lower() in oldNames:
                        index = oldNames.index(newName.lower())
                        self.colorSchemas.pop(index)

                    if ok:
                        self.colorSchemas.insert(0, (newName, self.getCurrentState()))
                        self.schemaCombo.insertItem(0, newName)
                        self.schemaCombo.setCurrentIndex(0)
                        self.selectedSchemaIndex = 0
                else:
                    ok = 1
                    state = self.getCurrentState()  # if we pressed cancel we have to select a different item than the "Save current palette as..."
                    self.selectedSchemaIndex = 0
                    self.schemaCombo.setCurrentIndex(0)
                    self.setCurrentState(state)
        else:
            schema = self.colorSchemas[self.selectedSchemaIndex][1]
            self.setCurrentState(schema)
Beispiel #3
0
	def __add_behavior(self):
		"""
		Add a behavior to the already existing ones.
		"""
		cb = self._ui.comboBox
		text, ok = QInputDialog.getText(
			self, 'Add behavior', 'Description:', text='')
		if ok:
			self.behavior = str(text)
			self.behaviors.append(self.behavior)
			self._ui.comboBox.addItem(self.behavior)
			cb.setCurrentIndex(cb.findText(self.behavior))

		# If adding the first item, we need to enable the comboBox and
		# remove the placeholder text
		if not cb.isEnabled():
			cb.removeItem(cb.findText(self._default_comboBox_text))
			cb.setEnabled(True)
Beispiel #4
0
    def paletteSelected(self):
        if not self.schemaCombo.count():
            return
        self.selectedSchemaIndex = self.schemaCombo.currentIndex()

        # if we selected "Save current palette as..." option then add another option to the list
        if self.selectedSchemaIndex == self.schemaCombo.count() - 1:
            message = "命名当前颜色设置\n" \
                      "按“取消”将取消更改并关闭对话框。"
            ok = 0
            while not ok:
                text, ok = QInputDialog.getText(self, "命名颜色设置", message)
                if (ok):
                    newName = str(text)
                    oldNames = [str(self.schemaCombo.itemText(i)).lower()
                                for i in range(self.schemaCombo.count() - 1)]
                    if newName.lower() == "default":
                        ok = False
                        message = "无法更改'默认'设置。" \
                                  "输入其他名称:"
                    elif newName.lower() in oldNames:
                        index = oldNames.index(newName.lower())
                        self.colorSchemas.pop(index)

                    if ok:
                        self.colorSchemas.insert(0, (newName, self.getCurrentState()))
                        self.schemaCombo.insertItem(0, newName)
                        self.schemaCombo.setCurrentIndex(0)
                        self.selectedSchemaIndex = 0
                else:
                    ok = 1
                    # if we pressed cancel we have to select a different item
                    # then the "Save current palette as..."
                    state = self.getCurrentState()
                    self.selectedSchemaIndex = 0
                    self.schemaCombo.setCurrentIndex(0)
                    self.setCurrentState(state)
        else:
            schema = self.colorSchemas[self.selectedSchemaIndex][1]
            self.setCurrentState(schema)
 def input_text(self, msg, title='', default=None):
     text, ok = QInputDialog.getText(self, title, msg, text=default)
     if ok:
         return str(text)
     else:
         return None