def show_table(self): form = Form() form.add(w.SubmitWidget, "prev", "prev") form.add(w.SubmitWidget, "next", "next") if form.is_submitted(): if form["prev"]: self.table.cycle.prev() elif form["next"]: self.table.cycle.next() return htmltext(self.table.render()) + form.render()
def stopper(): stop = get_field("stop") if stop: player.kill() return simplepage(body = "%s stopped." % song) else: f = Form() f.add_submit("stop", "Stop") return simplepage(body= ("Playing %s" % song) + f.render())
def select_histo(self): form = Form() form.add(w.SingleSelectWidget, "kind", options=["genre", "nation"]) form.add(w.SubmitWidget, "submit", "Choose!") if form.is_submitted(): return self.show_histo(form["kind"]) else: return form.render()
def form_with_submit(self): form = Form() form.add(StringWidget, "Telefono", value="XXX") form.add(SubmitWidget, "submit", value="ok") if not form.is_submitted(): return form.render() else: return self.thank_you(form["Telefono"])
def mutande(self): msg = htmltext(""" Abbiamo disponili i seguenti modelli: <br/> <br/> A. mutanda modello base <br/> B. mutandina di pizzo per signore <br/> C. mutandone ascellare modello Fantozzi <br/> """) form = Form() form.add(CheckboxWidget, "modelloA", value=0) form.add(CheckboxWidget, "modelloB", value=0) form.add(CheckboxWidget, "modelloC", value=1) form.add(SubmitWidget, "submit", "Compra!") return msg + form.render()
def add_book(self): form = Form() for field in Book.FIELDS: form.add(StringWidget, field, title=field) form.add(SubmitWidget, "submit") if not form.is_submitted(): return form.render() else: self.db.add_book(*[form[field] for field in Book.FIELDS]) self.db.commit() return "A new book has been added!"
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()
def maketable(self): 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()
def edit_book(self): "" form = Form() for field in Book.FIELDS: form.add(StringWidget, field, title=field, value=getattr(self.currentbook, field)) form.add(SubmitWidget, "submit") if not form.is_submitted(): return form.render() else: self.db.edit_book(self.currentbook.dbkey, *[form[field] for field in Book.FIELDS]) self.db.commit() return "The book has been edited!"
def calzini(self): msg = htmltext(""" Abbiamo disponili i seguenti modelli: <br/> <br/> A. Calzettone lungo da neve <br/> B. Calzino di seta estivo <br/> C. Calzino nero lutto <br/> """) form = Form() form.add(RadiobuttonsWidget, "calzini", options=list("ABC")) form.add(SubmitWidget, "submit", "Compra!") return msg + form.render()
def selector(songs): global player, song chosen = get_field("select") if chosen: song = chosen player = play(song) redirect("stopper") # works with Mozilla, but not with lynx/elinks else: f = Form() f.add_single_select("select", options=songs) f.add_submit("play", "Play!") return f.render()
def user_passwd_form(): form = Form() form.add(StringWidget, "un", title="Username") form.add(PasswordWidget, "pw", title="Password") form.add(SubmitWidget, "submit", "Submit") return form
def un_pw_form(): form = Form() form.add(StringWidget, 'username', title="Username") form.add(PasswordWidget, 'password', title="Password") form.add(SubmitWidget, "submit", "Submit") return form