Beispiel #1
0
    def bind_current_index(self, binding: Binding.Binding) -> None:
        self.clear_task("update_current_index")
        if self.__current_index_binding:
            self.__current_index_binding.close()
            self.__current_index_binding = None
        current_index = typing.cast(typing.Optional[int],
                                    binding.get_target_value())
        if current_index is not None and 0 <= current_index < len(self.items):
            self.current_index = current_index
        self.__current_index_binding = binding

        def update_current_index(current_index: int) -> None:
            if current_index is not None and 0 <= current_index < len(
                    self.items):

                def update_current_index_() -> None:
                    if self._behavior:
                        self.current_index = current_index

                self.add_task("update_current_index", update_current_index_)

        self.__current_index_binding.target_setter = update_current_index

        def handle_current_index_changed(index: int) -> None:
            if self.__current_index_binding:
                self.__current_index_binding.update_source(index)

        self.__on_current_index_changed = handle_current_index_changed
Beispiel #2
0
    def bind_color(self, binding: Binding.Binding) -> None:
        if self.__color_binding:
            self.__color_binding.close()
            self.__color_binding = None
        self.color = binding.get_target_value()
        self.__color_binding = binding

        def update_color(color):
            def update_color_():
                if self._behavior:
                    self.color = color

            self.add_task("update_color", update_color_)

        self.__color_binding.target_setter = update_color
Beispiel #3
0
    def bind_image(self, binding: Binding.Binding) -> None:
        if self.__image_binding:
            self.__image_binding.close()
            self.__image_binding = None
        self.image = binding.get_target_value()
        self.__image_binding = binding

        def update_image(
                image: typing.Optional[DrawingContext.RGBA32Type]) -> None:
            def update_image_() -> None:
                self.image = image

            self.add_task("update_image", update_image_)

        self.__image_binding.target_setter = update_image
Beispiel #4
0
    def bind_icon(self, binding: Binding.Binding) -> None:
        if self.__icon_binding:
            self.__icon_binding.close()
            self.__icon_binding = None
        self.icon = binding.get_target_value()
        self.__icon_binding = binding

        def update_icon(
                icon: typing.Optional[DrawingContext.RGBA32Type]) -> None:
            def update_icon_() -> None:
                self.icon = icon

            self.add_task("update_icon", update_icon_)

        self.__icon_binding.target_setter = update_icon
    def bind_display_item(self, binding: Binding.Binding) -> None:
        if self.__display_item_binding:
            self.__display_item_binding.close()
            self.__display_item_binding = None
        self.display_item = binding.get_target_value()
        self.__display_item_binding = binding

        def update_display_item(display_item: DisplayItem.DisplayItem) -> None:
            if self.__window:

                async def update_display_item_() -> None:
                    self.display_item = display_item
                    self.__update_display_item_task = None

                self.__update_display_item_task = self.__window.event_loop.create_task(
                    update_display_item_())

        self.__display_item_binding.target_setter = update_display_item
Beispiel #6
0
    def bind_items(self, binding: Binding.Binding) -> None:
        self.clear_task("update_items")
        if self.__items_binding:
            self.__items_binding.close()
            self.__items_binding = None
        self.items = list(
            typing.cast(typing.Sequence[typing.Any],
                        binding.get_target_value()))
        self.__items_binding = binding

        def update_items(items: typing.Sequence[typing.Any]) -> None:
            def update_items_() -> None:
                if self._behavior:
                    self.items = items

            self.add_task("update_items", update_items_)

        self.__items_binding.target_setter = update_items
Beispiel #7
0
    def bind_group_value(self, binding: Binding.Binding) -> None:
        if self.__group_value_binding:
            self.__group_value_binding.close()
            self.__group_value_binding = None
            self.__on_group_value_changed = None
        self.group_value = binding.get_target_value()
        self.__group_value_binding = binding

        def update_group_value(group_value: typing.Optional[int]) -> None:
            def update_group_value_() -> None:
                self.group_value = group_value

            self.add_task("update_group_value", update_group_value_)

        self.__group_value_binding.target_setter = update_group_value

        def handle_group_value_changed(
                group_value: typing.Optional[int]) -> None:
            if self.__group_value_binding:
                self.__group_value_binding.update_source(group_value)

        self.__on_group_value_changed = handle_group_value_changed