以下のプログラムを実行すると、画像を表示してほしい箇所が白くなります。
どうすればよいかご教示願います。
###コード
python
1from kivy.config import Config 2Config.set('graphics', 'width', '640')#デフォルトでは800×600になっている 3Config.set('graphics', 'height', '480') 4 5from kivy.app import App 6from kivy.uix.widget import Widget 7from kivy.properties import StringProperty ,ObjectProperty 8from kivy.core.text import LabelBase,DEFAULT_FONT#日本語を使えるようにする 9from kivy.resources import resource_add_path #多分画像表示のパス取得用のやつ 10from kivy.clock import Clock 11from kivy.graphics.texture import Texture 12from kivy.graphics import Rectangle 13 14import os 15import glob 16import random 17import threading 18import time 19 20import handtracking 21 22 23class SmartGlassWidget(Widget): 24 image_L = ObjectProperty(None) 25 image_R = ObjectProperty(None) 26 image_L_src = StringProperty("") 27 image_R_src = StringProperty("") 28 29 def __init__(self, **kwargs): 30 super(SmartGlassWidget,self).__init__(**kwargs) 31 def StartbuttonClicked(self): 32 self.image_R_src = "./Image_layer/calender.png" 33 34class SmartGlassApp(App): 35 def __init__(self,**kwargs): 36 super(SmartGlassApp,self).__init__(**kwargs) 37 self.title = "SmartGlass" 38 39 def build(self): 40 self.widget = SmartGlassWidget() 41 return self.widget 42 43if __name__ == "__main__": 44 SmartGlassApp().run()
kv
1SmartGlassWidget: 2 3<SmartGlassWidget>: 4 BoxLayout: 5 orientation: "vertical" 6 size: root.size 7 canvas: 8 Rectangle: 9 source: './Image_layer/calender.png' 10 size: self.size 11 # allow_stretch: True 12 Image: 13 sourece: root.image_R_src 14 # allow_stretch: True 15 16 Button: 17 size_hint_y:0.2 18 text:"Start App" 19 color: 1,0.5,0,1 20 on_press: root.StartbuttonClicked()
log
1[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0 2[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0 3[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1 4[INFO ] [Kivy ] v2.0.0 5[INFO ] [Kivy ] Installed at "C:\Users\kusan\anaconda3\lib\site-packages\kivy\__init__.py" 6[INFO ] [Python ] v3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] 7[INFO ] [Python ] Interpreter at "C:\Users\kusan\anaconda3\python.exe" 8[INFO ] [Factory ] 186 symbols loaded 9[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored) 10[INFO ] [Text ] Provider: sdl2 11[INFO ] [Window ] Provider: sdl2 12[INFO ] [GL ] Using the "OpenGL" graphics system 13[INFO ] [GL ] GLEW initialization succeeded 14[INFO ] [GL ] Backend used <glew> 15[INFO ] [GL ] OpenGL version <b'4.6.0 NVIDIA 456.71'> 16[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'> 17[INFO ] [GL ] OpenGL renderer <b'GeForce GTX 1660/PCIe/SSE2'> 18[INFO ] [GL ] OpenGL parsed version: 4, 6 19[INFO ] [GL ] Shading version <b'4.60 NVIDIA'> 20[INFO ] [GL ] Texture max size <32768> 21[INFO ] [GL ] Texture max units <32> 22[INFO ] [Window ] auto add sdl2 input provider 23[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked 24[INFO ] [GL ] NPOT texture support is available 25[INFO ] [Base ] Start application main loop 26[INFO ] [Base ] Leaving application in progress...
###ファイル構成
SmartGlass202101 |- Image_layer calender.png main.py smarglass.kv
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/03/08 15:00