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()
def show(self): if self.hasBackground: self.background = Widget(Element=DOM.createDiv(), StyleName='diaglog_coverup') self.background.setHeight(RootPanel().getOffsetHeight()) RootPanel().add(self.background) DialogBox.show(self)
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()
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()
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()
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()
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 create_popup(self, txt): popup = DialogBox(False, False) popup.onClick = lambda w: popup.hide() popup.setHTML('<b>%s</b>' % (txt)) popup.setWidget(Button('Close', popup)) popup.show()