Exemple #1
0
class EditPanel(AbsolutePanel):

    def __init__(self, key, title, content):
        AbsolutePanel.__init__(self)
        self.edit_header = Label("Edit a Post", StyleName="header_label")
        self.edit_title_label = Label("Title:")
        self.edit_title = TextBox()
        self.edit_title.setMaxLength(255)
        self.edit_content = TextArea()
        self.edit_content.setVisibleLines(2)
        self.edit_button = Button("Save")
        self.edit_cancel_button = Button("Cancel")
        self.edit_hidden_key = Hidden()
        self.error_message_label = Label("", StyleName="error_message_label")
        edit_contents = VerticalPanel(StyleName="Contents", Spacing=4)
        edit_contents.add(self.edit_header)
        edit_contents.add(self.edit_title_label)
        edit_contents.add(self.edit_title)
        edit_contents.add(self.edit_content)
        edit_contents.add(self.edit_button)
        edit_contents.add(self.edit_cancel_button)
        edit_contents.add(self.error_message_label)
        edit_contents.add(self.edit_hidden_key)
        self.edit_dialog = DialogBox(glass=True)
        self.edit_dialog.setHTML('<b>Blog Post Form</b>')
        self.edit_dialog.setWidget(edit_contents)
        left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft()
        top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop()
        self.edit_dialog.setPopupPosition(left, top)
        self.edit_dialog.hide()

    def clear_edit_panel(self):
        self.edit_title.setText("")
        self.edit_content.setText("")
        self.error_message_label.setText("")
Exemple #2
0
class DialogBoxDemo(SimplePanel):
    def __init__(self):
        SimplePanel.__init__(self)

        self.add(Button("Show Dialog", getattr(self, "showDialog")))


    def showDialog(self, event):
        contents = VerticalPanel()
        contents.setSpacing(4)
        contents.add(HTML('You can place any contents you like in a dialog box.'))
        contents.add(Button("Close", getattr(self, "onClose")))
        contents.setStyleName("Contents")

        self._dialog = DialogBox()
        self._dialog.setHTML('<b>Welcome to the dialog box</b>')
        self._dialog.setWidget(contents)

        left = (Window.getClientWidth() - 200) / 2
        top = (Window.getClientHeight() - 100) / 2
        self._dialog.setPopupPosition(left, top)
        self._dialog.show()


    def onClose(self, event):
        self._dialog.hide()
Exemple #3
0
class WritePanel(AbsolutePanel):

    def __init__(self, parent):
        AbsolutePanel.__init__(self)
        self.post_header = Label("Write a Post", StyleName="header_label")
        self.post_write_title_label = Label("Title:")
        self.post_title = TextBox()
        self.post_content = TextArea()
        self.post_button = Button("Post")
        self.cancel_button = Button("Cancel")
        self.error_message_label = Label("", StyleName="error_message_label")
        contents = VerticalPanel(StyleName="Contents", Spacing=4)
        contents.add(self.post_header)
        contents.add(self.post_write_title_label)
        contents.add(self.post_title)
        contents.add(self.post_content)
        contents.add(self.post_button)
        contents.add(self.cancel_button)
        contents.add(self.error_message_label)
        self.dialog = DialogBox(glass=True)
        self.dialog.setHTML('<b>Blog Post Form</b>')
        self.dialog.setWidget(contents)
        left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft()
        top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop()
        self.dialog.setPopupPosition(left, top)
        self.dialog.hide()

    def clear_write_panel(self):
        self.post_title.setText("")
        self.post_content.setText("")
        self.error_message_label.setText("")
class ErrorMessage:
    """
	Simple class to show a message that blocks the screen until the user
	clicks the "Close" button.
	
	Note that this gets its style from the CSS styles ".gwt-DialogBox .Caption",
	".gwt-DialogBox .Contents" and ".gwt-PopupPanelGlass"
	
	@author Mark Grimes ([email protected])
	@date 17/Jan/2014
	"""

    def __init__(self, message, messageTitle="Error"):
        self.dialog = DialogBox(glass=True)
        self.dialog.setHTML("<b>" + messageTitle + "</b>")
        dialogContents = VerticalPanel(StyleName="Contents", Spacing=4)
        dialogContents.add(HTML(message))
        dialogContents.add(Button("Close", getattr(self, "onClose")))
        self.dialog.setWidget(dialogContents)
        left = (Window.getClientWidth() - 200) / 2 + Window.getScrollLeft()
        top = (Window.getClientHeight() - 100) / 2 + Window.getScrollTop()
        self.dialog.setPopupPosition(left, top)
        self.dialog.show()

    def onClose(self, event):
        self.dialog.hide()
Exemple #5
0
class DialogBoxDemo(SimplePanel):
    def __init__(self):
        SimplePanel.__init__(self)

        self.add(Button("Show Dialog", getattr(self, "showDialog")))


    def showDialog(self, event):
        contents = VerticalPanel(StyleName="Contents",
                                 Spacing=4)
        contents.add(HTML('You can place any contents you like in a dialog box.'))
        contents.add(Button("Close", getattr(self, "onClose")))

        self._dialog = DialogBox(glass=True)
        self._dialog.setHTML('<b>Welcome to the dialog box</b>')
        self._dialog.setWidget(contents)

        left = (Window.getClientWidth() - 200) / 2 + Window.getScrollLeft()
        top = (Window.getClientHeight() - 100) / 2 + Window.getScrollTop()
        self._dialog.setPopupPosition(left, top)
        self._dialog.show()


    def onClose(self, event):
        self._dialog.hide()
Exemple #6
0
    def create_popup(self):

        # create the popup in the middle box
        popup = DialogBox(False, False)
        popup.onClick = lambda w: popup.hide()
        popup.setHTML('<b>Hello!</b>')
        popup.setWidget(Button('Close', popup))
        x = self.box.getAbsoluteLeft() + random()*100
        y = self.box.getAbsoluteTop() + random()*100
        popup.setPopupPosition(x, y)
        popup.show()
Exemple #7
0
    def create_popup(self):

        # create the popup in the middle box
        popup = DialogBox(False, False)
        popup.onClick = lambda w: popup.hide()
        popup.setHTML('<b>Hello!</b>')
        popup.setWidget(Button('Close', popup))
        x = self.box.getAbsoluteLeft() + random() * 100
        y = self.box.getAbsoluteTop() + random() * 100
        popup.setPopupPosition(x, y)
        popup.show()
Exemple #8
0
    def create_popup(self):

        # create the popup in the middle box
        popup = DialogBox(False, False)
        
        popup.setHTML(num.pop())

        x = self.box.getAbsoluteLeft() + random()*100
        y = self.box.getAbsoluteTop() + random()*100
        popup.setPopupPosition(x, y)
        popup.show()
 def setPopupPosition(self, left, top):
     if top + self.getOffsetHeight() > Window.getClientHeight():
         top = Window.getClientHeight() - self.getOffsetHeight()
     if left + self.getOffsetWidth() > Window.getClientWidth():
         left = Window.getClientWidth() - self.getOffsetWidth()    
     DialogBox.setPopupPosition(self, left, top)