Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当我覆盖了内置的on_touch_down和on_touch_move方法时,如何手动使滚动管理器工作?_Python_Kivy - Fatal编程技术网

Python 当我覆盖了内置的on_touch_down和on_touch_move方法时,如何手动使滚动管理器工作?

Python 当我覆盖了内置的on_touch_down和on_touch_move方法时,如何手动使滚动管理器工作?,python,kivy,Python,Kivy,因此,我设法使按钮在我的应用程序中工作,方法是说,如果x和y正确(按钮所在的位置),则按下按钮,然后: “tagasi”是按钮的名称。 现在,下一个障碍是如何使scrollview工作,因为这似乎不是那么容易。为了让kivy接受触摸输入(我正在为IOS开发这个应用程序),我必须手动重写大部分功能。不理想,但少抱怨,多工作。 因此,如果按钮是这样工作的: def on_touch_down(self, touch): if self.manager.current == "sc2":

因此,我设法使按钮在我的应用程序中工作,方法是说,如果x和y正确(按钮所在的位置),则按下按钮,然后:

“tagasi”是按钮的名称。 现在,下一个障碍是如何使scrollview工作,因为这似乎不是那么容易。为了让kivy接受触摸输入(我正在为IOS开发这个应用程序),我必须手动重写大部分功能。不理想,但少抱怨,多工作。 因此,如果按钮是这样工作的:

def on_touch_down(self, touch):
    if self.manager.current == "sc2":
        if 0 < touch.y/self.height < 0.2 and touch.x/self.width > 0 and touch.x/self.width < 1:
            self.tagasi.state = "down"
            self.tagasi.dispatch('on_press')

Screen:
    name: "sc2"

    size: root.width, root.height
    FloatLayout:

        Button:
            id: tagasi
            size_hint: 1, 0.2
            pos_hint: {"right":1, "bottom": 0}
            text: "go back"
            on_press:
                manager.current = "sc1"
                manager.transition.direction = "right"


    ScrollView:
        do_scroll_x: False
        do_scroll_y: True
        id: kerimine
        Label:
            size_hint_y: None
            height: self.texture_size[1]
            text_size: root.width, root.height
            padding: 10, 10
            text:
                'really some amazing text\n' * 100

我希望ScrollView正常工作,但不知道如何手动重写所有必要的内容(就像我用按钮手动告诉它“按”)

而不是将触摸位置与self.height/width进行比较,最好使用要激活的子按钮的
collide\u point
方法。至于实际问题,不要试图重写,而是在必要时重写。在这种情况下,如果您不想劫持touch事件来激活您的按钮,那么此时您只需调用
super()。
Screen:
    name: "sc2"

    size: root.width, root.height
    FloatLayout:

        Button:
            id: tagasi
            size_hint: 1, 0.2
            pos_hint: {"right":1, "bottom": 0}
            text: "go back"
            on_press:
                manager.current = "sc1"
                manager.transition.direction = "right"


    ScrollView:
        do_scroll_x: False
        do_scroll_y: True
        id: kerimine
        Label:
            size_hint_y: None
            height: self.texture_size[1]
            text_size: root.width, root.height
            padding: 10, 10
            text:
                'really some amazing text\n' * 100