如何在带有标签的kivy python桌面应用程序中将图像用作启动屏幕?

时间:2018-09-05 08:10:18

标签: python kivy spinner splash-screen

这是我的代码,仅接受数字并将其添加并在标签中显示结果,数字通过微调框接受。但是在加载主应用程序之前,我需要启动屏幕。我想知道我们如何将图像用作启动屏幕并显示一段时间,直到主应用程序启动。

from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.properties import StringProperty
from kivy.uix.spinner import Spinner
from kivy.app import App


Builder.load_string('''
<MainScreen>:
    GridLayout:      
        orientation: 'vertical'
        cols: 1
        canvas.before:
            Color:
                rgba: 1, 1, 1, 1  
            Rectangle:
                pos: self.pos
                size: self.size
        GridLayout:      
            orientation: 'vertical'
            cols: 2
            Spinner:
                id: first
                text: ' First Number'
                values: ['1','2','3','4','5','6','7','8','9'] 
            Spinner:
                id: second
                text: ' Second Number'
                values: ['1','2','3','4','5','6','7','8','9']       
        Label:
            id: result
            text: ' Result'
            color: 0,0,0,1
        Button:
            id: res
            on_press: root.onPow(first.text,second.text)
            text: 'Progress'
''')

class MainScreen(FloatLayout):
    changet = StringProperty() 
    def __init__(self, **kwargs):          
        super(MainScreen, self).__init__(**kwargs)
    def onPow(self,fir,sec):
        a = 0
        b = 0
        for i in range((10000)):
            print(b)
            self.ids.result.text=str(b*(int(fir)*int(sec)+i))
            b+=1
class TestApp(App):
    def build(self):
        return MainScreen()

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

初始屏幕的图像: Sample image for splash screen

我们甚至可以在此图像上使用标签。谢谢。

0 个答案:

没有答案