Exemplo n.º 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)
Exemplo n.º 3
0
 def __calc_walked_distance_window_with_direction(self):
     winsize, ok = QInputDialog.getInt(
         self, "Calculate the walked distance with direction",
         "Enter the window size", 30)
     if ok:
         v2 = self.object2d.create_value()
         v2.name = "Walked distance with direction in the previous {0} frames".format(
             winsize)
         _, v2._values = self.calc_walked_distance_with_direction(winsize)
 def __create_contours(self):
     items = [x.name for x in self._video.objects2D]
     item = QInputDialog.getItem(self,
                                 "Select the object to add a contour",
                                 "Object",
                                 items,
                                 editable=False)
     try:
         index = items.index(item[0])
         self.create_contours(list(self._video.objects2D)[index])
     except ValueError:
         pass
Exemplo n.º 5
0
 def input_int(self,
               msg,
               title='',
               default=0,
               min=-2147483647,
               max=2147483647):
     text, ok = QInputDialog.getInt(self,
                                    title,
                                    msg,
                                    value=default,
                                    min=min,
                                    max=max)
     if ok:
         return int(text)
     else:
         return None
Exemplo n.º 6
0
    def __import_value_from_timeline(self):
        timeline = self.mainwindow._time
        graphs = timeline.graphs

        item, ok = QInputDialog.getItem(self,
                                        "Select the value to import",
                                        'Value',
                                        [str(graph) for graph in graphs],
                                        editable=False)
        if ok:
            for graph in graphs:
                if str(item) == str(graph):
                    v = self.create_value()
                    v.name = graph.name
                    for i in range(len(graph)):
                        v.set_value(i, graph[i])
Exemplo n.º 7
0
 def input_double(self,
                  msg,
                  title='',
                  default=0,
                  min=-2147483647,
                  max=2147483647,
                  decimals=1):
     text, ok = QInputDialog.getDouble(self,
                                       title,
                                       msg,
                                       value=default,
                                       min=min,
                                       max=max,
                                       decimals=decimals)
     if ok:
         return float(text)
     else:
         return None
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
0
 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