On_release按钮不起作用,过渡也不起作用

时间:2019-10-17 05:54:36

标签: python kivy kivy-language

我是代码的完整入门者,无法在我的代码中找到问题。这是主文件。我想使用按钮从MainWindow过渡到MakeAcc屏幕。

但是该按钮似乎不响应on_release代码。有什么建议吗?

import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager , Screen
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label
from kivy.properties import ObjectProperty
from kivy.graphics import Color
from kivy.core.window import Window
from kivy.uix.widget import Widget
from kivy.uix.button import Button


class MainWindow(Screen):
    pass


Window.clearcolor = (1, 1, 1, 1)


class MakeAcc(Screen):
    current= "login"


class WindowManager(ScreenManager):
    pass


class Op(App):
    def build(self):
        return MakeAcc()


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

这是KV文件。我尝试复制一个编码器的代码以查看是否可行,但确实找不到我做错的事情。任何帮助将不胜感激。

WindowManager:
    MainWindow:
    MakeAcc:

<MainWindow>:
    name: "login"


    FloatLayout:

        Label:
            text: "Popeye"
            pos_hint: { "x": 0.3,"top": 1}
            font_size: 40
            size_hint: 0.35, 0.15
            color: [0,0,0,1]

        Label:
            text: "Email Address:  "
            pos_hint: { "x": 0.1,"top": 0.8}
            font_size: 30
            size_hint: 0.35, 0.15
            color: [0,0,0,1]



        TextInput:
            multiline: False
            size_hint: 0.4, 0.15
            pos_hint: {"x": 0.5, "top": 0.8}


        Label:
            text: "Password:  "
            pos_hint: { "x": 0.1,"top": 0.5}
            font_size: 30
            size_hint: 0.35, 0.15
            color: [0,0,0,1]


        TextInput:
            multiline: False
            size_hint: 0.4, 0.15
            pos_hint: {"x": 0.5, "top": 0.5}

        Button:

            text: "Submit"
            on_press:
                app.root.current = "create"
            size_hint: 0.6, 0.14
            pos_hint: {"x": 0.2, "top": 0.2}
            background_color: [0,0,0,1]



        Button:

            text: "Don't Have An Account? Create One Today!"
            size_hint: 0.4, 0.08
            pos_hint: {"x": 0.3, "top": 0.3}
            background_color: [0,0,0,1]





<MakeAcc>:
     name:"create"


     FloatLayout:
         Label:
            text: "Create An Account"
            pos_hint: { "x": 0.35,"y": 0.8}
            font_size: 40
            size_hint: 0.35, 0.15
            color: [0,0,0,1]

        Label:
            text: "Username:  "
            pos_hint: { "x": 0.1,"y": 0.6}
            font_size: 20
            size_hint: 0.35, 0.07
            color: [0,0,0,1]



        TextInput:
            multiline: False
            size_hint: 0.4, 0.07
            pos_hint: {"x": 0.5, "y": 0.6}


        Label:
            text: "Email:  "
            pos_hint: { "x": 0.1,"y": 0.5}
            font_size: 20
            size_hint: 0.35, 0.07
            color: [0,0,0,1]


        TextInput:
            multiline: False
            size_hint: 0.4, 0.07
            pos_hint: {"x": 0.5, "y": 0.5}

        Label:
            text: "Password:  "
            pos_hint: { "x": 0.1,"y": 0.4}
            font_size: 20
            size_hint: 0.35, 0.07
            color: [0,0,0,1]


        TextInput:
            multiline: False
            size_hint: 0.4, 0.07
            pos_hint: {"x": 0.5, "y": 0.4}

        Button:

            text: "Submit"
            size_hint: 0.55, 0.14
            pos_hint: {"x": 0.25, "top": 0.2}
            background_color: [0,0,0,1]
            on_release:
                app.root.current="login"
                root.manager.transition.direction = "down"

        Button:

            text: "Already Have An Account? Click Here to Login"
            size_hint: 0.4, 0.08
            pos_hint: {"x": 0.33, "top": 0.3}
            background_color: [0,0,0,1]

0 个答案:

没有答案