Ни как не получается поменять значение self.image.source на путь для файла. Вылетают различные ошибки
Вот сам код
class SaveLoad(FloatLayout):
save = ObjectProperty(None)
image = ObjectProperty(None)
cancel = ObjectProperty(None)
class LoadDialog(FloatLayout):
load = ObjectProperty(None)
cancel = ObjectProperty(None)
class Root(FloatLayout):
loadfile = ObjectProperty(None)
image = ObjectProperty(None)
def load(self, path, file):
# та самая проблемная строка
path = os.path.join(path, file[0])
self.image.source = path
dismiss_popup()
def dismiss_popup(self):
self._popup.dismiss()
def openFile(self):
if camera == 0:
content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
self._popup = Popup(title="Open File", content=content, size_hint=(0.9, 0.9))
self._popup.open()
else :
print("Error")
в файле kv
Root:
BoxLayout:
orientation: 'vertical'
size_hint: (1, 1)
GridLayout:
cols: 1
size_hint: (1, .2)
Button:
text: "Open\nfile"
on_press: root.openFile()
BoxLayout:
orientation: "horizontal"
padding: (190, 27)
Image:
id: image
source: 'image/white-background.jpg'
size_hint: (None, None)
size: (300 ,300)
# Окно с файловым менеджером
<LoadDialog>:
BoxLayout:
orientation: 'vertical'
size: root.size
pos: root.pos
FileChooserIconView:
id: filechooser
path: '~/'
BoxLayout:
orientation: 'horizontal'
size_hint_y: None
height: 40
Button:
text: "Close"
on_press: root.cancel()
Button:
text: "Load File"
on_press: root.load(filechooser.path, filechooser.selection)
Выдает эту ошибку
File "/home/karacb/.local/lib/python3.7/site-packages/kivy/lang/builder.py", line 64, in custom_callback
exec(__kvlang__.co_value, idmap)
File "/home/karacb/Desktop/Python/kivy language/Informatik/findface.kv", line 63, in <module>
on_press: root.load(filechooser.path, filechooser.selection)
File "/home/karacb/Desktop/Python/kivy language/Informatik/indexCopy.py", line 74, in load
self.image.source = path
AttributeError: 'NoneType' object has no attribute 'source'