BoxLayou 在 Kivy 上重复

问题描述

我正在设计一款应用来帮助学习识字。我的想法是显示类似于以下内容的屏幕:My idea

但是当我运行时,它复制了 BoxLayout 甚至四倍,我找不到问题。The real output

*.kv

#:kivy 1.9.0

<DrawGame>:
    AnchorLayout:
        anchor_x: 'center'
        anchor_y: 'center'
        Image:
            source: 'data/img/letra_a/a-trazo.png'

<ImageEx>:
    AnchorLayout:
        anchor_x: 'center'
        anchor_y: 'center'
        Image:
            source: 'data/img/letra_a/avestruz.png'
            
<SoundEx>:
    BoxLayout:
        orientation: 'horizontal'
        size: [1,.25]
        pos: root.pos
        Label:
            text: "Sonido de ejemplo"
            color: [0,83,80,19]
            
<ContainerBox>:
    canvas.before:
        Rectangle:
            pos: self.pos
            size: self.size
            source: 'data/img/fondobosque.jpg'
    orientation: 'vertical'
    Label:
        text: 'En este juego debes escribir con tu dedo,de manera correcta,la letra por la que empieza la imagen que le acompaña. Además podrás escuchar su pronunciación'
        size_hint_y: 0.2
    BoxLayout:  
        orientation: 'horizontal'
        DrawGame:
        BoxLayout:
            orientation: 'vertical'
            BoxLayout:
                orientation: 'vertical'
                ImageEx:
                SoundEx:

*.py

import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.uix.image import Image
from kivy.properties import NumericProperty,ReferenceListProperty,ObjectProperty
from kivy.graphics import Ellipse,Line,Color
from kivy.vector import Vector
from kivy.clock import Clock
from random import randint
from kivy.uix.screenmanager import ScreenManager,Screen
from kivy.uix.Boxlayout import BoxLayout
from kivy.uix.anchorlayout import AnchorLayout
from kivy.config import Config
from kivy.core.window import Window


Builder.load_file('letras.kv')

class DrawGame(BoxLayout):
    def __init__(self,**kwargs):
        super(DrawGame,self).__init__(**kwargs)
   
    def on_touch_down(self,touch):
        print(touch)
        with self.canvas:
            Color(0,1,0.5)
            touch.ud["line"] = Line(points=(touch.x,touch.y),width=10)
            
    def on_touch_move(self,touch):
        print(touch)
        touch.ud["line"].points += (touch.x,touch.y)
        
    def on_touch_up(self,touch):
        print("Released!",touch)
        
class ImageEx(BoxLayout):
    def __init__(self,**kwargs):
        super(ImageEx,self).__init__(**kwargs)
        
class SoundEx(BoxLayout):
    def __init__(self,**kwargs):
        super(SoundEx,self).__init__(**kwargs)
        
class ContainerBox(BoxLayout):
    def __init__(self,**kwargs):
        super(ContainerBox,self).__init__(**kwargs)
            
class LetrasApp(App):
    def build(self):
        #Window.fullscreen = 'auto'
        return ContainerBox()
    
if __name__ == "__main__":
    LetrasApp().run()

我不明白为什么它会增加所有信息,包括图像和标签。每个类只有一个声明。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...