Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from pyjamas import Window
- from pyjamas.ui.HTML import HTML
- from pyjamas.ui.RootPanel import RootPanel
- from pyjamas.ui.FormPanel import FormPanel
- from pyjamas.ui.StackPanel import StackPanel
- from pyjamas.ui.DockPanel import DockPanel
- from pyjamas.ui.VerticalPanel import VerticalPanel
- from pyjamas.ui.HorizontalPanel import HorizontalPanel
- from pyjamas.ui.Button import Button
- from pyjamas.ui.TextArea import TextArea
- from pyjamas.ui.TextBox import TextBox
- from pyjamas.ui.Label import Label
- from pyjamas.ui.ListBox import ListBox
- class ContactPanel:
- def onModuleLoad(self):
- # Contact info
- panelContact = VerticalPanel()
- panelContact.add(HTML("Name:"))
- panelContact.add(HTML("E-Mail:"))
- # Personal Information
- panelInfo = VerticalPanel()
- panelInfo.add(HTML("WebPage:"))
- panelInfor.add(HTML("Job:"))
- # Adresses
- panelAddress = VerticalPanel()
- panelAddress.add(HTML("Home Address:"))
- panelAddress.add(HTML("Work Address"))
- # Additional Notes
- panelNotas = VerticalPanel()
- panelNotas.add(HTML("Notes"))
- # Add the panes in a stack
- stack = StackPanel(Width="100%", Height="100px")
- stack.add(panelContact,"Contact")
- stack.add(panelInfo,"Personal Info")
- stack.add(panelAddress,"Adresses")
- stack.add(panelNotes,"Notes")
- # Buttons
- panelButton = HorizontalPanel()
- panelButton.add(HTML("Submit"))
- panelButton.add(HTML("Clear"))
- # Create content body
- content = VerticalPanel()
- content.add(HTML("Fill fields below:</br>")
- content.add(stack)
- content.add(panelButton)
- # Define web page as a dock
- page = DockPanel(BorderWidth=1, Padding=8,
- HorizontalAlignment=HasAlignment.ALIGN_CENTER,
- VerticalAlignment=HasAlignment.ALIGN_MIDDLE)
- # Dummy content to dock sections
- header = HTML("<H1>Contact-me</H1>")
- left = Label("LEFT HOLDER")
- right = Label("RIGHTHOLDER")
- footer = HTML("(c)All rights reserved. Gnu/GPL")
- # Add things to dockpanel Page
- page.add(header, DockPanel.NORTH)
- page.add(west, DockPanel.WEST)
- page.add(content, DockPanel.CENTER)
- page.add(east, DockPanel.EAST)
- page.add(footer, DockPanel.SOUTH)
- page.setCellHeight(center, "600px")
- page.setCellWidth (center, "800px")
- # Add page to RootPanel
- RootPanel().add(pagina)
- ##########################
- ## Form Stuff
- ###########################
- #
- ## Create form and pont to service
- #self.formulario = FormPanel()
- #self.formulario.setAction("/submit/")
- #self.formulario.setWidget(panelContato)
- #self.formulario.setWidget(panelInformacoes)
- #self.formulario.setWidget(panelEnderecos)
- #self.formulario.setWidget(panelNotas)
- #self.formulario.setWidget(conteudo)
- #
- ## Add a submit button to form
- #self.form.add(Button("Submit", self))
- #
- ## Add the handler
- #self.form.addFormHandler(self)
- #
- ## Add stack to form (this will change)
- #self.form.add(stack)
- #
- ## Add form to page (changed due Dock)
- #RootPanel().add(self.form)
- def onClick(self, sender):
- self.form.submit()
- def onSubmitComplete(self, event):
- # When the form submission is successfully completed, this event is
- # fired. Assuming the service returned a response of type text/plain,
- # we can get the result text here (see the FormPanel documentation for
- # further explanation).
- Window.alert(event.getResults())
- def onSubmit(self, event):
- # This event is fired just before the form is submitted. We can take
- # this opportunity to perform validation.
- if (self.tb.getText().length == 0):
- Window.alert("The text box must not be empty")
- event.setCancelled(True)
- if __name__ == '__main__':
- app = ContactPanel()
- app.onModuleLoad()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement