def display(self):
        self.panel.top()
        self.panel.show()
        self.window.clear()

        while True:
            self.window.refresh()
            curses.doupdate()

            for index, item in enumerate(self.items):
                if index == self.position:
                    mode = curses.A_REVERSE
                else:
                    mode = curses.A_NORMAL

                self.window.addstr(index, 1, str(item), mode)

            key = self.window.getch()

            if key in [curses.KEY_ENTER, ord('\n')]:
                self.pytify.listen(int(self.position - 1))

            elif key == curses.KEY_UP:
                self.navigate(-1)

            elif key == curses.KEY_DOWN:
                self.navigate(1)

            elif key == curses.KEY_LEFT:
                self.pytify.prev()

            elif key == curses.KEY_RIGHT:
                self.pytify.next()

            # spacebar
            elif key == 32:
                self.pytify.play_pause()

            # escape
            elif key == 27:
                break

        self.window.clear()
        self.panel.hide()
        panel.update_panels()
        curses.doupdate()
dataset/ETHPy150Open bjarneo/Pytify/pytify/menu.py/Menu.display/original