def onModuleLoad(self):
        self.panel=DockPanel()
        
        east = Label("east")
        self.panel.add(east, DockPanel.EAST)
        self.panel.add(Label("west"), DockPanel.WEST)
        self.panel.add(Label("north"), DockPanel.NORTH)
        self.panel.add(Label("south"), DockPanel.SOUTH)
        self.south2 = Label("south2")
        self.panel.add(self.south2, DockPanel.SOUTH)
        self.center = Label("center")
        self.panel.add(self.center, DockPanel.CENTER)

        self.panel.setWidth("300px")
        self.panel.setHeight("300px")

        self.panel.setBorderWidth("1px")

        self.panel.setCellVerticalAlignment(east, HasAlignment.ALIGN_BOTTOM)
        self.panel.setCellHorizontalAlignment(east, HasAlignment.ALIGN_RIGHT)


        self.r = Button("remove", self)
        self.a = Button("add", self)

        RootPanel().add(self.panel)
        RootPanel().add(self.r)
        RootPanel().add(self.a)
class BrowserDetect:
    def onModuleLoad(self):
        self.l = Label()
        RootPanel().add(self.l)
        self.display()

    def display(self):
        self.l.setText("Browser not detected/supported")
Esempio n. 3
0
    def onModuleLoad(self):
        b = VerticalDemoSlider(0, 100)
        RootPanel().add(b)

        b.setWidth("20px")
        b.setHeight("100px")

        b.addControlValueListener(self)
        self.label = Label("Not set yet")
        RootPanel().add(self.label)
Esempio n. 4
0
class ControlDemo:
    def onModuleLoad(self):
        b = VerticalDemoSlider(0, 100)
        RootPanel().add(b)

        b.setWidth("20px")
        b.setHeight("100px")

        b.addControlValueListener(self)
        self.label = Label("Not set yet")
        RootPanel().add(self.label)

    def onControlValueChanged(self, slider, old_value, new_value):
        self.label.setText("Value: %d" % int(new_value))
    def onModuleLoad(self):
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"
        self.METHOD_ECHO = "Echo"
        self.METHOD_REVERSE = "Reverse"
        self.METHOD_UPPERCASE = "UPPERCASE"
        self.METHOD_LOWERCASE = "lowercase"
        self.methods = [self.METHOD_ECHO, self.METHOD_REVERSE, self.METHOD_UPPERCASE, self.METHOD_LOWERCASE]

        self.remote_php = EchoServicePHP()
        self.remote_py = EchoServicePython()

        self.status=Label()
        self.text_area = TextArea()
        self.text_area.setText(r"{'Test'} [\"String\"]")
        self.text_area.setCharacterWidth(80)
        self.text_area.setVisibleLines(8)
        
        self.method_list = ListBox()
        #self.method_list.setMultipleSelect(True)
        self.method_list.setVisibleItemCount(1)
        for method in self.methods:
            self.method_list.addItem(method)
        self.method_list.setSelectedIndex(0)

        method_panel = HorizontalPanel()
        method_panel.add(HTML("Remote string method to call: "))
        method_panel.add(self.method_list)
        method_panel.setSpacing(8)

        self.button_php = Button("Send to PHP Service", self)
        self.button_py = Button("Send to Python Service", self)

        buttons = HorizontalPanel()
        buttons.add(self.button_php)
        buttons.add(self.button_py)
        buttons.setSpacing(8)
        
        info = r"<h2>JSON-RPC Example</h2><p>This example demonstrates the calling of server services with <a href=\"http://json-rpc.org/\">JSON-RPC</a>."
        info += "<p>Enter some text below, and press a button to send the text to an Echo service on your server. An echo service simply sends the exact same text back that it receives."
        
        panel = VerticalPanel()
        panel.add(HTML(info))
        panel.add(self.text_area)
        panel.add(method_panel)
        panel.add(buttons)
        panel.add(self.status)
        
        RootPanel().add(panel)
Esempio n. 6
0
    def __init__(self):
        Sink.__init__(self)
        self.sStrings=[["foo0", "bar0", "baz0", "toto0", "tintin0"],
            ["foo1", "bar1", "baz1", "toto1", "tintin1"],
            ["foo2", "bar2", "baz2", "toto2", "tintin2"],
            ["foo3", "bar3", "baz3", "toto3", "tintin3"],
            ["foo4", "bar4", "baz4", "toto4", "tintin4"]]

        self.combo=ListBox()
        self.list=ListBox()
        self.echo=Label()

        self.combo.setVisibleItemCount(1)
        self.combo.addChangeListener(self)
        self.list.setVisibleItemCount(10)
        self.list.setMultipleSelect(True)
        
        for i in range(len(self.sStrings)):
            self.combo.addItem("List %d" % i)
        self.combo.setSelectedIndex(0)
        self.fillList(0)
        
        self.list.addChangeListener(self)
        
        horz = HorizontalPanel()
        horz.setVerticalAlignment(HasAlignment.ALIGN_TOP)
        horz.setSpacing(8)
        horz.add(self.combo)
        horz.add(self.list)
        
        panel = VerticalPanel()
        panel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
        panel.add(horz)
        panel.add(self.echo)
        self.initWidget(panel)
        
        self.echoSelection()
Esempio n. 7
0
    def __init__(self, contact):
        # The popup's constructor's argument is a boolean specifying that it
        # auto-close itself when the user clicks outside of it.

        PopupPanel.__init__(self, True)

        inner = VerticalPanel()
        nameLabel = Label(contact.name)
        emailLabel = Label(contact.email)
        inner.add(nameLabel)
        inner.add(emailLabel)
        
        panel = HorizontalPanel()
        panel.setSpacing(4)
        panel.add(Image(contact.photo))
        panel.add(inner)
        
        self.add(panel)
        self.setStyleName("mail-ContactPopup")
        nameLabel.setStyleName("mail-ContactPopupName")
        emailLabel.setStyleName("mail-ContactPopupEmail")
Esempio n. 8
0
class Lists(Sink):
    def __init__(self):
        Sink.__init__(self)
        self.sStrings=[["foo0", "bar0", "baz0", "toto0", "tintin0"],
            ["foo1", "bar1", "baz1", "toto1", "tintin1"],
            ["foo2", "bar2", "baz2", "toto2", "tintin2"],
            ["foo3", "bar3", "baz3", "toto3", "tintin3"],
            ["foo4", "bar4", "baz4", "toto4", "tintin4"]]

        self.combo=ListBox()
        self.list=ListBox()
        self.echo=Label()

        self.combo.setVisibleItemCount(1)
        self.combo.addChangeListener(self)
        self.list.setVisibleItemCount(10)
        self.list.setMultipleSelect(True)
        
        for i in range(len(self.sStrings)):
            self.combo.addItem("List %d" % i)
        self.combo.setSelectedIndex(0)
        self.fillList(0)
        
        self.list.addChangeListener(self)
        
        horz = HorizontalPanel()
        horz.setVerticalAlignment(HasAlignment.ALIGN_TOP)
        horz.setSpacing(8)
        horz.add(self.combo)
        horz.add(self.list)
        
        panel = VerticalPanel()
        panel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
        panel.add(horz)
        panel.add(self.echo)
        self.initWidget(panel)
        
        self.echoSelection()

    def onChange(self, sender):
        print "onChange", sender, self.list, self.combo
        if sender is self.combo:
            print "fill list"
            self.fillList(self.combo.getSelectedIndex())
        elif sender is self.list:
            print "echo "
            self.echoSelection()
        else:
            print "oops"

    def onShow(self):
        pass
    
    def fillList(self, idx):
        self.list.clear()
        strings = self.sStrings[idx]
        for i in range(len(strings)):
            self.list.addItem(strings[i])

        self.echoSelection()

    def echoSelection(self):
        msg = "Selected items: "
        print msg, self.list.getItemCount()
        for i in range(self.list.getItemCount()):
            if self.list.isItemSelected(i):
                msg += "%d" % i + self.list.getItemText(i) + " "
        self.echo.setText(msg)
 def onModuleLoad(self):
     self.l = Label()
     RootPanel().add(self.l)
     self.display()
class JSONRPCExample:
    def onModuleLoad(self):
        self.TEXT_WAITING = "Waiting for response..."
        self.TEXT_ERROR = "Server Error"
        self.METHOD_ECHO = "Echo"
        self.METHOD_REVERSE = "Reverse"
        self.METHOD_UPPERCASE = "UPPERCASE"
        self.METHOD_LOWERCASE = "lowercase"
        self.methods = [self.METHOD_ECHO, self.METHOD_REVERSE, self.METHOD_UPPERCASE, self.METHOD_LOWERCASE]

        self.remote_php = EchoServicePHP()
        self.remote_py = EchoServicePython()

        self.status=Label()
        self.text_area = TextArea()
        self.text_area.setText(r"{'Test'} [\"String\"]")
        self.text_area.setCharacterWidth(80)
        self.text_area.setVisibleLines(8)
        
        self.method_list = ListBox()
        #self.method_list.setMultipleSelect(True)
        self.method_list.setVisibleItemCount(1)
        for method in self.methods:
            self.method_list.addItem(method)
        self.method_list.setSelectedIndex(0)

        method_panel = HorizontalPanel()
        method_panel.add(HTML("Remote string method to call: "))
        method_panel.add(self.method_list)
        method_panel.setSpacing(8)

        self.button_php = Button("Send to PHP Service", self)
        self.button_py = Button("Send to Python Service", self)

        buttons = HorizontalPanel()
        buttons.add(self.button_php)
        buttons.add(self.button_py)
        buttons.setSpacing(8)
        
        info = r"<h2>JSON-RPC Example</h2><p>This example demonstrates the calling of server services with <a href=\"http://json-rpc.org/\">JSON-RPC</a>."
        info += "<p>Enter some text below, and press a button to send the text to an Echo service on your server. An echo service simply sends the exact same text back that it receives."
        
        panel = VerticalPanel()
        panel.add(HTML(info))
        panel.add(self.text_area)
        panel.add(method_panel)
        panel.add(buttons)
        panel.add(self.status)
        
        RootPanel().add(panel)

    def onClick(self, sender, event):
        self.status.setText(self.TEXT_WAITING)
        method = self.methods[self.method_list.getSelectedIndex()]
        text = self.text_area.getText()

        print repr(text)

        # demonstrate proxy & callMethod()
        if sender == self.button_php:
            if method == self.METHOD_ECHO:
                id = self.remote_php.echo(text, self)
            elif method == self.METHOD_REVERSE:
                id = self.remote_php.callMethod("reverse", [text], self)
            elif method == self.METHOD_UPPERCASE:
                id = self.remote_php.uppercase(text, self)
            elif method == self.METHOD_LOWERCASE:
                id = self.remote_php.lowercase(text, self)
        else:
            if method == self.METHOD_ECHO:
                id = self.remote_py.echo(text, self)
            elif method == self.METHOD_REVERSE:
                id = self.remote_py.reverse(text, self)
            elif method == self.METHOD_UPPERCASE:
                id = self.remote_py.uppercase(text, self)
            elif method == self.METHOD_LOWERCASE:
                id = self.remote_py.lowercase(text, self)
        if id<0:
            self.status.setText(self.TEXT_ERROR)

    def onRemoteResponse(self, response, request_info):
        self.status.setText(response)

    def onRemoteError(self, code, message, request_info):
        self.status.setText("Server Error or Invalid Response: ERROR " + str(code) + " - " + str(message))