Пример #1
0
    def onClick(self, sender):
        if sender == self.newpage:
            self.todoId = None
            self.todoTextName.setText("")
            self.todoTextArea.setHTML("")
            return
        elif sender == self.view:
            name = self.todoTextName.getText()
            html = self.todoTextArea.getHTML()
            if not html:
                return
            p = HTMLDialog(name, html)
            p.setPopupPosition(10, 10)
            p.setWidth(Window.getClientWidth() - 40)
            p.setHeight(Window.getClientHeight() - 40)
            p.show()
            return
        elif sender == self.fDialogButton:
            Window.open(fileedit_url, "fileupload", "width=800,height=600")
            return
            dlg = FileDialog(fileedit_url)
            left = self.fDialogButton.getAbsoluteLeft() + 10
            top = self.fDialogButton.getAbsoluteTop() + 10
            dlg.setPopupPosition(left, top)
            dlg.show()

        id = self.remote.getPage(sender.getValue(sender.getSelectedIndex()), self)
        if id < 0:
            self.status.setHTML("Server Error or Invalid Response")
    def setPopupPosition(self, left, top):
        if isinstance(left, basestring):
            if left.endswith('%'):
                left = int(left[:-1])
                left = int(left * Window.getClientWidth() / 100)
            elif left.lower().endswith('px'):
                left = int(left[:-2])
        if isinstance(top, basestring):
            if top.lower().endswith('%'):
                top = int(top[:-1])
                top = int(top * Window.getClientHeight() / 100)
            elif top.endswith('px'):
                top = int(top[:-2])

        left = max(left, 0)
        top = max(top, 0)

        # Account for the difference between absolute position and the
        # body's positioning context.
        left -= DOM.getBodyOffsetLeft()
        top -= DOM.getBodyOffsetTop()

        element = self.getElement()
        DOM.setStyleAttribute(element, "left", "%dpx" % left)
        DOM.setStyleAttribute(element, "top", "%dpx" % top)
Пример #3
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()

        ADD(contents, rows, columns, bombs, buttons)

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

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

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

        ADD(buttons, Button("OK", getattr(self, 'new_game')), \
                     Button("Cancel", getattr(self, 'close_dialog')))

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

        self.dialog.show()
Пример #4
0
    def __init__(self, app):
        DialogBox.__init__(self)
        self.app = app
        self.table=FlexTable()
        self.table.setText(0, 0, "Please enter username and password")
        self.table.getFlexCellFormatter().setColSpan(0, 0, 2)
        self.table.setText(1, 0, "Username")
        self.handle = TextBox()
        h = getCookie('handle')
        self.handle.setText(h)
        self.table.setWidget(1, 1, self.handle)
        self.table.setText(2, 0, "Password")
        self.pwd = PasswordTextBox()
        self.table.setWidget(2, 1, self.pwd)

        self.table.setHTML(3,0,"")
        self.table.getFlexCellFormatter().setColSpan(3, 0, 2)        
        h = HorizontalPanel()
        self.table.setWidget(4,0, h)
        self.table.getFlexCellFormatter().setColSpan(4, 0, 2)
        h.add(Button("Ok", getattr(self, "onOk")))
        h.add(Button("Cancel", getattr(self, "onClose")))
        h.setSpacing(4)
        self.setHTML("<b>Login</b>")
        self.setWidget(self.table)
        left = (Window.getClientWidth() - 200) / 2
        top = (Window.getClientHeight() - 100) / 2
        self.setPopupPosition(left,top)
Пример #5
0
    def setPopupPosition(self, left, top):
        if isinstance(left, basestring):
            if left.endswith('%'):
                left = int(left[:-1])
                left = int(left * Window.getClientWidth() / 100)
            elif left.lower().endswith('px'):
                left = int(left[:-2])
        if isinstance(top, basestring):
            if top.lower().endswith('%'):
                top = int(top[:-1])
                top = int(top * Window.getClientHeight() / 100)
            elif top.endswith('px'):
                top = int(top[:-2])

        left = max(left, 0)
        top = max(top, 0)

        # Account for the difference between absolute position and the
        # body's positioning context.
        left -= DOM.getBodyOffsetLeft()
        top -= DOM.getBodyOffsetTop()

        element = self.getElement()
        DOM.setStyleAttribute(element, "left", "%dpx" % left)
        DOM.setStyleAttribute(element, "top", "%dpx" % top)
Пример #6
0
    def onClick(self, sender):
        if sender == self.newpage:
            self.todoId = None
            self.todoTextName.setText('')
            self.todoTextArea.setHTML('')
            return
        elif sender == self.view:
            name = self.todoTextName.getText()
            html = self.todoTextArea.getHTML()
            if not html:
                return
            p = HTMLDialog(name, html)
            p.setPopupPosition(10, 10)
            p.setWidth(Window.getClientWidth()-40)
            p.setHeight(Window.getClientHeight()-40)
            p.show()
            return
        elif sender == self.fDialogButton:
            Window.open(fileedit_url, "fileupload", "width=800,height=600")
            return
            dlg = FileDialog(fileedit_url)
            left = self.fDialogButton.getAbsoluteLeft() + 10
            top = self.fDialogButton.getAbsoluteTop() + 10
            dlg.setPopupPosition(left, top)
            dlg.show()


        id = self.remote.getPage(sender.getValue(sender.getSelectedIndex()),self)
        if id<0:
            self.status.setHTML("Server Error or Invalid Response")
Пример #7
0
 def onClick(self, sender):
     if sender == self.db:
         width = (Window.getClientWidth() - POPUP_WIDTH) / 2.0
         self.popup.setPopupPosition(width, 100)
         self.popup.show()
     else:
         self.process()
Пример #8
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()
Пример #9
0
    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("100%")

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("99%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        authors = [("2008, 2009", "Kenneth Casson Leighton", "*****@*****.**")]
        for years, name, email in authors:
            authors_html = \
            '&copy; %s <a href="mailto:%s">%s</a><br />' %\
            (years, email, name)
        authors_panel = HTML()
        authors_panel.setStyleName("ks-Authors")
        authors_panel.setHTML(authors_html[:-6])

        left_panel = DockPanel(Height="100%")
        left_panel.add(self.sink_list, DockPanel.NORTH)
        left_panel.add(authors_panel, DockPanel.SOUTH)

        self.description.setStyleName("ks-Intro")

        self.panel.add(left_panel, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
Пример #10
0
def start_spinner(container, run_str='Processing<br>Please wait...'):
    global __spinner  # pylint: disable=W0603
    __spinner = Spinner(run_str)
    RootPanel().add(__spinner)
    center = (Window.getClientWidth() - __spinner.size) / 2
    middle = Window.getClientHeight() / 3
    __spinner.setPopupPosition(center, middle)
    __spinner.show()
    __spinner.draw()
    container.setStyleAttribute('opacity', '0.3')
Пример #11
0
 def testResize(self):
     # TODO: window resizing does not work accuratly in browser
     # because getClientWidth etc does not really match GWT. We
     # need to copy the GWT implementation
     if IN_BROWSER:
         return
     self.resize_test = True
     Window.addWindowResizeListener(self)
     self.h = Window.getClientHeight()
     self.w = Window.getClientWidth()
     Window.resize(800, 600)
 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()
Пример #13
0
 def testResize(self):
     # TODO: window resizing does not work accuratly in browser
     # because getClientWidth etc does not really match GWT. We
     # need to copy the GWT implementation
     if IN_BROWSER:
         return
     self.resize_test = True
     Window.addWindowResizeListener(self)
     self.h = Window.getClientHeight()
     self.w = Window.getClientWidth()
     Window.resize(800, 600)
    def setGlassPosition(self):
        top = Window.getScrollTop()
        left = Window.getScrollLeft()
        height = Window.getClientHeight()
        width = Window.getClientWidth()

        DOM.setStyleAttribute(self.glass, "position", "absolute")
        DOM.setStyleAttribute(self.glass, "left", "%s" % \
                              left if left == 0 else "%spx" % left)
        DOM.setStyleAttribute(self.glass, "top", "%s" % \
                              top if top == 0 else "%spx" % top)
        DOM.setStyleAttribute(self.glass, "height", "%spx" % (top + height))
        DOM.setStyleAttribute(self.glass, "width", "%spx" % (left + width))
Пример #15
0
    def setGlassPosition(self):
        top = Window.getScrollTop()
        left = Window.getScrollLeft()
        height = Window.getClientHeight()
        width = Window.getClientWidth()

        DOM.setStyleAttribute(self.glass, "position", "absolute")
        DOM.setStyleAttribute(self.glass, "left", "%s" % \
                              left if left == 0 else "%spx" % left)
        DOM.setStyleAttribute(self.glass, "top", "%s" % \
                              top if top == 0 else "%spx" % top)
        DOM.setStyleAttribute(self.glass, "height", "%spx" % (top + height))
        DOM.setStyleAttribute(self.glass, "width", "%spx" % (left + width))
Пример #16
0
    def onModuleLoad(self):

        self.remote = InfoServicePython()

        self.tree_width = 200

        self.tp = HorizontalPanel()
        self.tp.setWidth("%dpx" % (self.tree_width))
        self.treeview = Trees()
        self.treeview.fTree.addTreeListener(self)
        self.sp = ScrollPanel()
        self.tp.add(self.treeview)
        self.sp.add(self.tp)
        self.sp.setHeight("100%")

        self.horzpanel1 = HorizontalPanel()
        self.horzpanel1.setSize("100%", "100%")
        self.horzpanel1.setBorderWidth(1)
        self.horzpanel1.setSpacing("10px")

        self.rp = RightPanel()
        self.rps = ScrollPanel()
        self.rps.add(self.rp)
        self.rps.setWidth("100%")
        self.rp.setWidth("100%")

        self.cp1 = CollapserPanel(self)
        self.cp1.setWidget(self.sp)
        self.cp1.setHTML("&nbsp;")


        self.midpanel = MidPanel(self)
        self.cp2 = CollapserPanel(self)
        self.cp2.setWidget(self.midpanel)
        self.cp2.setHTML("&nbsp;")

        self.horzpanel1.add(self.cp1)
        self.horzpanel1.add(self.cp2)
        self.horzpanel1.add(self.rps)

        self.cp1.setInitialWidth("%dpx" % self.tree_width)
        self.cp2.setInitialWidth("200px")

        RootPanel().add(self.horzpanel1)

        width = Window.getClientWidth()
        height = Window.getClientHeight()

        self.onWindowResized(width, height)
        Window.addWindowResizeListener(self)
Пример #17
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()
Пример #18
0
    def __init__(self):
        Composite.__init__(self)

        self.vp_list=VerticalPanel()
        self.sinks=[]
        self.selectedSink=-1

        self.sp = ScrollPanel(self.vp_list)
        self.sp.setWidth("14em")

        self.initWidget(self.sp)
        self.setStyleName("ks-List")

        self.resize(Window.getClientWidth(), Window.getClientHeight())
Пример #19
0
    def __init__(self):
        Composite.__init__(self)

        self.vp_list = VerticalPanel()
        self.sinks = []
        self.selectedSink = -1

        self.sp = ScrollPanel(self.vp_list)
        self.sp.setWidth("24em")

        self.initWidget(self.sp)
        self.setStyleName("ks-List")

        self.resize(Window.getClientWidth(), Window.getClientHeight())
Пример #20
0
    def centerBox(self):
        self_width = self.getOffsetWidth()
        self_height = self.getOffsetHeight()

        height = Window.getClientHeight()
        width = Window.getClientWidth()

        center_x = int(width) / 2
        center_y = int(height) / 2

        self_top  = center_y - (int(self_height) / 2)
        self_left = center_x - (int(self_width)  / 2)

        self.setPopupPosition(self_left, self_top)
    def centerBox(self):
        self_width = self.getOffsetWidth()
        self_height = self.getOffsetHeight()

        height = Window.getClientHeight()
        width = Window.getClientWidth()

        center_x = int(width) / 2
        center_y = int(height) / 2

        self_top = center_y - (int(self_height) / 2)
        self_left = center_x - (int(self_width) / 2)

        self.setPopupPosition(self_left, self_top)
Пример #22
0
    def onModuleLoad(self):

        self.remote = InfoServicePython()

        self.tree_width = 200

        self.tp = HorizontalPanel()
        self.tp.setWidth("%dpx" % (self.tree_width))
        self.treeview = Trees()
        self.treeview.fTree.addTreeListener(self)
        self.sp = ScrollPanel()
        self.tp.add(self.treeview)
        self.sp.add(self.tp)
        self.sp.setHeight("100%")

        self.horzpanel1 = HorizontalPanel()
        self.horzpanel1.setSize("100%", "100%")
        self.horzpanel1.setBorderWidth(1)
        self.horzpanel1.setSpacing("10px")

        self.rp = RightPanel()
        self.rps = ScrollPanel()
        self.rps.add(self.rp)
        self.rps.setWidth("100%")
        self.rp.setWidth("100%")

        self.cp1 = CollapserPanel(self)
        self.cp1.setWidget(self.sp)
        self.cp1.setHTML("&nbsp;")


        self.midpanel = MidPanel(self)
        self.cp2 = CollapserPanel(self)
        self.cp2.setWidget(self.midpanel)
        self.cp2.setHTML("&nbsp;")

        self.horzpanel1.add(self.cp1)
        self.horzpanel1.add(self.cp2)
        self.horzpanel1.add(self.rps)

        self.cp1.setInitialWidth("%dpx" % self.tree_width)
        self.cp2.setInitialWidth("200px")

        RootPanel().add(self.horzpanel1)

        width = Window.getClientWidth()
        height = Window.getClientHeight()

        self.onWindowResized(width, height)
        Window.addWindowResizeListener(self)
Пример #23
0
    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        height = Window.getClientHeight()

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("98%")
        self.sp.setHeight("%dpx" % (height - 200))

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("100%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        self.description.setStyleName("ks-Intro")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
Пример #24
0
 def move_off_screen(self, widget):
     (left, top) = self.move(widget)
     width = widget.getOffsetWidth()
     height = widget.getOffsetHeight()
     if (left + width) <= 0:
         return self.end(widget)
     if (top + height) <= 0:
         return self.end(widget)
     width = Window.getClientWidth()
     height = Window.getClientHeight()
     if left >= width:
         return self.end(widget)
     if top >= height:
         return self.end(widget)
     return True
Пример #25
0
 def onShowImpl(self, popup):
     width = self.getOffsetWidth()
     heigth = self.getOffsetHeight()
     w_width = Window.getClientWidth()
     w_heigth = Window.getClientHeight()
     if w_width > width and w_heigth > heigth:
         offset_x = self.getAbsoluteLeft()
         offset_y = self.getAbsoluteTop()
         element = self.getElement()
         if (offset_x + width) > w_width:
             offset_x = w_width - width
             DOM.setStyleAttribute(element, "left", "%dpx" % offset_x)
         if (offset_y + heigth) > w_heigth:
             offset_y = w_heigth - heigth
             DOM.setStyleAttribute(element, "top", "%dpx" % offset_y)
Пример #26
0
 def move_off_screen(self, widget):
     (left, top) = self.move(widget)
     width = widget.getOffsetWidth()
     height = widget.getOffsetHeight()
     if (left + width) <= 0:
         return self.end(widget)
     if (top + height) <= 0:
         return self.end(widget)
     width = Window.getClientWidth()
     height = Window.getClientHeight()
     if left >= width:
         return self.end(widget)
     if top >= height:
         return self.end(widget)
     return True
Пример #27
0
 def onShowImpl(self, popup):
     width = self.getOffsetWidth()
     heigth = self.getOffsetHeight()
     w_width = Window.getClientWidth()
     w_heigth = Window.getClientHeight()
     if w_width > width and w_heigth > heigth:
         offset_x = self.getAbsoluteLeft()
         offset_y = self.getAbsoluteTop()
         element = self.getElement()
         if (offset_x + width) > w_width:
             offset_x = w_width - width
             DOM.setStyleAttribute(element, "left", "%dpx" % offset_x)
         if (offset_y + heigth) > w_heigth:
             offset_y = w_heigth - heigth
             DOM.setStyleAttribute(element, "top", "%dpx" % offset_y)
Пример #28
0
    def onClick(self, sender):
        if (sender == self.signOutLink):
            Window.alert("If this were implemented, you would be signed out now.")
        elif (sender == self.aboutLink):
            # When the 'About' item is selected, show the AboutDialog.
            # Note that showing a dialog box does not block -- execution continues
            # normally, and the dialog fires an event when it is closed.
            dlg = AboutDialog()

            # Position it roughly in the middle of the screen.
            left = (Window.getClientWidth() - 512) / 2
            top = (Window.getClientHeight() - 256) / 2
            Logger("TopPanel", "left: %d" % left)
            Logger("TopPanel", "top: %d" % top)
            dlg.setPopupPosition(left, top)

            dlg.show()
Пример #29
0
 def show_about(self):
     self.dialog = PopupPanel(StyleName='about', autoHide=True)
     
     contents = HTMLPanel('', StyleName='contents')
     self.dialog.setWidget(contents)
     
     html = '<p class="pyjamas">MineSweeper written in Python with ' \
                 '<a href="http://pyjs.org" target="_blank">Pyjamas</a><p>' \
            '<p class="comments">Send comments to ' \
                 '<a href="mailto:[email protected]">' \
                     '[email protected]</a>.<p>'
     contents.setHTML(html)
     
     left = (Window.getClientWidth() - 294) / 2
     top = (Window.getClientHeight() - 112) / 2
     self.dialog.setPopupPosition(left, top)
     self.dialog.show()
Пример #30
0
    def show_about(self):
        self.dialog = PopupPanel(StyleName='about', autoHide=True)

        contents = HTMLPanel('', StyleName='contents')
        self.dialog.setWidget(contents)

        html = '<p class="pyjamas">MineSweeper written in Python with ' \
                    '<a href="http://pyjs.org" target="_blank">Pyjamas</a><p>' \
               '<p class="comments">Send comments to ' \
                    '<a href="mailto:[email protected]">' \
                        '[email protected]</a>.<p>'
        contents.setHTML(html)

        left = (Window.getClientWidth() - 294) / 2
        top = (Window.getClientHeight() - 112) / 2
        self.dialog.setPopupPosition(left, top)
        self.dialog.show()
Пример #31
0
    def onClick(self, sender):
        if (sender == self.signOutLink):
            Window.alert(
                "If this were implemented, you would be signed out now.")
        elif (sender == self.aboutLink):
            # When the 'About' item is selected, show the AboutDialog.
            # Note that showing a dialog box does not block -- execution continues
            # normally, and the dialog fires an event when it is closed.
            dlg = AboutDialog()

            # Position it roughly in the middle of the screen.
            left = (Window.getClientWidth() - 512) / 2
            top = (Window.getClientHeight() - 256) / 2
            Logger("TopPanel", "left: %d" % left)
            Logger("TopPanel", "top: %d" % top)
            dlg.setPopupPosition(left, top)

            dlg.show()
Пример #32
0
    def onWindowResized(self, width, height):

        if not self.resize_test:
            self.fail("onWindowResized called after WindowListener removed")
            return

        nh = Window.getClientHeight()
        nw = Window.getClientWidth()
        # TODO: we cannot assert the exact size, because, we have toolbars
        self.assertTrue(nw != self.w)
        self.assertTrue(nh != self.h)
        self.assertTrue(isinstance(nw, int))
        self.assertTrue(isinstance(nh, int))

        # put the window back to its original size
        # but make sure to switch off resize notify!
        self.resize_test = False
        Window.removeWindowResizeListener(self)
        Window.resize(self.w, self.h)
Пример #33
0
    def onWindowResized(self, width, height):

        if not self.resize_test:
            self.fail("onWindowResized called after WindowListener removed")
            return

        nh = Window.getClientHeight()
        nw = Window.getClientWidth()
        # TODO: we cannot assert the exact size, because, we have toolbars
        self.assertTrue(nw!=self.w)
        self.assertTrue(nh!=self.h)
        self.assertTrue(isinstance(nw, int))
        self.assertTrue(isinstance(nh, int))

        # put the window back to its original size
        # but make sure to switch off resize notify!
        self.resize_test = False
        Window.removeWindowResizeListener(self)
        Window.resize(self.w, self.h)
 def setGlassPosition(self):
     top = Window.getScrollTop()
     left = Window.getScrollLeft()
     height = Window.getClientHeight()
     width = Window.getClientWidth()
     el = self.getElement()
     DOM.setStyleAttribute(el, "position", "absolute")
     DOM.setStyleAttribute(el, "left",
                               "%s" % left if left == 0 else "%spx" % left)
     DOM.setStyleAttribute(el, "top",
                               "%s" % top if top == 0 else "%spx" % top)
     DOM.setStyleAttribute(el, "height", "%spx" % (top + height))
     DOM.setStyleAttribute(el, "width", "%spx" % (left + width))
     # under pyjd glasswidget cannot be transparent,
     # otherwise it drops the mousecapture, so we have
     # to give it a 1% opaque background color
     if pyjd.is_desktop:
         # pyjd uses IE style opacity
         DOM.setStyleAttribute(el, "filter", "alpha(opacity=1)")
         # this is the Moz form of transparency
         DOM.setStyleAttribute(el, "background", "rgba(255,255,255,0.1)")
Пример #35
0
    def __init__(self):

        self.GridTest = None

        self.screen = Screen(Window.getClientWidth(), Window.getClientHeight())
        w = text_app()
        a = self.screen.add_app(w, "text 1", 400, 300)
        a.show()
        w = text_app()
        a = self.screen.add_app(w, "text 2", 400, 300)
        a.show()
        w = slider_app()
        a = self.screen.add_app(w, "s", 20, 100)
        a.show()

        RootPanel().add(self.screen)

        self.loading_apps = []
        self.loading_app = None
        self.loading_desc = None

        self.load_app('../../gridtest/output/', 'GridTest', 'grid test')
        self.load_app('../../widgets/output/', 'Widgets', 'clock')
Пример #36
0
    def __init__(self):

        self.GridTest = None

        self.screen = Screen(Window.getClientWidth(), Window.getClientHeight())
        w = text_app()
        a = self.screen.add_app(w, "text 1", 400, 300)
        a.show()
        w = text_app()
        a = self.screen.add_app(w, "text 2", 400, 300)
        a.show()
        w = slider_app()
        a = self.screen.add_app(w, "s", 20, 100)
        a.show()

        RootPanel().add(self.screen)

        self.loading_apps = []
        self.loading_app = None
        self.loading_desc = None

        self.load_app('../../gridtest/output/', 'GridTest', 'grid test')
        self.load_app('../../widgets/output/', 'Widgets', 'clock')
Пример #37
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()
Пример #38
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()
Пример #39
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()
Пример #40
0
 def execute(self):
     self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
Пример #41
0
    def loadChapters(self):

        self.curInfo = ''
        self.curSink = None
        self.description = HTML()
        self.sink_list = SinkList()
        self.panel = DockPanel()

        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        #self.nf = NamedFrame("section")
        #self.nf.setWidth("100%")
        #self.nf.setHeight("10000")

        self.sp = ScrollPanel(self.sinkContainer)
        #self.sp = VerticalSplitPanel()
        self.sp.setWidth("100%")
        self.sp.setHeight("100%")

        #self.sp.setTopWidget(self.sinkContainer)
        #self.sp.setBottomWidget(self.nf)
        #self.sp.setSplitPosition(10000) # deliberately high - max out.

        vp = VerticalPanel()
        vp.setWidth("99%")
        vp.setHeight("100%")
        vp.add(self.description)
        vp.add(self.sp)

        authors = [
            ("2008, 2009", "Kenneth Casson Leighton", "*****@*****.**")
        ]
        for years, name, email in authors:
            authors_html = \
            '&copy; %s <a href="mailto:%s">%s</a><br />' %\
            (years, email, name)
        authors_panel = HTML()
        authors_panel.setStyleName("ks-Authors")
        authors_panel.setHTML(authors_html[:-6])

        left_panel = DockPanel(Height="100%")
        left_panel.add(self.sink_list, DockPanel.NORTH)
        left_panel.add(authors_panel, DockPanel.SOUTH)

        self.description.setStyleName("ks-Intro")

        self.panel.add(left_panel, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list,
                                            HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")
        self.panel.setCellHeight(vp, "100%")

        Window.addWindowResizeListener(self)

        History.addHistoryListener(self)
        RootPanel().add(self.panel)

        self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
Пример #42
0
 def onClick(self, sender):
     width = (Window.getClientWidth() - POPUP_WIDTH) / 2.0
     self.popup.setPopupPosition(width, 100)
     self.popup.show()
Пример #43
0
 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)    
Пример #44
0
 def testClientDimensions(self):
     h = Window.getClientHeight()
     w = Window.getClientWidth()
     self.assertTrue(isinstance(w, int))
     self.assertTrue(isinstance(h, int))
Пример #45
0
        for obj in self.objects:
            obj.update(2)
        ctx = self.context
        ctx.clearRect(0, 0, self.width, self.height)
        for obj in self.objects:
            obj.draw(ctx)

    def add(self, obj):
        self.objects.append(obj)

    def onLoad(self, img=None):
        if self.img == img:
            self.onTimer()

    def onError(self, img=None):
        #console.log('load img error')
        pass


if __name__ == '__main__':
    canvas = LlkCanvas(int(Window.getClientWidth()),
                       int(Window.getClientHeight()))
    RootPanel().add(canvas)
    img = canvas.img
    for i in range(100):
        canvas.add(
            BasicBox(img, (randint(0, 20), randint(0, 20)),
                     (randint(0, 10), randint(0, 10)), canvas))
    Timer(object=canvas).scheduleRepeating(100)
    #load_image('output.png', Listener( (lambda img:canvas.draw(img)) ))
Пример #46
0
def window_center():
    left = (Window.getClientWidth() - 300) / 2 + Window.getScrollLeft()
    top = (Window.getClientHeight() - 100) / 2 + Window.getScrollTop()
    return left, top
Пример #47
0
            self.map[sbox.yth][sbox.xth] = 0
            self.selected_box = None
    def onKeyDown(self, sender, code, modifiers):
        pass
    def onKeyUp(self, sender, code, modifiers):
        pass
    def onLoad(self, img=None):
        if self.img == img:
            self.onTick(1, True)
            Timer(object=canvas).scheduleRepeating(100)
    def onError(self, img=None):
        #console.log('load img error')
        pass

if __name__ == '__main__':
    canvas = LlkCanvas(int(Window.getClientWidth()), int(Window.getClientHeight()))
    RootPanel().add(canvas)
    img = canvas.img
    imgobjs = []
    for i in range(10):
        xth = i%cwidth
        yth = int(i/cheight)
        print xth, yth
        imgobj = ImgObj(img,xth,yth)
        imgobjs.append(imgobj)

    #imgobjs = sample(imgobjs, len(imgobjs))
    map = \
   [[0,0,1,1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,0],
    [0,0,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,1,0,0],
    [0,0,1,1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,0,0],
Пример #48
0
    def __init__(self, autoHide=None, modal=True, **kwargs):

        PopupPanel.__init__(self, autoHide, modal, **kwargs)

        datasource = None
        id = None

        if kwargs.has_key("datasrc"):
            datasource = kwargs["datasrc"]
        if kwargs.has_key("id"):
            id = kwargs["id"]

        self.setSize(Window.getClientWidth() - 50, Window.getClientHeight() - 50)
        self.setPopupPosition(20, 0)
        DOM.setAttribute(self, "align", "center")

        # self.dbProxInstrucao = DialogBox()
        # self.dbProxInstrucao.setHTML("Alow")
        # botton = Button("Ok")
        # botton.addClickListener(self.onCloseDialog)
        # self.dbProxInstrucao.setWidget(botton)

        self.caption = HTML()
        self.child = None
        self.setHTML("<b>Soma de Matrizes.</b>")

        self.dragging = False
        self.dragStartX = 0
        self.dragStartY = 0

        self.imageFechar = Image("images/fechar.gif", Size=("32px", "32px"), StyleName="gwt-ImageButton")
        self.imgbtnDesfazer = Image("images/previous-arrow.png", Size=("32px", "20px"), StyleName="gwt-ImageButton")
        self.imgbtnFazer = Image("images/next-arrow.png", Size=("32px", "20px"), StyleName="gwt-ImageButton")
        #        self.imgbtnDesfazer.addClickListener(desfazerProxOperacao)
        #        self.imgbtnFazer.addClickListener(fazerProxOperacao)

        self.btnAutomatic = Button("Automático", self.onIniciarAnimacaoAutomatica)
        self.btnInterativo = Button("Interativo")
        if id == "escalar":
            self.btnStepByStep = Button("Passo a passo", IniciarAnimacaoPassoAPasso)
        else:
            self.btnStepByStep = Button("Passo a passo", self.onIniciarAnimacaoPassoAPasso)
        self.btnFazer = Button("fazer >>", fazerProxOperacao)
        # self.btnFazer.setEnabled(False);
        self.btnDesfazer = Button("<< desfazer", desfazerProxOperacao)
        # self.btnDesfazer.setEnabled(False);
        self.btnFechar = PushButton(imageFechar, imageFechar)
        self.btnTestarResposta = Button("Testar Solução")
        self.lbVelocidade = ListBox()
        self.lbVelocidade.setID("lbseg")

        self.lbVelocidade.addItem("0.5 segundo", value=2)
        self.lbVelocidade.addItem("1 segundo", value=1)
        self.lbVelocidade.addItem("2 segundos", value=0.5)
        self.lbVelocidade.addItem("3 segundos", value=1 / 3)
        self.lbVelocidade.addItem("4 segundos", value=0.25)
        self.lbVelocidade.addItem("5 segundos", value=0.20)
        self.lbVelocidade.addItem("6 segundos", value=0.167)
        self.lbVelocidade.addItem("7 segundos", value=0.143)
        self.lbVelocidade.addItem("8 segundos", value=0.125)
        self.lbVelocidade.addItem("10 segundos", value=0.1)

        lblinha1 = ListBox()
        lblinha1.setID("lm1")
        lblinha1.addItem("1", value=1)
        lblinha1.addItem("2", value=2)
        lblinha1.addItem("3", value=3)
        lblinha1.addItem("4", value=4)
        lblinha1.addItem("5", value=5)

        lblinha2 = ListBox()
        lblinha2.setID("lm2")
        lblinha2.addItem("1", value=1)
        lblinha2.addItem("2", value=2)
        lblinha2.addItem("3", value=3)
        lblinha2.addItem("4", value=4)
        lblinha2.addItem("5", value=5)

        lbcoluna1 = ListBox()
        lbcoluna1.setID("cm1")
        lbcoluna1.addItem("1", value=1)
        lbcoluna1.addItem("2", value=2)
        lbcoluna1.addItem("3", value=3)
        lbcoluna1.addItem("4", value=4)
        lbcoluna1.addItem("5", value=5)
        lbcoluna1.addItem("6", value=6)
        lbcoluna1.addItem("7", value=7)

        lbcoluna2 = ListBox()
        lbcoluna2.setID("cm2")
        lbcoluna2.addItem("1", value=1)
        lbcoluna2.addItem("2", value=2)
        lbcoluna2.addItem("3", value=3)
        lbcoluna2.addItem("4", value=4)
        lbcoluna2.addItem("5", value=5)
        lbcoluna2.addItem("6", value=6)
        lbcoluna2.addItem("7", value=7)

        self.lblStatus = Label("Label para Status")

        # Eventos
        self.imageFechar.addClickListener(self.onFecharPopup)

        # Cabeçalho da poupPanel
        self.grid = Grid(1, 16)
        self.grid.setWidth(self.getWidth())
        self.grid.setHTML(0, 0, "<b>Matriz 1:</b> Nº Linhas:")
        self.grid.setWidget(0, 1, lblinha1)
        self.grid.setText(0, 2, "Nº Colunas:")
        self.grid.setWidget(0, 3, lbcoluna1)
        self.grid.setHTML(0, 4, "<b>Matriz 2:</b> Nº Linhas:")
        self.grid.setWidget(0, 5, lblinha2)
        self.grid.setText(0, 6, "Nº Colunas:")
        self.grid.setWidget(0, 7, lbcoluna2)
        #        self.grid.setWidget(0, 3, self.txtColunas)
        self.grid.setWidget(0, 8, self.btnStepByStep)
        self.grid.setWidget(0, 9, self.btnDesfazer)
        self.grid.setWidget(0, 10, self.btnFazer)
        self.grid.setHTML(0, 11, "<b>Velocidade:</b>")
        self.grid.setWidget(0, 12, self.lbVelocidade)
        self.grid.setWidget(0, 13, self.btnAutomatic)
        # self.grid.setWidget(0, 14, self.btnInterativo)
        self.grid.setWidget(0, 15, self.imageFechar)
        # self.grid.setWidget(0, 7, self.btnFechar)
        self.grid.getCellFormatter().setAlignment(
            0, 15, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_TOP
        )

        self.panel = FlexTable(Height="100%", width="100%", BorderWidth="0", CellPadding="0", CellSpacing="0")

        self.panel.setWidget(0, 0, self.caption)
        self.panel.setWidget(1, 0, self.grid)
        self.panel.getCellFormatter().setHeight(2, 0, "100%")
        self.panel.getCellFormatter().setWidth(2, 0, "100%")
        self.panel.getCellFormatter().setAlignment(
            2, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_TOP
        )
        self.panel.setID("contetepopup")

        painelhorizontal = HorizontalPanel()
        gridinterativa = FlexTable()

        painelhorizontal.add(
            HTML(
                "<canvas id='%s' datasrc='%s' width='%s' height='%s' style='image-rendering: optimizespeed !important; '></canvas>"
                % ("soma", datasource, "1000px", "500px")
            )
        )

        ftInterativo = FlexTable(Height="100%", width="100%", BorderWidth="0", CellPadding="0", CellSpacing="0")

        gridinterativa = Grid(4, 4)
        gridinterativa.setWidget(
            0,
            0,
            HTML(
                "<b>M1(</b><input type='text' class='gwt-TextBox' id='linha1' style='width: 25px; height:20px;' maxLength='1'><b> , </b>"
            ),
        )

        gridinterativa.setWidget(
            0,
            1,
            HTML(
                "<input type='text' class='gwt-TextBox' id='coluna1' style='width: 25px;height:20px;' maxLength='1'><b>)&nbsp;+</b>"
            ),
        )

        gridinterativa.setWidget(
            0,
            2,
            HTML(
                "<b>M2(</b>&nbsp;<input type='text' class='gwt-TextBox' id='linha2' style='width: 25px; height:20px;' maxLength='1'><b> , </b>"
            ),
        )

        gridinterativa.setWidget(
            0,
            3,
            HTML(
                "<input type='text' class='gwt-TextBox' id='coluna2' style='width: 25px; height:20px;' maxLength='1'><b>)&nbsp;=</b>"
            ),
        )

        gridinterativa.setWidget(
            2,
            0,
            HTML(
                "&nbsp;&nbsp;<b>(</b><input type='text' class='gwt-TextBox' id='n1' style='width: 25px; height:20px;' maxLength='1'><b>)&nbsp;+</b>"
            ),
        )

        gridinterativa.setWidget(
            2,
            1,
            HTML(
                "<b>(</b><input type='text' class='gwt-TextBox' id='n2' style='width: 25px; height:20px;' maxLength='1'><b>)</b>"
            ),
        )

        gridinterativa.setWidget(
            2,
            2,
            HTML(
                "<b>=&nbsp;</b>&nbsp;<input type='text' class='gwt-TextBox' id='solucao' style='width: 25px; height:20px;' maxLength='1'>"
            ),
        )

        ftInterativo.setHTML(0, 0, "</br>")
        ftInterativo.setHTML(1, 0, "<b><h3>Painel Interativo<h3></b>")
        # ftInterativo.setWidget(2, 0, self.btnInterativo)
        ftInterativo.setWidget(3, 0, gridinterativa)
        ftInterativo.setWidget(4, 0, self.btnTestarResposta)
        ftInterativo.setHTML(5, 0, "</br>")
        ftInterativo.setHTML(6, 0, "Use a tecla tab para agilizar.")

        ftInterativo.getCellFormatter().setAlignment(
            4, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_TOP
        )
        ftInterativo.getCellFormatter().setAlignment(
            1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_TOP
        )

        # painelhorizontal.add(ftInterativo)

        self.panel.setWidget(2, 0, painelhorizontal)

        self.panel.setWidget(3, 0, self.lblStatus)

        self.panel.setStyleName("dialogContent")

        PopupPanel.setWidget(self, self.panel)

        self.setStyleName("gwt-DialogBox")
        self.caption.setStyleName("Caption")
        self.caption.addMouseListener(self)
Пример #49
0
 def testClientDimensions(self):
     h = Window.getClientHeight()
     w = Window.getClientWidth()
     self.assertTrue(isinstance(w, int))
     self.assertTrue(isinstance(h, int))
Пример #50
0
 def execute(self):
     self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
Пример #51
0
 def adjustWidths(self, windowWidth=None):
     if windowWidth is None:
         windowWidth = Window.getClientWidth()
     width = windowWidth - self.leftPanelWidth - self.widthFudgeFactor
     if self.iconPanel is not None:
         self.icons.setWidth(width)