4

Urwidの水平メニューの例に基づいてアプリを構築しています。情報を表示したいアイテムがあります。下に「OK」ボタンがあり、メニューを前の状態に戻すか、画面全体/ループを再起動したい。

この例では、 を使用していますExitMainLoop()が、終了したくありません。ただ再起動したいだけです。そのため、コールバックを別の関数に変更しましたが、すべての試みは何もしないか、プログラムをクラッシュさせます。

関連するビットは次のとおりです。

メニューの開始:

if __name__ == "__main__":
    top = HorizontalBoxes()
    top.open_box(menu_top([]).menu)
    urwid.MainLoop(urwid.Filler(top, 'middle', 40), palette).run()

関連するメニュー クラス/機能。私の問題は-does_nothing関数には何が入るのですか?

class Choice(urwid.WidgetWrap):
    def __init__(self, caption, pid):
        super(Choice, self).__init__(
            MenuButton(caption, partial(self.item_chosen,pid)))
        self.caption = caption

    def item_chosen(self, pid, button):
        if self.caption == (u"System status"):
            showSystemStatus()


def showSystemStatus():
    response = urwid.Text( "... some text ")
    done = MenuButton(u'OK', does_nothing)
    response_box = urwid.Filler(urwid.Pile([response,done]))
    top.open_box(urwid.AttrMap(response_box, 'options'))

def does_nothing(key):
    ????????????????????
    return
4

1 に答える 1