###前提・実現したいこと
別ディレクトリにある画像を並べて表示することができました。
しかし、<.DS_Store>のエラーが出てかつ白い画像らしきものが表示されます。
if文で、<.png><.jpg><.jpeg>以外のファイルは表示しないはずなのですが…
if文がおかしいのでしょうか、よろしくお願いします。
###エラーコード
python
1[INFO ] [GL ] Using the "OpenGL ES 2" graphics system 2[INFO ] [GL ] Backend used <gl> 3[INFO ] [GL ] OpenGL version <2.1 ATI-10.2.8> 4[INFO ] [GL ] OpenGL vendor <ATI Technologies Inc.> 5[INFO ] [GL ] OpenGL renderer <ATI Radeon HD 4670 OpenGL Engine> 6[INFO ] [GL ] OpenGL parsed version: 2, 1 7[INFO ] [GL ] Shading version <1.20> 8[INFO ] [GL ] Texture max size <8192> 9[INFO ] [GL ] Texture max units <16> 10[INFO ] [Window ] auto add sdl2 input provider 11[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked 12[INFO ] [Text ] Provider: sdl2 13[INFO ] [Base ] Start application main loop 14[INFO ] [GL ] NPOT texture support is available 15[ERROR ] [Image ] Error loading texture ./page/gallery/.DS_Store
###該当のソースコード
python#
1# -*- coding: utf-8 -*- 2import kivy 3kivy.require('1.7.3') 4from kivy.lang import Builder 5from kivy.app import App 6from kivy.uix.boxlayout import BoxLayout 7from kivy.uix.widget import Widget 8from kivy.core.window import Window 9from kivy.properties import StringProperty,ListProperty 10#Window.clearcolor=[0.999,0.89,0.999,1] 11from kivy.uix.screenmanager import ScreenManager, Screen 12from kivy.graphics import Rectangle 13from kivy.properties import NumericProperty 14 15import sys 16from kivy.core.text import LabelBase, DEFAULT_FONT 17from kivy.resources import resource_add_path 18 19from glob import glob 20from random import randint 21from os.path import join, dirname 22from kivy.logger import Logger 23from kivy.uix.scatter import Scatter 24 25#OpenCV 26import os 27import numpy as np 28import cv2 29import re 30 31# デフォルトに使用するフォントを変更する 32resource_add_path('./fonts') 33LabelBase.register(DEFAULT_FONT, 'mplus-2c-regular.ttf') 34#日本語が使用できるように日本語フォントを指定する 35class Picture(Widget): #画像の表示 36 source = StringProperty(None) 37class Tops3(Widget): 38 hogehoge = StringProperty() 39 def __init__(self, **kwargs): 40 super(Tops3, self).__init__(**kwargs) 41 data_dir_path = u"./page/gallery/" 42 file_list = os.listdir(r'./page/gallery/') 43 curdir = dirname(__file__) 44 pos_x = 40 45 pos_y = 300 46 for file_name in file_list: 47 root, ext = os.path.splitext(file_name) 48 pos_x += 100 49 if ext == u'.png' or u'.jpeg' or u'.jpg' : 50 picture = Picture(source= data_dir_path + file_name,rotation=randint(-30, 30),x = pos_x,y = pos_y) 51 self.add_widget(picture) 52 def buttomClickedMenu(self): #トップページに戻る 53 self.clear_widgets() 54 sys.path.append('../') 55 from main import TextWidget 56 menu = TextWidget() 57 self.add_widget(menu) 58Builder.load_string(r''' 59<Tops3>: 60 Button: 61 text:'<TOPに戻る' 62 pos:5,547 63 size:200,50 64 on_press:root.buttomClickedMenu() 65 66<Picture>: 67 # each time a picture is created, the image can delay the loading 68 # as soon as the image is loaded, ensure that the center is changed 69 # to the center of the screen. 70 on_size: self.center = win.Window.center 71 #size: image.size 72 size_hint: None, None 73 Image: 74 id: image1 75 source: root.source 76 pos:root.x,root.y 77''')
###補足情報(言語/FW/ツール等のバージョンなど)
python2.7
kivy
MAC
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/29 03:02