Экран не меняется после нажатия кнопки в симуляторе Xcode - PullRequest
0 голосов
/ 01 мая 2019

Мое приложение Kivy отлично работает в python2.Запуск в симуляторе Xcode (10.1) дает мне главный экран, но нажатие кнопки не возвращает меня ко второму (экран рисования).Интересно, что при перемещении и нажатии на мышь приложение выводит координаты как следует.Я попытался создать очень простой проект только с 1 кнопкой и 2 экранами: опять же, на Python работает нормально, но в симуляторе нет.

Есть предложения?

python

class MainScreen(Screen):  

    username = ObjectProperty(None)
    test_type = ObjectProperty(None)
    test_date = ObjectProperty(None)

    def reset(self):
        self.username.text = ""
        self.test_type.text = ""
        self.test_date.text = ""

class SecondScreen(Screen):
    pass     
class AnotherScreen(Screen):
    pass
class ScreenManagement(ScreenManager):
    pass

class DrawInput(Widget):

    def on_touch_down(self, touch):

        timing_ms = ApplePenApp.get_running_app().sw_seconds
        print('test')

        with self.canvas:
            Color(0, 0, 0)
            touch.ud["line"] = Line(points = (touch.x, touch.y))    

    def on_touch_move(self, touch):
        timing_ms = ApplePenApp.get_running_app().sw_seconds
        touch.ud["line"].points += (touch.x, touch.y)

    def on_touch_up(self, touch):     
        timing_ms = ApplePenApp.get_running_app().sw_seconds

presentation = Builder.load_file("applepen_kivy.kv")

class ApplePenApp(App):
    def build(self):
        return presentation

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

Kivy

# File name: main.py
#: import FadeTransition kivy.uix.screenmanager.FadeTransition

ScreenManagement:
    transition: FadeTransition()
    MainScreen:
        id: main
    SecondScreen:

    AnotherScreen:

<MainScreen>:
    name: "main"
    #define global variables 
    username: username
    test_type: test_type
    test_date: test_date

    GridLayout:
        cols:1
        #organise the window
        size: root.width, root.height

        GridLayout:
            cols: 2

            Label: 
                text: "Username: "
                color: 0.5,0.5, 0.5, 1
                font_size: 30
            TextInput:
                id: username
                multiline: False
                font_size: 30
            Label: 
                text: "Copy/Recall/Recall2: "
                color: 0.5,0.5, 0.5, 1
                font_size: 30
            TextInput:
                id: test_type
                multiline: False
                font_size: 30
            Label: 
                text: "Date: "
                color: 0.5,0.5, 0.5, 1
                font_size: 30
            TextInput:
                id: test_date
                multiline: False
                font_size: 30

        Button:
            font_size: 30
            size_hint: 0.5, 0.5
            text: "Submit"
            on_press: app.root.current = "drawing" 


<SecondScreen>:
    name: "drawing"

    FloatLayout:

        DrawInput:
            id: drawing

        Button:
            font_size: 30
            size_hint: 0.2, 0.05
            pos_hint: {"x": 0.4, "bottom": 1}
            text: "finish"
            on_release: app.root.current = "main"

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...