按照有关kivy的基本教程,尝试运行它,但是弹出的kivy窗口为空白,.kv文件为小写,因此我猜那里没有问题。到处搜索解决方案,但一无所获
正确安装所有软件包,仔细检查kv文件
#main.py#
import kivy
kivy.require('1.10.0')
from kivy.app import App
from kivy.uix.widget import Widget
class CustomWidget(Widget):
pass
class CustomWidgetApp(App):
def build(self):
return CustomWidget()
customWidget = CustomWidgetApp()
customWidget.run()
customwidget.kv:
#customwidget.kv#
<CustButton@Button>:
font_size: 32
color: 0, 0, 0, 1
size: 150, 50
background_normal: ''
background_down: 'bkgrd-down-color.png'
background_color: .88, .88, .88, 1
<CustomWidget>:
CustButton:
text: "Random"
pos: root.x, 200
CustButton:
text: "Buttons"
pos: 200, root.y
CustButton:
text: "Buttons"
pos: 200, 400
期待带有3个按钮的窗口
记录是否有帮助:
[INFO ] [Logger ] Record log in
C:\Users\----\AppData\Roaming\SPB_16.6\.kivy\logs\kivy_19-01-11_28.txt
[INFO ] [Kivy ] v1.10.1
[INFO ] [Python ] v3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC
v.1900 64 bit (AMD64)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil,
img_gif (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 NVIDIA 398.72'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'GeForce GTX 1070/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 NVIDIA'>
[INFO ] [GL ] Texture max size <32768>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Base ] Start application main loop