0

remove_widget関数を使用して、クリック後にボタンを非表示にしようとしています。ドキュメントによると、これがこれを達成する正しい方法だと思います。ただし、ボタンを削除しようとすると、クラッシュします。これがウィジェットへの参照型と関係があるのか​​ どうかはわかりません。

これが私のmain.kvです

<MainPanel>:
orientation: 'vertical'
spacing: 1

AppActionBar:
    size_hint: (1., 0.1)

ScrollView:
    id: scrollview_main
    do_scroll_x: False
    do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16))
    AnchorLayout:
        id: anchorlayout_main
        size_hint_y: None
        height: root.height if root.fullscreen else max(root.height, content.height)
        GridLayout:
            id: content
            cols: 1
            spacing: '8dp'
            padding: '8dp'
            size_hint: (1, 1) if root.fullscreen else (.8, None)
            height: self.height if root.fullscreen else self.minimum_height
            Button:
                id: button_open_process
                size_hint_y: None
                text: 'Open New Process'
                height: '48dp'
                width: '120dp'
                on_release:
                    root.open_process()
                    root.remove_widget(root.button_attach_process) <-- offending line
                    #root.remove_widget(root.button_open_process)
            Button:
                id: button_attach_process
                size_hint_y: None
                text: 'Attach to Currently Running Process'
                height: '48dp'
                width: '120dp'
                on_release: root.attach_process()

ID付きのボタンをクリックするとエラーが発生しますbutton_open_process

AttributeError: 'MainPanel' object has no attribute 'button_attach_process'

この問題の原因は何ですか?

4

1 に答える 1