Пример #1
0
    def display(self):
        '''Create a GUI panel and display it for the user.'''
        pages = self.pages() or 1
        language = self.get_language()
        tb = []
        # add title
        tb.append('%-25s'%(self._popup.title))
        # add description
        if self._popup.description:
            tb.append('%s\n'%self._popup.description)
        # add separating slashes
        if pages == 0:
            # empty menu
            tb.append(spmenu_resources.get_string('empty', language))
        else:
            # add options
            self._add_options(tb)
            # add separating slashes
            tb.append(' ')
            # add page navigation links
            if pages > 1:
                s_prev = spmenu_resources.get_string('prev', language)
                s_next = spmenu_resources.get_string('next', language)
                if self.pagenum == 1:
                    # tb.append('8. %s'%s_prev)
                    tb.append(' ')
                else:
                    tb.append('->8. %s\n'%s_prev)
                if self.pagenum == pages:
                    # tb.append('9. %s\n'%s_next)
                    tb.append(' ')
                else:
                    tb.append('->9. %s\n'%s_next)
            else:
                tb.append(' ')
                tb.append(' ')

        # add exit button
        tb.append('0. %s'%spmenu_resources.get_string('cancel', language))
        #display it
        text = '\n'.join(tb)
        dbgmsg(2, 'es.menu(%d, %d, textlen=%d, %s'%(
            0, self._user.userid, len(text), self._popup.enable_keys))
        es.menu(0, self._user.userid, text, self._popup.enable_keys)
Пример #2
0
 else:
     self._final_contents = list(self._popup) + self._contents
 pages = self.pages()
 language = self.get_language()
 tb = []
 # add title
 tb.append('%-25s(%d/%d)'%(self.title or self._popup.title,
     self.pagenum, pages or 1))
 # add description
 if self.description:
     tb.append('%s\n'%self.description or self._popup.description)
 # add separating slashes
 tb.append('-'*30)
 if pages == 0:
     # empty menu
     tb.append(spmenu_resources.get_string('empty', language))
 else:
     # add options
     minopt = (self.pagenum-1)*self._popup.options_per_page
     maxopt = self.pagenum*self._popup.options_per_page
     index = 0
     for index, option in enumerate(self._final_contents[minopt:maxopt]):
         tb.append(str(option)%(index+1))
     for i in xrange(self._popup.options_per_page-index-1):
         tb.append(' ')
     # add separating slashes
     tb.append('-'*30)
     # add page navigation links
     if pages > 1:
         s_prev = spmenu_resources.get_string('prev', language)
         s_next = spmenu_resources.get_string('next', language)