Kivy:试图在Raspberry Pi上运行一个kivy应用程序时出现白屏

时间:2016-03-02 20:07:05

标签: raspberry-pi screen kivy raspbian

我是Kivy编程的新手,我正在为我的大学做一个项目。我有一个带有16Gb SD卡的Raspberry Pi 2,我已经安装了Raspbian Jessie和Kivy 1.9.2。

我写了一个简单的代码,基本上只是一个屏幕管理器。有六个按钮,每个按钮打开一个新屏幕。 (此时屏幕只包含一个文本和一个"后退"按钮)这个kivy应用程序在我的计算机上工作正常(Windows 7)但是当我尝试用覆盆子pi运行它时我只得到一个白色的空白屏幕。 (运行应用程序时,我在CLI上没有任何错误消息)

我尝试过其他一些kivy应用程序,例如" showcase"从kivy的examples文件夹中,它工作正常。我试图从kivy运行很多例子,我注意到一些应用程序运行正常,而其他应用程序只是给出一个空白屏幕。有任何想法吗?有RAM情况吗?谢谢!

from kivy.app import App
#kivy.require("1.9.2")
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from glob import glob
from os.path import dirname, join, basename
from kivy.uix.screenmanager import ScreenManager, Screen, WipeTransition
from kivy.uix.label import Label
from kivy.uix.widget import Widget
from kivy.uix.videoplayer import VideoPlayer
from kivy.clock import Clock
from kivy.graphics import Line,Color,Ellipse


class MainScreen(Screen):
   pass

class ScreenOne(Screen):
   pass

class ScreenTwo(Screen):
   pass

class ScreenThree(Screen):
   pass

class ScreenFour(Screen):
   pass

class ScreenFive(Screen):
   pass

class ScreenSix(Screen):
   pass

class ScreenManagement(ScreenManager):
   pass

presentation = Builder.load_file("Interface4.kv")

class Interface4(App):
   def build(self):
    return presentation

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

Interface4.kv

#: import WipeTransition kivy.uix.screenmanager.WipeTransition

  ScreenManagement:
    transition: WipeTransition()
    MainScreen:
    ScreenOne:
    ScreenTwo:
    ScreenThree:
    ScreenFour:
    ScreenFive:
    ScreenSix:

这些屏幕中的每个屏幕都只包含基本文本和"返回上一屏幕"按钮。例如。

<ScreenOne>
name: "other1"
orientation: 'vertical'
canvas:
    Color:
        rgb: 0, 0, 1
    Rectangle:
        source: 'data/images/background.jpg'
        size: self.size
FloatLayout:        
    Button:
        on_release: app.root.current = "main"
        background_color: 0,0,1,0
        text_size: self.size 
        font_size: 20
        pos_hint: {'x': .85, 'y': .0}
        size_hint: .15, .15
        Image:
            source:'data/images/home.png'
            pos:self.parent.pos
            size:self.parent.size

0 个答案:

没有答案