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
python kivy recyclerview-layout
add a comment |
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
python kivy recyclerview-layout
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
add a comment |
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
python kivy recyclerview-layout
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
python kivy recyclerview-layout
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
add a comment |
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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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