예제 #1
0
class MultipageTable(object):
    # use Quixote forms
    def __init__(self, body, header=[], maxsize=20):
        self.header = header
        self.maxsize = maxsize
        self.section = Cycle(chop(body, maxsize))
        self.sect = self.section[0]  # default
        self.ismultipage = len(self.section) > 1

    def makerow(self, row, header=False):
        if header:
            r = " ".join("<th>%s</th>" % col for col in row)
        else:
            r = " ".join("<td>%s</td>" % col for col in row)
        return "<tr>%s</tr>" % r

    def maketable(self):
        #yield "<div align='center'>"
        if self.ismultipage:
            form = Form()
            form.add(SubmitWidget, "prev", "Prev")
            form.add(SubmitWidget, "next", "Next")
            if form["next"]:  # is submitted
                self.sect = self.section.next()
            if form["prev"]:  # is submitted
                self.sect = self.section.prev()
            yield "Page #%s of %s" % (self.section.index + 1, len(
                self.section))
        yield "<table border='1'>"
        if self.header:
            yield self.makerow(self.header)
        for row in self.sect:
            yield self.makerow(row)
        yield "</table>"
        if self.ismultipage:
            yield form.render()
        #yield "</div>"

    def render(self):
        return htmltext("\n").join(map(htmltext, self.maketable()))
예제 #2
0
class MultipageTable(object):
    # use Quixote forms
    def __init__(self, body, header=[], maxsize=20):
        self.header = header
        self.maxsize = maxsize
        self.section = Cycle(chop(body, maxsize))
        self.sect = self.section[0] # default
        self.ismultipage = len(self.section) > 1

    def makerow(self, row, header=False):
        if header:
            r = " ".join("<th>%s</th>" % col for col in row)
        else:
            r = " ".join("<td>%s</td>" % col for col in row)
        return "<tr>%s</tr>" % r

    def maketable(self):
        #yield "<div align='center'>"
        if self.ismultipage:
            form = Form()
            form.add(SubmitWidget, "prev", "Prev")
            form.add(SubmitWidget, "next", "Next")
            if form["next"]: # is submitted
                self.sect = self.section.next()
            if form["prev"]: # is submitted
                self.sect = self.section.prev()
            yield "Page #%s of %s" % (self.section.index+1, len(self.section))
        yield "<table border='1'>"
        if self.header:
            yield self.makerow(self.header)
        for row in self.sect:
            yield self.makerow(row)
        yield "</table>"
        if self.ismultipage:
            yield form.render()
        #yield "</div>"

    def render(self):
        return htmltext("\n").join(map(htmltext, self.maketable()))
예제 #3
0
 def __init__(self, body, header=[], maxsize=20):
     self.header = header
     self.maxsize = maxsize
     self.section = Cycle(chop(body, maxsize))
     self.sect = self.section[0] # default
     self.ismultipage = len(self.section) > 1
예제 #4
0
 def __init__(self, body, header=[], maxsize=20):
     self.header = header
     self.maxsize = maxsize
     self.section = Cycle(chop(body, maxsize))
     self.sect = self.section[0] # default
     self.ismultipage = len(self.section) > 1