我是新手,我正在写一个viewer
应用程序。
目前,我仅在进行设计,但是出现以下错误:
line 239, in create_view
view_instance = cls(**item_args) TypeError: 'kivy.weakproxy.WeakProxy' object is not callable
共享我的代码:
bins_player.py:
import kivy
import glob
from os import path
import tkinter as tk
from kivy.app import App
from tkinter import filedialog
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.uix.gridlayout import GridLayout
kivy.require('1.9.0')
class FilesPanel(GridLayout):
frames_list = ObjectProperty()
def open_files(self):
root = tk.Tk()
root.withdraw()
self.load_files(filedialog.askdirectory(parent=root,initialdir="/", title='Please select a directory'))
def load_files(self, selected_folder):
all_bin_files = glob.glob(path.join(selected_folder, '*.bin'))
for bin_file in all_bin_files:
self.frames_list.adapter.data.extend([bin_file])
self.frames_list._trigger_reset_populate()
class BinsPlayerMain(GridLayout):
pass
class Bins_PlayerApp(App):
def build(self):
Window.clearcolor = (1, 1, 1, 1)
self.title = 'Bins Player'
self.icon = 'BinsPlayer.ico'
return BinsPlayerMain()
if __name__ == "__main__":
Bins_PlayerApp().run()
bins_player.kv:
#: include ui/filespanel.kv
<BinsPlayerMain>:
rows: 2
GridLayout:
filespanel.kv:
#: include force ui/sectiontitle.kv
#: import ListAdapter kivy.adapters.listadapter.ListAdapter
<FilesPanel>:
id: filesPanel
frames_list: frames_list_view
rows: 2
size_hint_x: None
width: 200
ListView:
id: frames_list_view
rgba: .2, .2, .2, 1
adapter:
ListAdapter(data=[], cls=filesPanel)
Button:
size_hint_y: None
height: 30
spacing: 10
text: 'Open Folder'
on_press: filesPanel.open_files()
打开文件夹后-ListView
更新后,我立即收到此错误。
这里可能是什么问题?
我看到了一种名为new
的{{1}}布局-可以在这里使用它代替ResycleView
吗?