示例#1
0
    def test_normal_foreach(self):
        objects = ['1', '2', '3']
        self.assertEqual([1, 2, 3], foreach(int, objects))

        import operator
        objects = [0, 1, 2]
        self.assertEqual([1, 2, 3], foreach(operator.add, objects, 1))
示例#2
0
    def test_combo_box_row(self):
        with quive.EventLoop(0.1):
            combo_box = quive.ComboBox()
            combo_box.show()

            combo_box.string_list.value = st.foreach(str, range(10))
            self.assertEqual(combo_box.string_list.value,
                             st.foreach(str, range(10)))

            combo_box.string_list.value = st.foreach(str, range(9))
            self.assertEqual(combo_box.string_list.value,
                             st.foreach(str, range(9)))
示例#3
0
        def set_value(self, value):
            value = value or []

            old_count = self.count
            new_count = len(value)
            for i in range(min(old_count, new_count)):
                self.parent.setItemText(i, value[i])
            st.foreach(self.parent.removeItem, range(new_count, old_count))
            self.parent.addItems(value[old_count:new_count])

            self.parent.index.emit_changed()
            self.parent.string.emit_changed()

            self.string_list.check_change()
示例#4
0
    def test_get_attr_foreach(self):
        class A:
            def __init__(self, v):
                self.v = v

        objects = [A(1), A(2), A(3)]
        self.assertEqual([1, 2, 3], foreach('.v', objects))
示例#5
0
    def test_obj_func_foreach(self):
        class A:
            def __init__(self, v):
                self.v = v

            def plus(self, p):
                return self.v + p

        objects = [A(0), A(1), A(2)]
        self.assertEqual([1, 2, 3], foreach('#plus', objects, 1))
示例#6
0
    def test_list_widget_row(self):
        with quite.EventLoop(0.1):
            list_widget = quite.ListWidget()
            list_widget.show()
            executed = [False]

            @quite.connect_with(list_widget.string.changed)
            def text_changed(text):
                self.assertEqual(text, '1')
                executed[0] = True

            list_widget.string_list.value = st.foreach(str, range(10))
            list_widget.index.value = 1
            self.assertTrue(executed[0])
示例#7
0
    def test_list_widget_string_list(self):
        with quite.EventLoop(0.1):
            list_widget = quite.ListWidget()
            list_widget.show()
            executed = [False]
            string_list = st.foreach(str, range(10))

            @quite.connect_with(list_widget.string_list.changed)
            def string_list_changed(string_list_now):
                self.assertEqual(string_list, string_list_now)
                executed[0] = True

            list_widget.string_list.value = string_list
            self.assertTrue(executed[0])
示例#8
0
    def test_combo_box_string_list(self):
        with quive.EventLoop(0.1):
            combo_box = quive.ComboBox()
            combo_box.show()
            executed = [False]

            string_list = st.foreach(str, range(10))

            @quive.connect_with(combo_box.string_list.changed)
            def string_list_changed(string_list_now):
                self.assertEqual(string_list, string_list_now)
                executed[0] = True

            combo_box.string_list.value = string_list
            self.assertTrue(executed[0])
示例#9
0
 def get_value(self):
     return st.foreach(self.parent.itemText, range(self.count))
示例#10
0
 def get_value(self):
     return st.foreach(self.item_text, range(self.count))
示例#11
0
 def get_value(self):
     return st.foreach(self.parent.itemText, range(self.count))
示例#12
0
 def get_value(self):
     return st.foreach(self.item_text, range(self.count))