所以我在看this视频,我跟他一样跟着他,我像他一样写代码,但当我运行时,它不会出错,而是返回一个空白屏幕而不是计算器UI,另一个视频也发生了同样的事情。。(P.S我的kivy版本是1.10.1)
[INFO ] [Logger ] Record log in C:\Users\Erfan\.kivy\logs\kivy_19-01-
01_23.txt
[INFO ] [Kivy ] v1.10.1
[INFO ] [Python ] v3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018,
23:09:28) [MSC v.1916 64 bit (AMD64)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_gif
(img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[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.5.0 NVIDIA 353.62'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'GeForce GT 730/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 5
[INFO ] [GL ] Shading version <b'4.50 NVIDIA'>
[INFO ] [GL ] Texture max size <16384>
[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
[INFO ] [Base ] Leaving application in progress...
这是我的代码,没有错误。你知道吗
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Label
from kivy.uix.widget import Widget
kivy.require("1.10.1")
class CalcGridLayout(GridLayout):
pass
class CalculatorApp(App):
def LoginForm(self):
return CalcGridLayout
calcApp = CalculatorApp()
calcApp.run()
它重定向到我创建的一个名为“的文件”计算器.kv" 这些是文件中的代码。你知道吗
<CustButton@Button>:
font_size: 32
<CalcGridLayout>:
id: calculator
display: entry
rows: 5
padding: 10
spacing: 10
BoxLayout:
TextInput:
id: entry
font_size: 32
multiline: False
BoxLayout:
spacing: 10
CustButton:
text: "7"
on_press: entry.text += self.text
CustButton:
text: "8"
on_press: entry.text += self.text
CustButton:
text: "9"
on_press: entry.text += self.text
CustButton:
text: "+"
on_press: entry.text += self.text
BoxLayout:
spacing: 10
CustButton:
text: "4"
on_press: entry.text += self.text
CustButton:
text: "5"
on_press: entry.text += self.text
CustButton:
text: "6"
on_press: entry.text += self.text
CustButton:
text: "-"
on_press: entry.text += self.text
BoxLayout:
spacing: 10
CustButton:
text: "1"
on_press: entry.text += self.text
CustButton:
text: "2"
on_press: entry.text += self.text
CustButton:
text: "3"
on_press: entry.text += self.text
CustButton:
text: "*"
on_press: entry.text += self.text
BoxLayout:
spacing: 10
CustButton:
text: "AC"
on_press: entry.text = ""
CustButton:
text: "0"
on_press: entry.text += self.text
CustButton:
text: "="
on_press: entry.text += self.text
CustButton:
text: "/"
on_press: entry.text += self.text
是的!我发现了这个问题,问题是我可能使用了LoginForm,这与我们需要的完全不同,所以我基本上需要做的是改变LoginForm来构建。你知道吗
我是说从
至
我认为您错过了python文件中return CalcGridLayout之后的括号
相关问题 更多 >
编程相关推荐