RecycleView görüntüyü göstermek

oy
0

Ben bir DB'den SQL DB'den veri ve görüntüleri içeren bir tablo yapmaya çalışıyoruz. Ben birkaç şey denedim ama görüntü görünmüyor.

Bu kodu kullanılmış ve modifiye: Stackoverflow Kodu Linki

i main.py değiştirildi Kod parçacıkları

import sqlite3

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.recycleview.views import RecycleDataViewBehavior
from kivy.uix.button import Button
from kivy.properties import BooleanProperty, ListProperty, StringProperty, ObjectProperty
from kivy.uix.recyclegridlayout import RecycleGridLayout
from kivy.uix.behaviors import FocusBehavior
from kivy.uix.recycleview.layout import LayoutSelectionBehavior
from kivy.uix.popup import Popup
from kivy.uix.image import Image #<<<<<<<<<<<<<<< new

[...]

class RV(BoxLayout):
    data_items = ListProperty([])
    image = Image(source='image.gif') #<<<<<<<<<<<<<<<<<<< new

    def __init__(self, **kwargs):
        super(RV, self).__init__(**kwargs)
        self.get_users()

    def get_users(self):
        connection = sqlite3.connect(demo.db)
        cursor = connection.cursor()

        cursor.execute(SELECT * FROM Users ORDER BY UserID ASC)
        rows = cursor.fetchall()

        # create data_items
        for row in rows:
            for col in row:
                self.data_items.append(col)
                print(type(col))
            self.data_items.append(self.image) #<<<<<<<<<<<<<<<<<<< new

[...]

test.kv

#:kivy 1.10.0

<TextInputPopup>:
    title: Popup
    size_hint: None, None
    size: 400, 400
    auto_dismiss: False

    BoxLayout:
        orientation: vertical
        TextInput:
            id: txtinput
            text: root.obj_text
        Button:
            size_hint: 1, 0.2
            text: Save Changes
            on_release:
                root.obj.update_changes(txtinput.text)
                root.dismiss()
        Button:
            size_hint: 1, 0.2
            text: Cancel Changes
            on_release: root.dismiss()


<SelectableButton>:
    # Draw a background to indicate selection
    canvas.before:
        Color:
            rgba: (.0, 0.9, .1, .3) if self.selected else (0, 0, 0, 1)
        Rectangle:
            pos: self.pos
            size: self.size

<RV>:
    BoxLayout:
        orientation: vertical

        GridLayout:
            size_hint: 1, None
            size_hint_y: None
            height: 25
            cols: 3

            Label:
                text: User ID
            Label:
                text: User Name

            Label:
                text: Image To Insert

        BoxLayout:
            RecycleView:
                viewclass: 'SelectableButton'
                data: [{'text': str(x)} for x in root.data_items] #<<<<<<<<<< Problem?
                SelectableRecycleGridLayout:
                    cols: 3
                    default_size: None, dp(26)
                    default_size_hint: 1, None
                    size_hint_y: None
                    height: self.minimum_height
                    orientation: 'vertical'
                    multiselect: True
                    touch_multiselect: True

Sorun:

Benim sorunun bir resmi gösterir Bağlantı

Oluştur 08/11/2018 saat 11:19
kaynak kullanıcı
Diğer dillerde...                            

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more