def __create_side_panel(self, configuration):
        self.__clean_side_panel()

        connectors = []
        ports = System.get_ports()
        for key in ports:
            if ports[key].language == self.block.language:
                connectors.append(key)

        data = {"label": _("Port Type"), "name":"type", "values": connectors}
        field = ComboField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration.type)

        data = {"label": _("Connection Type"), "name":"conn_type", "values": [Port.INPUT, Port.OUTPUT]}
        field = ComboField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration.conn_type)

        data = {"label": _("Label"), "name":"label"}
        field = StringField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration.label)

        data = {"label": _("Name"), "name":"name"}
        field = StringField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration.name)

        button = Gtk.Button.new_with_label("Save")
        button.connect("clicked", self.__on_save, None)
        self.side_panel.pack_start(button, False, False, 1)
        self.side_panel.show_all()
class TestComboField(unittest.TestCase):
    def setUp(self):
        ComboField(None, None)
        data = {"label": "Test", "value": "a", "name": "", "values": ["a"]}
        self.field = ComboField(data, None)
        self.field = ComboField({"label": "test", "value": True}, None)
        self.field = ComboField({}, self.test_value)

    def test_value(self):
        data = {"label": "Test", "value": "a", "name": "", "values": ["a"]}
        self.field = ComboField(data, None)
        value1 = "a"
        self.field.set_value(value1)
        value2 = self.field.get_value()
        self.assertEqual(value1, value2, 'incorrect value')
Beispiel #3
0
    def __create_side_panel(self, configuration):
        self.__clean_side_panel()

        connectors = []
        for key in System.ports:
            if System.ports[key].language == self.block.language:
                connectors.append(key)

        data = {"label": _("Type"), "name":"type", "values": connectors}
        field = ComboField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration["type"])

        data = {"label": _("Label"), "name":"label"}
        field = StringField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration["label"])

        data = {"label": _("Name"), "name":"name"}
        field = StringField(data, None)
        self.side_panel.pack_start(field, False, False, 1)
        if configuration is not None: field.set_value(configuration["name"])

        button = Gtk.Button.new_with_label("Save")
        button.connect("clicked", self.__on_save, None)
        self.side_panel.pack_start(button, False, False, 1)
        self.side_panel.show_all()
Beispiel #4
0
class TestComboField(TestCase):
    def setUp(self):
        """Do the test basic setup."""
        data = {
            "label": ("Type"),
            "name": "type",
            "value": "Banana",
            "values": ["Banana", "Apple", "Orange"]
        }
        self.combofield = ComboField(data, self)

    # ----------------------------------------------------------------------
    def test_get_value(self):
        self.assertTrue(self.combofield.get_value())

    # ----------------------------------------------------------------------
    def test_set_value(self):
        value = "Teste"
        self.assertIsNone(self.combofield.set_value(value))
        value = "Algo"
        self.assertIsNone(self.combofield.set_value(value))
        value = "Banana"
        self.assertIsNone(self.combofield.set_value(value))