show image on RecycleView











up vote
0
down vote

favorite












I try to make a table with data from a SQL DB and images not from a DB. I have tried several things but the image don't show up.



I used this code and modified it: Link to Stackoverflow Code



Code snippets that i Changed in Main.py



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


Problem:



Link that shows a Picture of my problem












share|improve this question
























  • What is the name of the fields in your table?
    – eyllanesc
    Nov 8 at 19:59










  • @eyllanesc Table is: Users. Row 1 is 'UserID'- Integer (1, 2, 3) and Row 2 is 'Name' - Text (derik, dodo, dummi) and Row 3 isn't in the Database. Its in the python file in a for loop to create a empty field in the RecycleView
    – Richard
    Nov 9 at 13:13















up vote
0
down vote

favorite












I try to make a table with data from a SQL DB and images not from a DB. I have tried several things but the image don't show up.



I used this code and modified it: Link to Stackoverflow Code



Code snippets that i Changed in Main.py



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


Problem:



Link that shows a Picture of my problem












share|improve this question
























  • What is the name of the fields in your table?
    – eyllanesc
    Nov 8 at 19:59










  • @eyllanesc Table is: Users. Row 1 is 'UserID'- Integer (1, 2, 3) and Row 2 is 'Name' - Text (derik, dodo, dummi) and Row 3 isn't in the Database. Its in the python file in a for loop to create a empty field in the RecycleView
    – Richard
    Nov 9 at 13:13













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I try to make a table with data from a SQL DB and images not from a DB. I have tried several things but the image don't show up.



I used this code and modified it: Link to Stackoverflow Code



Code snippets that i Changed in Main.py



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


Problem:



Link that shows a Picture of my problem












share|improve this question















I try to make a table with data from a SQL DB and images not from a DB. I have tried several things but the image don't show up.



I used this code and modified it: Link to Stackoverflow Code



Code snippets that i Changed in Main.py



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


Problem:



Link that shows a Picture of my problem









python kivy recyclerview-layout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 8 at 19:37









eyllanesc

67.1k82952




67.1k82952










asked Nov 8 at 11:19









Richard

32




32












  • What is the name of the fields in your table?
    – eyllanesc
    Nov 8 at 19:59










  • @eyllanesc Table is: Users. Row 1 is 'UserID'- Integer (1, 2, 3) and Row 2 is 'Name' - Text (derik, dodo, dummi) and Row 3 isn't in the Database. Its in the python file in a for loop to create a empty field in the RecycleView
    – Richard
    Nov 9 at 13:13


















  • What is the name of the fields in your table?
    – eyllanesc
    Nov 8 at 19:59










  • @eyllanesc Table is: Users. Row 1 is 'UserID'- Integer (1, 2, 3) and Row 2 is 'Name' - Text (derik, dodo, dummi) and Row 3 isn't in the Database. Its in the python file in a for loop to create a empty field in the RecycleView
    – Richard
    Nov 9 at 13:13
















What is the name of the fields in your table?
– eyllanesc
Nov 8 at 19:59




What is the name of the fields in your table?
– eyllanesc
Nov 8 at 19:59












@eyllanesc Table is: Users. Row 1 is 'UserID'- Integer (1, 2, 3) and Row 2 is 'Name' - Text (derik, dodo, dummi) and Row 3 isn't in the Database. Its in the python file in a for loop to create a empty field in the RecycleView
– Richard
Nov 9 at 13:13




@eyllanesc Table is: Users. Row 1 is 'UserID'- Integer (1, 2, 3) and Row 2 is 'Name' - Text (derik, dodo, dummi) and Row 3 isn't in the Database. Its in the python file in a for loop to create a empty field in the RecycleView
– Richard
Nov 9 at 13:13

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206704%2fshow-image-on-recycleview%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206704%2fshow-image-on-recycleview%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)