Python kivy图像不显示
我是新来的基维。我想做的是显示目录中的所有图像,用户可以向下滚动浏览它们 我遇到了一个问题,对于目录中的一个文件夹,所有图像都显示为白色矩形,我不明白为什么。另一个目录中的图像显示良好。。。以下是源代码:Python kivy图像不显示,python,image,user-interface,kivy,Python,Image,User Interface,Kivy,我是新来的基维。我想做的是显示目录中的所有图像,用户可以向下滚动浏览它们 我遇到了一个问题,对于目录中的一个文件夹,所有图像都显示为白色矩形,我不明白为什么。另一个目录中的图像显示良好。。。以下是源代码: class vAll(Screen): def __init__ (self,**kwargs): super (vAll, self).__init__(**kwargs) # os.chdir("/Users/User/Documents/
class vAll(Screen):
def __init__ (self,**kwargs):
super (vAll, self).__init__(**kwargs)
# os.chdir("/Users/User/Documents/dev/engineerappcopy/VGimages")
popup = Popup(title='View all', size_hint=(1,1), auto_dismiss=False)
ims = []
directory_list = list()
for root, dirs, files in os.walk("/Users/User/Documents/dev/engineerappcopy/VGimages", topdown=False):
for name in dirs:
directory_list.append(os.path.join(root, name))
print directory_list
#this layout is the child widget for the main popup
layout1 = StackLayout(orientation='lr-bt')
#this button is a child of layout1
closebutton = Button(text='back', size_hint=(0.8,0.05))
closebutton.bind(on_press=self.changer)
sz = 1
for d in directory_list:
os.chdir(d)
for fn in glob.glob("*.png"):
#return Image(source=fn,size=(10,10))
ims.append(fn)
for im in ims:
print im
i = AsyncImage(source=im)
sz = sz + 1
#another child of layout1 and this is the scrollview which will have a custom draggable scrollbar
scrlv = ScrollView(size_hint=(0.9,0.95))
layout2 = GridLayout(cols=2, size_hint_y= sz/10+4)
layout2.bind(minimum_height=layout2.setter('height'))
for im in ims:
i = Image(source=im)
layout2.add_widget(i)
scrlv.add_widget(layout2)
layout1.add_widget(closebutton)
layout1.add_widget(scrlv)
self.add_widget(layout1)
def scroll_change(self, scrlv, instance, value):
scrlv.scroll_y = value
def changer(self,*args):
self.manager.current = 'home'
抱歉,这段代码太糟糕了,我只是想把它用到workWhite矩形通常意味着图像路径无效或格式不受支持。抱歉,这段代码太糟糕了,我只是在玩,试图让它工作。白色矩形通常意味着图像路径无效或格式不受支持。