Пример #1
0
 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()
Пример #2
0
 def _create_korobov_dialog(self):
     contents = VerticalPanel(StyleName="Contents", Spacing=4)
     contents.add(HTML("Enter the Korobov parameter."))
     kparam = TextBox(Text='2')
     contents.add(kparam)
     contents.add(Button("OK", getattr(self, '_close_korobov_dialog')))
     dialog = DialogBox(glass=True)
     dialog.setHTML('<b>Compute a Korobov generating vector</b>')
     dialog.setWidget(contents)
     return dialog, kparam
Пример #3
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()
Пример #4
0
 def _create_expr_dialog(self):
     contents = VerticalPanel(StyleName="Contents", Spacing=4)
     msg = (
         "Enter an expression for the weights, using <em>{0}</em> as the "
         "{1}, for example: <ul><li>{0}^-2</li><li>1/(1+{0}^2)</li><li>0.1^{0}</li></ul>."
     ).format(self._expr_var, self._expr_var_desc)
     contents.add(HTML(msg))
     expr = TextBox(Text='0.1')
     contents.add(expr)
     contents.add(Button("OK", getattr(self, '_close_expr_dialog')))
     dialog = DialogBox(glass=True)
     dialog.setHTML('<b>Set the weights from an expression</b>')
     dialog.setWidget(contents)
     return dialog, expr
Пример #5
0
    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()
Пример #6
0
 def _create_add_dialog(self):
     contents = VerticalPanel(StyleName="Contents", Spacing=4)
     wtype = ListBox(Width="14em")
     wtype.addChangeListener(self)
     for wclass in self.WEIGHT_TYPES:
         wtype.addItem(wclass.NAME, value=wclass)
     panel = HorizontalPanel(Spacing=8)
     panel.add(HTML("Weight type: ", **captionstyle))
     panel.add(wtype)
     contents.add(panel)
     contents.add(Button("OK", getattr(self, '_close_add_dialog')))
     dialog = DialogBox(glass=True)
     dialog.setHTML('<b>Add a new type of weights</b>')
     dialog.setWidget(contents)
     return dialog, wtype
Пример #7
0
 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()
Пример #8
0
    def show_custom(self):
        self.dialog = DialogBox(StyleName='custom-dialog')
        self.dialog.setHTML('Custom Settings')

        contents = VerticalPanel(StyleName='contents')
        self.dialog.setWidget(contents)

        # contents of contents
        rows = HorizontalPanel()
        columns = HorizontalPanel()
        bombs = HorizontalPanel()
        buttons = HorizontalPanel()

        for each in (rows, columns, bombs, buttons):
            contents.add(each)

        rows.add(Label('Rows:'))
        self.row = TextBox()
        rows.add(self.row)

        columns.add(Label('Columns:'))
        self.column = TextBox()
        columns.add(self.column)

        bombs.add(Label('Bombs:'))
        self.bomb = TextBox()
        bombs.add(self.bomb)

        buttons.add(Button("OK", getattr(self, 'new_game')))
        buttons.add(Button("Cancel", getattr(self, 'close_dialog')))

        left = (Window.getClientWidth() - 201) / 2
        top = (Window.getClientHeight() - 190) / 2
        self.dialog.setPopupPosition(left, top)

        self.dialog.show()