Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.86 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from pyjamas import Window
  4.  
  5. from pyjamas.ui.HTML import HTML
  6.  
  7. from pyjamas.ui.RootPanel import RootPanel
  8. from pyjamas.ui.FormPanel import FormPanel
  9. from pyjamas.ui.StackPanel import StackPanel
  10. from pyjamas.ui.DockPanel import DockPanel
  11. from pyjamas.ui.VerticalPanel import VerticalPanel
  12. from pyjamas.ui.HorizontalPanel import HorizontalPanel
  13.  
  14. from pyjamas.ui.Button import Button
  15. from pyjamas.ui.TextArea import TextArea
  16. from pyjamas.ui.TextBox import TextBox
  17. from pyjamas.ui.Label import Label
  18. from pyjamas.ui.ListBox import ListBox
  19.  
  20.  
  21. class ContactPanel:
  22.     def onModuleLoad(self):
  23.  
  24.     # Contact info
  25.     panelContact = VerticalPanel()
  26.         panelContact.add(HTML("Name:"))
  27.         panelContact.add(HTML("E-Mail:"))
  28.  
  29.     # Personal Information
  30.     panelInfo = VerticalPanel()
  31.         panelInfo.add(HTML("WebPage:"))
  32.         panelInfor.add(HTML("Job:"))
  33.    
  34.     # Adresses
  35.     panelAddress = VerticalPanel()
  36.         panelAddress.add(HTML("Home Address:"))
  37.         panelAddress.add(HTML("Work Address"))
  38.  
  39.     # Additional Notes
  40.     panelNotas = VerticalPanel()
  41.         panelNotas.add(HTML("Notes"))
  42.  
  43.     # Add the panes in a stack
  44.     stack = StackPanel(Width="100%", Height="100px")
  45.     stack.add(panelContact,"Contact")
  46.     stack.add(panelInfo,"Personal Info")
  47.     stack.add(panelAddress,"Adresses")
  48.     stack.add(panelNotes,"Notes")
  49.  
  50.     # Buttons
  51.     panelButton = HorizontalPanel()
  52.         panelButton.add(HTML("Submit"))
  53.         panelButton.add(HTML("Clear"))
  54.  
  55.     # Create content body
  56.     content = VerticalPanel()
  57.     content.add(HTML("Fill fields below:</br>")
  58.     content.add(stack)
  59.     content.add(panelButton)
  60.  
  61.     # Define web page as a dock
  62.     page =  DockPanel(BorderWidth=1, Padding=8,
  63.             HorizontalAlignment=HasAlignment.ALIGN_CENTER,
  64.                 VerticalAlignment=HasAlignment.ALIGN_MIDDLE)
  65.  
  66.     # Dummy content to dock sections
  67.         header  = HTML("<H1>Contact-me</H1>")
  68.         left    = Label("LEFT HOLDER")
  69.         right   = Label("RIGHTHOLDER")
  70.         footer  = HTML("(c)All rights reserved. Gnu/GPL")
  71.  
  72.     # Add things to dockpanel Page
  73.         page.add(header,  DockPanel.NORTH)
  74.         page.add(west,    DockPanel.WEST)
  75.         page.add(content, DockPanel.CENTER)
  76.         page.add(east,    DockPanel.EAST)
  77.         page.add(footer,  DockPanel.SOUTH)
  78.  
  79.         page.setCellHeight(center, "600px")
  80.         page.setCellWidth (center, "800px")
  81.  
  82.     # Add page to RootPanel
  83.     RootPanel().add(pagina)
  84.  
  85.     ##########################
  86.     ## Form Stuff
  87.     ###########################
  88.     #
  89.     ## Create form and pont to service
  90.     #self.formulario = FormPanel()
  91.     #self.formulario.setAction("/submit/")
  92.     #self.formulario.setWidget(panelContato)
  93.     #self.formulario.setWidget(panelInformacoes)
  94.     #self.formulario.setWidget(panelEnderecos)
  95.     #self.formulario.setWidget(panelNotas)
  96.     #self.formulario.setWidget(conteudo)
  97.     #
  98.     ## Add a submit button to form
  99.     #self.form.add(Button("Submit", self))
  100.     #
  101.     ## Add the handler
  102.     #self.form.addFormHandler(self)
  103.     #
  104.     ## Add stack to form (this will change)
  105.     #self.form.add(stack)
  106.     #
  107.     ## Add form to page (changed due Dock)
  108.     #RootPanel().add(self.form)
  109.  
  110.     def onClick(self, sender):
  111.         self.form.submit()
  112.  
  113.     def onSubmitComplete(self, event):
  114.         # When the form submission is successfully completed, this event is
  115.         # fired. Assuming the service returned a response of type text/plain,
  116.         # we can get the result text here (see the FormPanel documentation for
  117.         # further explanation).
  118.         Window.alert(event.getResults())
  119.  
  120.     def onSubmit(self, event):
  121.         # This event is fired just before the form is submitted. We can take
  122.         # this opportunity to perform validation.
  123.         if (self.tb.getText().length == 0):
  124.             Window.alert("The text box must not be empty")
  125.             event.setCancelled(True)
  126.  
  127.  
  128. if __name__ == '__main__':
  129.     app = ContactPanel()
  130.     app.onModuleLoad()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement