Exemplo n.º 1
0
    def __init__(self):
        SimplePanel.__init__(self)

        self.form = FormPanel()
        self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
        self.form.setMethod(FormPanel.METHOD_POST)
        self.url = "http://localhost/pyjamas_upload_demo"
        self.form.setAction(self.url)
        self.form.setTarget("results")

        vPanel = VerticalPanel()

        hPanel = HorizontalPanel()
        hPanel.setSpacing(5)
        hPanel.add(Label("Upload file:"))

        self.field = FileUpload()
        self.field.setName("file")
        hPanel.add(self.field)

        hPanel.add(Button("Submit", getattr(self, "onBtnClick")))
        vPanel.add(hPanel)

        self.simple = CheckBox("Simple mode?  ")
        #self.simple.setChecked(True)
        vPanel.add(self.simple)
        self.progress = Label('0%')

        results = NamedFrame("results")
        vPanel.add(results)
        vPanel.add(self.progress)

        self.form.add(vPanel)
        self.add(self.form)
Exemplo n.º 2
0
    def __init__(self):
        SimplePanel.__init__(self)

        self.form = FormPanel()
        self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
        self.form.setMethod(FormPanel.METHOD_POST)
        self.form.setAction("http://nonexistent.com")
        self.form.setTarget("results")

        vPanel = VerticalPanel()

        hPanel = HorizontalPanel()
        hPanel.setSpacing(5)
        hPanel.add(Label("Upload file:"))

        self.field = FileUpload()
        self.field.setName("file")
        hPanel.add(self.field)

        hPanel.add(Button("Submit", getattr(self, "onBtnClick")))

        vPanel.add(hPanel)

        results = NamedFrame("results")
        vPanel.add(results)

        self.form.add(vPanel)
        self.add(self.form)
Exemplo n.º 3
0
 def onModuleLoad(self):
     
     self.remote_py = MyBlogService()
     
     # Create a FormPanel and point it at a service.
     self.form = FormPanel()
     
     # Create a panel to hold all of the form widgets.
     vp=VerticalPanel(BorderWidth=0,HorizontalAlignment=HasAlignment.ALIGN_CENTER,VerticalAlignment=HasAlignment.ALIGN_MIDDLE,Width="100%",Height="150px")
     self.form.setWidget(vp)
     
     header=HTML("<h2>LOGIN TO YOUR ACCOUNT</h2>")
     part1=header
           
     # Create a TextBox, giving it a name so that it will be submitted.
     self.userName = TextBox()
     self.userName.setName("userNameFormElement")
     self.userName.setPlaceholder("User Name")
     part2=self.userName
     
     self.password = PasswordTextBox()
     self.password.setName("passwordFormElement")
     self.password.setPlaceholder("Password")
     part3=self.password
     
     self.errorInfoLabel = Label()
     self.errorInfoLabel.setStyleName('error-info')
     part4=self.errorInfoLabel
     part4.setStyleName("errorlabel")
     
      # Add a 'submit' button.
     hpanel = HorizontalPanel(BorderWidth=0,HorizontalAlignment=HasAlignment.ALIGN_CENTER,VerticalAlignment=HasAlignment.ALIGN_MIDDLE,Width="100%",Height="50px")
     
     partb=Button("Login", self)
     partb.setStyleName('btn')
     
     image=Label("Don''t have account? Sign up")
     anchor = Anchor(Widget=image, Href='/signup.html')
     parta=anchor
     
          
     hpanel.add(partb)
     hpanel.add(parta)
    
     part5=hpanel 
     part5.setStyleName("hpanel")
     
     vp.add(part1)
     vp.add(part2)
     vp.add(part3)
     vp.add(part4)
     vp.add(part5)
     vp.setStyleName("signup")
     
     # Add an event handler to the form.
     self.form.addFormHandler(self)
     RootPanel().add(self.form)
Exemplo n.º 4
0
    def __init__(self):
        SimplePanel.__init__(self)

        self.form = FormPanel()
        self.form.setAction("http://google.com/search")
        self.form.setTarget("results")

        panel = VerticalPanel()
        panel.add(Hidden("q", "python pyjamas"))
        panel.add(Button("Search", getattr(self, "onBtnClick")))

        results = NamedFrame("results")
        panel.add(results)

        self.form.add(panel)
        self.add(self.form)
Exemplo n.º 5
0
    def get_upload_panel(self):
        # Create a FormPanel and point it at a service.
        self.form = FormPanel()
        self.form.setAction("/upload")

        # Add an event handler to the form.
        handler = UploadFormHandler()
        handler.form = self.form
        self.form.addFormHandler(handler)

        # Because we're going to add a FileUpload widget, we'll need to set the
        # form to use the POST method, and multipart MIME encoding.
        self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
        self.form.setMethod(FormPanel.METHOD_POST)

        panel = VerticalPanel()
        panel.setSpacing(8)
        panel.setStyleName("panel")  # same name as in OpenPowerSystem.css.
        self.form.setWidget(panel)

        info = HTML(r'Upload CIM RDF/XML instance file.')
        panel.add(info)

        # Create a list box for choice of profile.
        self.profiles = [("UCTE (CIM 14)", "ucte"), ("CPSM (CIM13)", "cpsm"),
                         ("CDPSM (CIM 14)", "cdpsm"),
                         ("Dynamics (CIM 14)", "dynamics")]
        self.profile = ListBox(VisibleItemCount=1)
        self.profile.setName("profileType")
        for n, v in self.profiles:
            self.profile.addItem(n, v)
        panel.add(self.profile)

        # Create a FileUpload widget.
        rdfxml_file = FileUpload()
        rdfxml_file.setName("uploadFormElement")
        panel.add(rdfxml_file)

        # Add a 'submit' button.
        upload = Button("Upload", handler)
        panel.add(upload)

        return self.form
Exemplo n.º 6
0
    def __init__(self):
        SimplePanel.__init__(self)

        self.form = FormPanel(Action="http://google.com/search",
                              Target="results")

        vPanel = VerticalPanel(Spacing=5)
        hPanel = HorizontalPanel(Spacing=5)

        hPanel.add(Label("Search for:"))
        hPanel.add(TextBox(Name="q"))
        hPanel.add(Button("Submit", self))

        vPanel.add(hPanel)

        results = NamedFrame("results", Width="100%", Height="200px")
        vPanel.add(results)

        self.form.add(vPanel)
        self.add(self.form)
Exemplo n.º 7
0
    def onModuleLoad(self):
        # Create a FormPanel and point it at a service.
        self.form = FormPanel()
        self.form.setAction("/chat-service/test/")

        # Because we're going to add a FileUpload widget, we'll need to set the
        # form to use the POST method, and multipart MIME encoding.
        self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
        self.form.setMethod(FormPanel.METHOD_POST)

        # Create a panel to hold all of the form widgets.
        panel = VerticalPanel()
        self.form.setWidget(panel)

        # Create a TextBox, giving it a name so that it will be submitted.
        self.tb = TextBox()
        self.tb.setName("textBoxFormElement")
        panel.add(self.tb)

        # Create a ListBox, giving it a name and some values to be associated with
        # its options.
        lb = ListBox()
        lb.setName("listBoxFormElement")
        lb.addItem("foo", "fooValue")
        lb.addItem("bar", "barValue")
        lb.addItem("baz", "bazValue")
        panel.add(lb)

        # Create a FileUpload widget.
        upload = FileUpload()
        upload.setName("uploadFormElement")
        panel.add(upload)

        # Add a 'submit' button.
        panel.add(Button("Submit", self))

        # Add an event handler to the form.
        self.form.addFormHandler(self)

        RootPanel().add(self.form)
Exemplo n.º 8
0
    def onModuleLoad(self):
        self.form = FormPanel()
        self.remote_py = MyBlogService()

        self.form.setAction("/index.html")

        vp = VerticalPanel(BorderWidth=0,
                           HorizontalAlignment=HasAlignment.ALIGN_CENTER,
                           VerticalAlignment=HasAlignment.ALIGN_MIDDLE,
                           Width="100%",
                           Height="150px")
        self.form.setWidget(vp)

        header = HTML(
            "<h2>CREATE MY ACCOUNT</h2><h3>Welcome to signup form</h3>")
        part1 = header

        hpn = HorizontalPanel(BorderWidth=0,
                              HorizontalAlignment=HasAlignment.ALIGN_LEFT,
                              VerticalAlignment=HasAlignment.ALIGN_MIDDLE,
                              Width="92%",
                              Height="60px")

        self.fname = TextBox()
        self.fname.setName("fname")
        self.fname.setPlaceholder("First Name")
        hpn.add(self.fname)

        self.lname = TextBox()
        self.lname.setName("lname")
        self.lname.setPlaceholder("Last Name")
        hpn.add(self.lname)
        hpn.setCellWidth(self.fname, "70%")
        hpn.setCellWidth(self.lname, "30%")
        part2 = hpn

        self.uname = TextBox()
        self.uname.setName("uname")
        self.uname.setPlaceholder("User Name")
        part3 = self.uname

        self.password = PasswordTextBox()
        self.password.setName("passsignup")
        self.password.setPlaceholder("Choose a password")
        part4 = self.password

        self.rpassword = PasswordTextBox()
        self.rpassword.setName("rpasssignup")
        self.rpassword.setPlaceholder("Confirm your password")
        part5 = self.rpassword

        self.email = TextBox()
        self.email.setName("emailsignup")
        self.email.setPlaceholder("Enter your email address ")
        part6 = self.email

        self.errorlabel = Label()
        self.errorlabel.setStyleName("errorlabel")
        part7 = self.errorlabel

        hpanel = HorizontalPanel(BorderWidth=0,
                                 HorizontalAlignment=HasAlignment.ALIGN_CENTER,
                                 VerticalAlignment=HasAlignment.ALIGN_MIDDLE,
                                 Width="100%",
                                 Height="50px")

        partb = Button("Signup", self)
        partb.setStyleName('btn')
        image = Label("Already have account! Sign in")
        anchor = Anchor(Widget=image, Href='/index.html')
        parta = anchor

        hpanel.add(partb)
        hpanel.add(parta)
        hpanel.setStyleName("hpanel")

        part8 = hpanel

        vp.add(part1)
        vp.add(part2)
        vp.add(part3)
        vp.add(part4)
        vp.add(part5)
        vp.add(part6)
        vp.add(part7)
        vp.add(part8)

        vp.setCellHeight(part1, "5%")
        vp.setCellHeight(part2, "10%")
        vp.setCellHeight(part3, "10%")
        vp.setCellHeight(part4, "10%")
        vp.setCellHeight(part5, "10%")
        vp.setCellHeight(part6, "10%")
        vp.setCellHeight(part7, "10%")
        vp.setCellHeight(part8, "10%")

        vp.setStyleName("signup")

        self.form.addFormHandler(self)
        RootPanel().add(self.form)