1
我正在使用Kivy在Raspi 3上編寫一個圖形用戶界面,並且它一直在工作得很好,但現在我添加了幾個「屏幕」,在返回到前一個屏幕時崩潰。Kivy/Raspi着色器異常
基本上來自模仿我希望能夠去其他三個屏幕(TCS,EPC,CT)中的任何一個,並且能夠返回到Mimic。我可以去模仿和隨後對所有這些屏幕,但點擊返回按鈕,出現以下消息導致程序崩潰:
Traceback (most recent call last):
File "GUI.py", line 1329, in <module>
MainApp().run()
File "/usr/local/lib/python2.7/dist-packages/kivy/app.py", line 828, in run
runTouchApp()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 500, in runTouchApp
EventLoop.window.mainloop()
File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_egl_rpi.py", line 90, in mainloop
self._mainloop()
File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_egl_rpi.py", line 85, in _mainloop
EventLoop.idle()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 339, in idle
self.dispatch_input()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 324, in dispatch_input
post_dispatch_input(*pop(0))
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 290, in post_dispatch_input
wid.dispatch('on_touch_up', me)
File "kivy/_event.pyx", line 718, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:8191)
File "/usr/local/lib/python2.7/dist-packages/kivy/uix/behaviors/button.py", line 179, in on_touch_up
self.dispatch('on_release')
File "kivy/_event.pyx", line 714, in kivy._event.EventDispatcher.dispatch (kivy/_event.c:8146)
File "kivy/_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy/_event.c:14035)
File "kivy/_event.pyx", line 1109, in kivy._event.EventObservers._dispatch (kivy/_event.c:12816)
File "/usr/local/lib/python2.7/dist-packages/kivy/lang/builder.py", line 64, in custom_callback
exec(__kvlang__.co_value, idmap)
File "<string>", line 540, in <module>
File "kivy/properties.pyx", line 423, in kivy.properties.Property.__set__ (kivy/properties.c:5572)
File "kivy/properties.pyx", line 461, in kivy.properties.Property.set (kivy/properties.c:6405)
File "kivy/properties.pyx", line 516, in kivy.properties.Property.dispatch (kivy/properties.c:7105)
File "kivy/_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy/_event.c:14035)
File "kivy/_event.pyx", line 1131, in kivy._event.EventObservers._dispatch (kivy/_event.c:13193)
File "/usr/local/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 973, in on_current
self.transition.start(self)
File "/usr/local/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 369, in start
self.add_screen(self.screen_in)
File "/usr/local/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 505, in add_screen
self.fbo_out = self.make_screen_fbo(self.screen_out)
File "/usr/local/lib/python2.7/dist-packages/kivy/uix/screenmanager.py", line 469, in make_screen_fbo
fbo = Fbo(size=screen.size)
File "kivy/graphics/fbo.pyx", line 150, in kivy.graphics.fbo.Fbo.__init__ (kivy/graphics/fbo.c:3155)
File "kivy/graphics/instructions.pyx", line 754, in kivy.graphics.instructions.RenderContext.__init__ (kivy/graphics/instructions.c:11094)
File "kivy/graphics/shader.pyx", line 186, in kivy.graphics.shader.Shader.__init__ (kivy/graphics/shader.c:4152)
File "kivy/graphics/shader.pyx", line 695, in kivy.graphics.shader.Shader.vs.__set__ (kivy/graphics/shader.c:11550)
File "kivy/graphics/shader.pyx", line 557, in kivy.graphics.shader.Shader.build_vertex (kivy/graphics/shader.c:9283)
File "kivy/graphics/shader.pyx", line 587, in kivy.graphics.shader.Shader.link_program (kivy/graphics/shader.c:9736)
Exception: Shader didnt link, check info log.
全部代碼是在這裏:https://github.com/ISS-Mimic/Mimic/blob/master/Pi/GUI.py
相關的(我認爲)片段:
class MainApp(App):
def build(self):
self.mimic_screen = MimicScreen(name = 'mimic')
self.fakeorbit_screen = FakeOrbitScreen(name = 'fakeorbit')
self.eps_screen = EPS_Screen(name = 'eps')
self.ct_screen = CT_Screen(name = 'ct')
self.tcs_screen = TCS_Screen(name = 'tcs')
root = MainScreenManager(transition=WipeTransition())
root.add_widget(MainScreen(name = 'main'))
root.add_widget(CalibrateScreen(name = 'calibrate'))
root.add_widget(self.mimic_screen)
root.add_widget(self.fakeorbit_screen)
root.add_widget(self.eps_screen)
root.add_widget(self.ct_screen)
root.add_widget(self.tcs_screen)
root.add_widget(ManualControlScreen(name = 'manualcontrol'))
root.current= 'main'
Clock.schedule_interval(self.update_labels, 1)
Clock.schedule_interval(self.checkAOSlong, 5)
return root
和KV代碼:
Builder.load_string('''
#:kivy 1.8
#:import kivy kivy
#:import win kivy.core.window
ScreenManager:
MainScreen:
FakeOrbitScreen:
EPS_Screen:
CT_Screen:
TCS_Screen:
ManualControlScreen:
MimicScreen:
CalibrateScreen:
<MainScreen>:
name: 'main'
FloatLayout:
orientation: 'vertical'
Image:
source: './imgs/iss.png'
allow_stretch: True
keep_ratio: True
Button:
size_hint: 0.3,0.1
pos_hint: {"center_x": 0.2, "center_y": 0.9}
text: 'Fake Orbit'
font_size: 30
width: 50
height: 20
on_release: root.manager.current = 'fakeorbit'
BoxLayout:
size_hint_y: None
Button:
text: 'Control'
font_size: 30
width: 50
height: 20
on_press: root.changeManualControlBoolean(True)
on_release: root.manager.current = 'manualcontrol'
Button:
text: 'Calibrate'
font_size: 30
width: 50
height: 20
on_release: root.manager.current = 'calibrate'
on_release: my_button.disabled = False
MyButton:
id: my_button
text: 'Mimic'
disabled: True
font_size: 30
width: 50
height: 20
on_release: app.root.current = 'mimic'
Button:
text: 'Exit'
font_size: 30
width: 50
height: 20
on_release: app.stop(*args)
<FakeOrbitScreen>:
name: 'fakeorbit'
...
<ManualControlScreen>:
name: 'manualcontrol'
...
<CalibrateScreen>:
name: 'calibrate'
...
<CT_Screen>:
name: 'ct'
FloatLayout:
Image:
source: './imgs/iss2.png'
allow_stretch: True
keep_ratio: False
Button:
size_hint: 0.3,0.1
pos_hint: {"Left": 1, "Bottom": 1}
text: 'Return'
font_size: 30
on_release: app.root.current = 'mimic'
<TCS_Screen>:
name: 'tcs'
FloatLayout:
Image:
source: './imgs/iss2.png'
allow_stretch: True
keep_ratio: False
Button:
size_hint: 0.3,0.1
pos_hint: {"Left": 1, "Bottom": 1}
text: 'Return'
font_size: 30
on_release: app.root.current = 'mimic'
<EPS_Screen>:
name: 'eps'
FloatLayout:
Image:
source: './imgs/iss2.png'
allow_stretch: True
keep_ratio: False
Button:
size_hint: 0.3,0.1
pos_hint: {"Left": 1, "Bottom": 1}
text: 'Return'
font_size: 30
on_release: app.root.current = 'mimic'
<MimicScreen>:
name: 'mimic'
FloatLayout:
id: mimicscreenlayout
Image:
source: './imgs/iss2.png'
allow_stretch: True
keep_ratio: False
Button:
size_hint: 0.3,0.1
pos_hint: {"center_x": 0.65, "center_y": 0.65}
text: 'EPS'
font_size: 30
on_release: root.manager.current = 'eps'
Button:
size_hint: 0.3,0.1
pos_hint: {"center_x": 0.65, "center_y": 0.5}
text: 'CT'
font_size: 30
on_release: root.manager.current = 'ct'
Button:
size_hint: 0.3,0.1
pos_hint: {"center_x": 0.65, "center_y": 0.35}
text: 'TCS'
font_size: 30
on_release: root.manager.current = 'tcs'
Button:
size_hint: 0.3,0.1
pos_hint: {"Left": 1, "Bottom": 1}
text: 'Return'
font_size: 30
on_release: root.changeMimicBoolean(False)
on_release: root.changeSwitchBoolean(False)
on_release: app.root.current = 'main'
''')
從GUI參考圖片:每個屏幕的作品,除了在從EPS返回精細,TCS,或CT(返回返回到主從模仿正常工作)
任何幫助將非常感激。僅供參考我是kivy和python的新手,幾乎不知道我在做什麼...