(self, misc, *add)
Print a menu with checkable entries
Print a menu with checkable entries
Print a menu with checkable entries
def gen_check_menu(self, misc, *add):
        '''Print a menu with checkable entries'''

        if len(misc) == 0:
            return False
        items = []
        for i in range(len(misc)):
            items.append(0)
        highlight = 1
        h_color = 6
        n_color = 1
        e = ''
        while e != NL:
            try:
                self.stdscr.clear()
                self.stdscr.addstr(
                    0, 0, self.loginname + '@' + self.hostname + ':',
                    cur.color_pair(2))
                self.stdscr.addstr(0,
                                   len(self.loginname +
                                       '@' + self.hostname + ':'),
                                   self.cur_dir)
                for i, j, k in misc:
                    if items[i - 1] == 0:
                        check = '[ ]'
                    else:
                        check = '[X]'
                    if i == highlight:
                        self.stdscr.addstr(
                            i, j, check + k, cur.color_pair(h_color))
                    else:
                        self.stdscr.addstr(
                            i, j, check + k, cur.color_pair(n_color))
                for i, j, k in add:
                    self.stdscr.addstr(i, j, k)
            except:
                pass
            finally:
                self.stdscr.refresh()
            try:
                e = self.stdscr.getch()
            except KeyboardInterrupt:
                e = 4
            if e == 4:
                return -1
            elif e == cur.KEY_RESIZE:
                self.resize_all()
            elif e == cur.KEY_F5:
                return False
            elif e == SP:
                if items[highlight - 1] == 0:
                    items[highlight - 1] = 1
                else:
                    items[highlight - 1] = 0
            elif (e == cur.KEY_DOWN or e == ord('j')) and highlight < len(misc):
                highlight += 1
            elif (e == cur.KEY_UP or e == ord('k')) and highlight > 1:
                highlight -= 1
            elif e == NL:
                return items
def gen_check_menu ( self , misc , * add ) : if len ( misc ) == 0 : return False items = [ ] for i in range ( len ( misc ) ) : items . append ( 0 ) highlight = 1 h_color = 6 n_color = 1 e = '' while e != NL : try : self . stdscr . clear ( ) self . stdscr . addstr ( 0 , 0 , self . loginname + '@' + self . hostname + ':' , cur . color_pair ( 2 ) ) self . stdscr . addstr ( 0 , len ( self . loginname + '@' + self . hostname + ':' ) , self . cur_dir ) for i , j , k in misc : if items [ i - 1 ] == 0 : check = '[ ]' else : check = '[X]' if i == highlight : self . stdscr . addstr ( i , j , check + k , cur . color_pair ( h_color ) ) else : self . stdscr . addstr ( i , j , check + k , cur . color_pair ( n_color ) ) for i , j , k in add : self . stdscr . addstr ( i , j , k ) except : pass finally : self . stdscr . refresh ( ) try : e = self . stdscr . getch ( ) except KeyboardInterrupt : e = 4 if e == 4 : return - 1 elif e == cur . KEY_RESIZE : self . resize_all ( ) elif e == cur . KEY_F5 : return False elif e == SP : if items [ highlight - 1 ] == 0 : items [ highlight - 1 ] = 1 else : items [ highlight - 1 ] = 0 elif ( e == cur . KEY_DOWN or e == ord ( 'j' ) ) and highlight < len ( misc ) : highlight += 1 elif ( e == cur . KEY_UP or e == ord ( 'k' ) ) and highlight > 1 : highlight -= 1 elif e == NL : return items