Exemplo n.º 1
0
 def show_images(self):
     # image_list must always contain camera_icon, otherwise image_list[0] in <Images> fails
     copy_list = [im for im in app.daten.image_list if not im[0].endswith(utils.camera_icon)]
     l = len(copy_list)
     if l == 0:
         app.do_capture()
         return
     elif l == 1:
         t = copy_list[0]
         if t[1] is None:
             self.show_single_image(t[0])
         else:
             maxdim = self.app.getConfigValue("maxdim", 1024)
             if self.app.useGoogle:
                 im = self.app.gphoto.getImage(t[1], maxdim)
             else:
                 im = self.app.serverIntf.getImage(t[1], maxdim)
             if im is None:
                 self.app.message("Kann Bild nicht laden")
             else:
                 self.show_single_image(im)
         return
     self.bl.clear_widgets()
     for i, cp in enumerate(copy_list):
         im = AsyncImage(source=cp[0], on_touch_down=self.show_single_image)
         im.size = app.root.sm.size
         im.mediaId = cp[1]
         im.number = i
         # without auto_bring_to_front=False the boxlayout children are reshuffled
         sc = Scatter(do_rotation=False, do_translation=False, do_scale=False, size=im.size,
                      auto_bring_to_front=False, size_hint=(None, None))
         sc.add_widget(im)
         self.bl.add_widget(sc)
Exemplo n.º 2
0
 def _load_content(self):
     try:
         for item in Parser.parse_feed(self.rss_url).items:
             try:
                 img_link = item.img_links[0]
             except IndexError:
                 img_link = "https://lh3.googleusercontent.com/proxy/IDewKjtSRFq4JXcNwZJwSKxI5m70p5T-j5ImFoVBiH5Xw109aTK491K1iP46b1uDnMpNbbNBKEZSJgbkCsbS6sf5gSK_TJMEFTtVcjGiZBtUoCpj6VYDA6Vdg1fWs8A49ZOf_mq8u7E3IeMnXEdxzSoh5nk"
             image = AsyncImage(source=img_link)
             image.size = image.image_ratio * 200, 200
             self.main_content.grid_layout.add_widget(image)
             self.main_content.grid_layout.add_widget(
                 ItemButton(text=item.title,
                            item=item,
                            rss_url=self.rss_url))
         self.main_content.text_input.text = self.rss_url
     except ConnectionError:
         self.main_content.text_input.text = "Woops, something happened with url :("
Exemplo n.º 3
0
    def __init__(self, product, category, product_items, **kwargs):
        super().__init__(**kwargs)
        self.product = product
        self.category = category
        self.product_items = product_items
        Window.bind(on_keyboard=self.prev_screen)

        product_data = get_product(category, product)
        root = Builder.load_file('layouts/product_screen/main.kv')
        root.grid.bind(minimum_height=root.grid.setter('height'))
        root.grid.add_widget(
            Label(text=product_data['full_name'], height=50, size_hint_y=None))
        head_block = GridLayout(cols=2,
                                size_hint_y=None,
                                height=310,
                                padding=(100, 20))
        image = AsyncImage(
            source=product_data['img_url'],
            allow_stretch=True,
            size_hint=(None, None),
        )
        image.size = image.image_ratio * 300, 300
        right_head = GridLayout(rows=2)
        price = Label(
            text=
            f'{product_data["current_price"]["price_min"]} - {product_data["current_price"]["price_max"]} руб.'
        )
        description = Label(text=product_data['description'])
        head_block.add_widget(image)
        right_head.add_widget(description)
        right_head.add_widget(price)
        head_block.add_widget(right_head)
        root.grid.add_widget(head_block)
        for name, values in product_data['spec'].items():
            root.grid.add_widget(Label(text=name, height=50, size_hint_y=None))
            for key, value in values.items():
                block = GridLayout(rows=1, height=50, size_hint_y=None)
                left = Label(text=key, halign='left')
                block.add_widget(left)
                if isinstance(value, bool):
                    value = 'yes' if value else 'no'
                block.add_widget(Label(text=str(value)))
                root.grid.add_widget(block)

        self.add_widget(root)
Exemplo n.º 4
0
    def __init__(self, category, product_items, **kwargs):
        super().__init__(**kwargs)
        Window.bind(on_keyboard=self.prev_screen)
        self.category = category
        root = Builder.load_file('layouts/catalog_screen/main.kv')
        root.grid.bind(minimum_height=root.grid.setter('height'))
        for product in product_items:
            product_box = ProductItem(category=category,
                                      product=product['key'],
                                      product_items=product_items,
                                      height=350,
                                      size_hint_y=None)

            image = AsyncImage(source=product['img_url'],
                               allow_stretch=True,
                               size_hint=(None, None),
                               pos_hint={
                                   'top': .8,
                                   'right': .8
                               })
            image.size = image.image_ratio * 200, 200
            product_box.add_widget(image)

            label1 = Label(text=product['full_name'],
                           pos_hint={
                               'right': .75,
                               'top': 1
                           })
            product_box.add_widget(label1)

            label3 = Label(
                text=f'от {product["current_price"]["price_min"]} р.',
                pos_hint={
                    'right': .75,
                    'top': .9
                })
            product_box.add_widget(label3)

            root.grid.add_widget(product_box)
        self.add_widget(root)
Exemplo n.º 5
0
 def __init__(self, item: Item, rss_url, **kwargs):
     super().__init__(**kwargs)
     self.item = item
     self.rss_url = rss_url
     self.main_content = main_content = Builder.load_file(
         'layouts/item_screen/main.kv')
     main_content.title_label.text = item.title
     img_links = item.img_links
     try:
         img_links[0]
     except IndexError:
         img_links = [
             "https://lh3.googleusercontent.com/proxy/IDewKjtSRFq4JXcNwZJwSKxI5m70p5T-j5ImFoVBiH5Xw109aTK491K1iP46b1uDnMpNbbNBKEZSJgbkCsbS6sf5gSK_TJMEFTtVcjGiZBtUoCpj6VYDA6Vdg1fWs8A49ZOf_mq8u7E3IeMnXEdxzSoh5nk"
         ]
     for img_link in img_links:
         image = AsyncImage(source=img_link)
         image.size = image.image_ratio * 200, 200
         main_content.image.add_widget(image)
     main_content.description_label.text = item.description
     main_content.author_label.text = f"Author: {item.author}"
     main_content.time_label.text = f"Published time: {time.asctime(item.published_parsed)}"
     main_content.url_label.text = f"Link: {item.link}"
     self.add_widget(main_content)
Exemplo n.º 6
0
    def show_img(self, _type, _img_path, _chat_window_id):
        _chat_window = None
        _chat_scroll = self.ids.chat_scroll

        if _chat_window_id == self.member_list_current._id:
            _chat_window = _chat_scroll.children[0]
        else:
            _chat_window = self.chat_record.setdefault(_chat_window_id, None)
            if _chat_window is None:
                _chat_window = StackLayout(orientation='tb-lr',
                                           size_hint=[1, None])
                _chat_window.width = _chat_scroll.width
                _chat_window.height = 0

        _label_left = Label()

        _label_main = AsyncImage(source=_img_path, nocache=True)
        # _label_main.reload()
        _label_main.bind(on_touch_down=self.zoom_img)
        _label_main.size = [
            _label_main.norm_image_size[0], _label_main.norm_image_size[1]
        ]
        _label_right = Label()

        _pos_x_hint_left = [0, 0]
        _pos_x_hint_main = [0, 0]
        _pos_x_hint_right = [0, 0]

        while _pos_x_hint_main[0] == 0:
            if _label_main.texture_size[0] >= _chat_window.width * 0.7:

                _pos_x_hint_main = [0.7, None]
            else:
                _pos_x_hint_main = [
                    _label_main.texture_size[0] / _chat_window.width, None
                ]

        if _type == 'receive':
            _pos_x_hint_left = [0.05, None]
            _pos_x_hint_right = [
                1 - _pos_x_hint_left[0] - _pos_x_hint_main[0], None
            ]
        elif _type == 'send':
            _pos_x_hint_left = [1 - 0.05 - _pos_x_hint_main[0], None]
            _pos_x_hint_right = [0.05, None]
        elif _type == 'time':
            _pos_x_hint_left = [(1 - _pos_x_hint_main[0]) / 2, None]
            _pos_x_hint_right = _pos_x_hint_left

            _chat_window.last_msg_time = time.time()

        _label_left.size_hint = _pos_x_hint_left
        _label_main.size_hint = _pos_x_hint_main
        _label_right.size_hint = _pos_x_hint_right

        _box = BoxLayout(size_hint=[1, None])
        _box.height = _label_main.texture_size[1] + 30
        _box.add_widget(_label_left)
        _box.add_widget(_label_main)
        _box.add_widget(_label_right)
        _chat_window.add_widget(_box)

        if _chat_window_id is None:
            # _chat_scroll.scroll_y = 0
            self.chat_window_height = self.chat_window_height + _box.height
            _chat_window.height = self.chat_window_height + 30
        else:
            _chat_window.height = _chat_window.height + _box.height
            self.chat_record.update({_chat_window_id: _chat_window})

        pass