这只是一个小测试kivy应用程序。当我通过鼠标调整窗口大小时,所有元素都会消失,并留下黑色窗口。我是python的新手,请帮我解决。
from kivy.app import App
#kivy.require('1.9.1')
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
class LoginScreen(GridLayout):
def __init__(self, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text="Username:"))
self.username = TextInput(multiline=False)
self.add_widget(self.username)
class SimpleKivy(App):
def build(self):
return LoginScreen()
if __name__ == "__main__":
SimpleKivy().run()
这是控制台错误信息:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/vucheqh/PycharmProjects/mobile/KivyTest.py
[INFO ] [Logger ] Record log in /Users/vucheqh/.kivy/logs/kivy_16-08-26_12.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_imageio, img_dds, img_gif, img_pygame, img_pil (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: pygame
[INFO ] [Window ] Provider: pygame
[ERROR ] [WinPygame ] unable to set icon
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/window/window_pygame.py", line 215, in set_icon
self._set_icon_standard(filename)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/window/window_pygame.py", line 227, in _set_icon_standard
im = pygame.image.load(filename)
pygame.error: Failed loading libpng.dylib: dlopen(libpng.dylib, 2): image not found
[INFO ] [GL ] OpenGL version <b'2.1 INTEL-10.14.73'>
[INFO ] [GL ] OpenGL vendor <b'Intel Inc.'>
[INFO ] [GL ] OpenGL renderer <b'Intel HD Graphics 5000 OpenGL Engine'>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <b'1.20'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [Base ] Start application main loop
[INFO ] [GL ] NPOT texture support is available
[ERROR ] [WinPygame ] unable to set icon
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/window/window_pygame.py", line 215, in set_icon
self._set_icon_standard(filename)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/kivy/core/window/window_pygame.py", line 227, in _set_icon_standard
im = pygame.image.load(filename)
pygame.error: Failed loading libpng.dylib: dlopen(libpng.dylib, 2): image not found
[INFO ] [Context ] Reloading graphics data...
[INFO ] [Context ] Reloading done in 0.0291s
Exception ignored in: 'kivy.graphics.context.Context.dealloc_texture'
OverflowError: signed integer is greater than maximum