Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

python - Text don't appear on kivy

I'm trying to make an app on kivy but the labels aren't showing up when I use the apk on my phone, I've already changed several things, used the button as a form of label, put a label in a BoxLayout, then added the screen, nothing makes the texts appear, I will leave here an example code and the way it looks on my cell phone, computer, and my buildozer.spec. enter image description hereenter image description here

My code:

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.screenmanager import ScreenManager, Screen, FadeTransition
from kivy.uix.image import Image
from kivy.core.window import Window


Window.clearcolor=(.6,.9,.5,1)
class ScreenManagement(ScreenManager):
    def __init__(self, **kwargs):
        super(ScreenManagement, self).__init__(**kwargs)

class Iniciar(Screen):
    def __init__(self, **kwargs):
        super(Iniciar, self).__init__(**kwargs)
        self.add_widget(Label(text='Test', font_size=16, pos_hint={'center_x': .55, 'y': .10}, color=(1.59,1.54,2.21)))
        self.add_widget(Label(text='Test2', font_size=16, pos_hint={'center_x': .40, 'y': .10}, color='yellow'))
        self.add_widget(Label(text='Test3', font_size=16, pos_hint={'center_x': .20, 'y': .10}, color='yellow'))
        self.button = Button(text='Return Decision', color=(2.55,2.55,2.55,1),size_hint=(.1, .15), pos_hint={'center_x': .85, 'y': .05})
        self.button.bind(on_press=self.press_button)
        self.add_widget(self.button)
    def press_button(self, *args):
        self.manager.current = 'decision'


class Decision(Screen):
    def __init__(self, **kwargs):
        super(Decision, self).__init__(**kwargs)
        self.label = Label(text='', font_size=27, pos_hint={'center_x': .55, 'y': .10},text_size=(250, None),color='pink')
        #self.reload = Image(source='reload.png', size_hint=(.15, .15), pos_hint={'center_x': .85, 'y': .05})
        self.button = Button(text='Return Iniciar', size_hint=(.1, .15), pos_hint={'center_x': .85, 'y': .05}, background_color=(2.55, 2.55, 0, 0))
        self.add_widget(self.button)
        #elf.add_widget(self.reload)
        self.button.bind(on_press=self.press_button)
        self.add_widget(self.label)
    def press_button(self, *args):
        self.manager.current = 'iniciar'

class Application(App):
    def build(self):
        sm = ScreenManagement(transition=FadeTransition())
        sm.add_widget(Decision(name='decision'))
        sm.add_widget(Iniciar(name='iniciar'))

        return sm


if __name__ == "__main__":
    Application().run()

My buildozer.spec is on default


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...