コード例 #1
0
 def __init__(self, c):
     PopupPanel.__init__(self, True)
     p = SimplePanel()
     p.add(c)
     c.show(10, 10)
     p.setWidth("100%")
     self.setWidget(p)
コード例 #2
0
ファイル: DialogBox.py プロジェクト: anandology/pyjamas
    def __init__(self, autoHide=None, modal=True, **kwargs):
        # Init section
        self.dragging = False
        self.dragStartX = 0
        self.dragStartY = 0
        self.child = None
        self.panel = FlexTable(
            Height="100%",
            BorderWidth="0",
            CellPadding="0",
            CellSpacing="0",
        )
        cf = self.panel.getCellFormatter()
        cf.setHeight(1, 0, "100%")
        cf.setWidth(1, 0, "100%")
        cf.setAlignment(
            1, 0,
            HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE,
        )

        # Arguments section
        self.modal = modal
        self.caption = HTML()
        self.panel.setWidget(0, 0, self.caption)
        self.caption.setStyleName("Caption")
        self.caption.addMouseListener(self)

        # Finalize
        kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox")
        PopupPanel.__init__(self, autoHide, modal, **kwargs)
        PopupPanel.setWidget(self, self.panel)
コード例 #3
0
ファイル: Calendar.py プロジェクト: jwashin/pyjs
 def __init__(self, c):
     PopupPanel.__init__(self, True)
     p = SimplePanel()
     p.add(c)
     c.show(10, 10)
     p.setWidth("100%")
     self.setWidget(p)
コード例 #4
0
class PopupPanelDemo(SimplePanel):
    def __init__(self):
        SimplePanel.__init__(self)

        vPanel = VerticalPanel()
        vPanel.setSpacing(4)

        self._btn = Button("Click Me", getattr(self, "showPopup"))

        vPanel.add(HTML("Click on the button below to display the popup."))
        vPanel.add(self._btn)

        self.add(vPanel)

    def showPopup(self, event):
        contents = HTML("Hello, World!")
        contents.addClickListener(getattr(self, "onClick"))

        self._popup = PopupPanel(autoHide=True)
        self._popup.add(contents)
        self._popup.setStyleName("showcase-popup")

        left = self._btn.getAbsoluteLeft() + 10
        top = self._btn.getAbsoluteTop() + 10
        self._popup.setPopupPosition(left, top)
        self._popup.show()

    def onClick(self, sender=None):
        self._popup.hide()
コード例 #5
0
    def __init__(self, autoHide=None, modal=True, centered=False, **kwargs):
        # Init section
        self.dragging = False
        self.dragStartX = 0
        self.dragStartY = 0
        self.child = None
        self.panel = FlexTable(
            Height="100%",
            BorderWidth="0",
            CellPadding="0",
            CellSpacing="0",
        )
        cf = self.panel.getCellFormatter()
        cf.setHeight(1, 0, "100%")
        cf.setWidth(1, 0, "100%")
        cf.setAlignment(
            1,
            0,
            HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE,
        )

        # Arguments section
        self.modal = modal
        self.caption = HTML()
        self.panel.setWidget(0, 0, self.caption)
        self.caption.setStyleName("Caption")
        self.caption.addMouseListener(self)

        # Finalize
        kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox")
        PopupPanel.__init__(self, autoHide, modal, **kwargs)
        PopupPanel.setWidget(self, self.panel)

        self.centered = centered
コード例 #6
0
    def draw(self):
        if self.classIcon != "":
            self.icon = Element(Element=DOM.createElement("i"),
                                StyleName=self.classIcon)
            self.add(self.icon)

        if self.rootPanel is None:
            self.popup = PopupPanel(autoHide=True,
                                    modal=False,
                                    rootpanel=self,
                                    StyleName='dropdown_btn')
            DOM.setStyleAttribute(self.popup.element, "position", "static")
        else:  #o poup nao esta fechando!
            self.popup = PopupPanel(autoHide=True,
                                    modal=False,
                                    rootpanel=self.rootPanel,
                                    StyleName='dropdown_btn')

        self.dropdown_arrow = Element(Element=DOM.createElement('div'),
                                      StyleName='dropdown_arrow')
        self.title = Element(Element=DOM.createSpan(), StyleName='title')
        DOM.setInnerHTML(self.title.getElement(), self.text)
        self.add(self.title)
        self.add(Widget(Element=DOM.createDiv(), StyleName='r'))
        self.add(Widget(Element=DOM.createDiv(), StyleName='coverup'))
        self.popup.add(self.dropdown_arrow)
コード例 #7
0
ファイル: popupPanel.py プロジェクト: Afey/pyjs
class PopupPanelDemo(SimplePanel):
    def __init__(self):
        SimplePanel.__init__(self)

        vPanel = VerticalPanel(Spacing=4)

        self._btn = Button("Click Me", getattr(self, "showPopup"))

        vPanel.add(HTML("Click on the button below to display the popup."))
        vPanel.add(self._btn)

        self.add(vPanel)


    def showPopup(self, event):
        contents = HTML("Hello, World!")
        contents.addClickListener(getattr(self, "onClick"))

        self._popup = PopupPanel(autoHide=True)
        self._popup.add(contents)
        self._popup.setStyleName("showcase-popup")

        left = self._btn.getAbsoluteLeft() + 10
        top  = self._btn.getAbsoluteTop() + 10
        self._popup.setPopupPosition(left, top)
        self._popup.show()


    def onClick(self, sender=None):
        self._popup.hide()
コード例 #8
0
ファイル: Popups.py プロジェクト: wkornewald/pyjs
    def hide(self, autoClosed=False):
        if not self.showing:
            return

        if modal_popups.has_key(self.identifier):
            del modal_popups[self.identifier]

        PopupPanel.hide(self)
コード例 #9
0
ファイル: Popups.py プロジェクト: fluidinfo/Tickery
    def hide(self, autoClosed=False):
        if not self.showing:
            return

        if self.identifier in modal_popups:
            del modal_popups[self.identifier]

        PopupPanel.hide(self)
コード例 #10
0
ファイル: Popups.py プロジェクト: brodybits/pyjs
 def __init__(self):
     PopupPanel.__init__(self, True)
     
     contents = HTML("Click anywhere outside this popup to make it disappear.")
     contents.setWidth("128px")
     self.setWidget(contents)
     
     self.setStyleName("ks-popups-Popup")
コード例 #11
0
ファイル: WebguiHelpers.py プロジェクト: ncqgm/gnumed
    def __init__(self, txt, **kwargs):
        txt = HTML(txt)
        txt.addClickListener(self)

        PopupPanel.__init__(self, autoHide=True, StyleName="showcase-popup",
                            **kwargs)
        self.add(txt)
        self.show()
コード例 #12
0
    def __init__(self):
        PopupPanel.__init__(self, True)

        contents = HTML(
            "Click anywhere outside this popup to make it disappear.")
        contents.setWidth("128px")
        self.setWidget(contents)

        self.setStyleName("ks-popups-Popup")
コード例 #13
0
    def __init__(self, txt, **kwargs):
        txt = HTML(txt)
        txt.addClickListener(self)

        PopupPanel.__init__(self,
                            autoHide=True,
                            StyleName="showcase-popup",
                            **kwargs)
        self.add(txt)
        self.show()
コード例 #14
0
ファイル: Popups.py プロジェクト: Afey/pyjs
    def show(self):
        if self.showing:
            return

        if modal_popups.has_key(self.identifier) and \
           modal_popups[self.identifier] != self:
            return
        modal_popups[self.identifier] = self

        PopupPanel.show(self)
コード例 #15
0
 def draw(self):
     self.title = Element(Element=DOM.createSpan(), StyleName='title')
     DOM.setInnerHTML(self.title.getElement(), self.text)
     self.add(self.title)
     self.tip = PopupPanel(Element=DOM.createElement('code'), autoHide=True, modal=False, rootpanel=self)
     div = Element(Element=DOM.createElement('div'), StyleName='joyride-tip-guide')
     div.add(Widget(Element=DOM.createSpan(), StyleName='joyride-nub left'))
     self.tipItens = Element(Element=DOM.createElement('div'), StyleName='tip-itens')
     div.add(self.tipItens)
     self.tip.add(div)
コード例 #16
0
ファイル: Popups.py プロジェクト: wkornewald/pyjs
    def show(self):
        if self.showing:
            return

        if modal_popups.has_key(self.identifier) and \
           modal_popups[self.identifier] != self:
            return
        modal_popups[self.identifier] = self

        PopupPanel.show(self)
コード例 #17
0
ファイル: Popups.py プロジェクト: fluidinfo/Tickery
    def show(self):
        if self.showing:
            return

        if (self.identifier in modal_popups and
            modal_popups[self.identifier] != self):
            return
        modal_popups[self.identifier] = self

        PopupPanel.show(self)
コード例 #18
0
    def showPopup(self, event):
        contents = HTML("Hello, World!")
        contents.addClickListener(getattr(self, "onClick"))

        self._popup = PopupPanel(autoHide=True)
        self._popup.add(contents)
        self._popup.setStyleName("showcase-popup")

        left = self._btn.getAbsoluteLeft() + 10
        top = self._btn.getAbsoluteTop() + 10
        self._popup.setPopupPosition(left, top)
        self._popup.show()
コード例 #19
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()
コード例 #20
0
ファイル: RichTextToolbar.py プロジェクト: minghuascode/pyj
    def __init__(self, editor):
        PopupPanel.__init__(self, glass=True)

        self.m_origAnchorStart = None
        self.m_origAnchorEnd = None
        self.m_origTargetText = ""
        self.m_editor = editor

        vpanel = VerticalPanel()
        vpanel.setWidth("350px")

        self.m_webPageText = TextBox()
        self.m_webPageText.setText("http:#")
        self.m_webPageText.setWidth("320px")

        vpanel.add(self.m_webPageText)

        lbl = Label("Display:")

        self.m_targetText = TextBox()
        self.m_targetText.setWidth("100%")

        lpanel = HorizontalPanel()
        lpanel.add(lbl)
        lpanel.add(self.m_targetText)

        vpanel.add(lpanel)

        self.m_fillOutCB = CheckBox("Change entire link")
        self.m_fillOutCB.setVisible(False)
        self.m_fillOutCB.addClickListener(self)
        vpanel.add(self.m_fillOutCB)

        self.m_okBut = Button("Ok", self)
        self.m_okBut.addStyleName("float-left")

        self.m_cancelBut = Button("Cancel", self)
        self.m_cancelBut.addStyleName("float-left")

        hpanel = HorizontalPanel()
        hpanel.add(self.m_okBut)
        hpanel.add(self.m_cancelBut)

        vpanel.add(hpanel)

        self.add(vpanel)
        self.setStyleName("gwt-DialogBox")
コード例 #21
0
ファイル: RichTextToolbar.py プロジェクト: Afey/pyjs
    def __init__(self, editor):
        PopupPanel.__init__(self, glass=True)

        self.m_origAnchorStart = None
        self.m_origAnchorEnd = None
        self.m_origTargetText = ""
        self.m_editor = editor

        vpanel = VerticalPanel()
        vpanel.setWidth("350px")

        self.m_webPageText = TextBox()
        self.m_webPageText.setText("http:#")
        self.m_webPageText.setWidth("320px")

        vpanel.add(self.m_webPageText)

        lbl = Label("Display:")

        self.m_targetText = TextBox()
        self.m_targetText.setWidth("100%")

        lpanel = HorizontalPanel()
        lpanel.add(lbl)
        lpanel.add(self.m_targetText)

        vpanel.add(lpanel)

        self.m_fillOutCB = CheckBox("Change entire link")
        self.m_fillOutCB.setVisible(False)
        self.m_fillOutCB.addClickListener(self)
        vpanel.add(self.m_fillOutCB)

        self.m_okBut = Button("Ok", self)
        self.m_okBut.addStyleName("float-left")

        self.m_cancelBut = Button("Cancel", self)
        self.m_cancelBut.addStyleName("float-left")

        hpanel = HorizontalPanel()
        hpanel.add(self.m_okBut)
        hpanel.add(self.m_cancelBut)

        vpanel.add(hpanel)

        self.add(vpanel)
        self.setStyleName("gwt-DialogBox")
コード例 #22
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()
コード例 #23
0
ファイル: MenuBarPopupPanel.py プロジェクト: Afey/pyjs
 def onEventPreview(self, event):
     type = DOM.eventGetType(event)
     if type == "click":
         target = DOM.eventGetTarget(event)
         parentMenuElement = self.item.getParentMenu().getElement()
         if DOM.isOrHasChild(parentMenuElement, target):
             return False
     return PopupPanel.onEventPreview(self, event)
 def onEventPreview(self, event):
     type = DOM.eventGetType(event)
     if type == "click":
         target = DOM.eventGetTarget(event)
         parentMenuElement = self.item.getParentMenu().getElement()
         if DOM.isOrHasChild(parentMenuElement, target):
             return False
     return PopupPanel.onEventPreview(self, event)
コード例 #25
0
ファイル: Popups.py プロジェクト: fluidinfo/Tickery
    def __init__(self, identifier, autoHide=None, modal=False, rootpanel=None):
        PopupPanel.__init__(self, autoHide, modal, rootpanel)

        self.identifier = identifier
        self.caption = HTML()
        self.child = None
        self.showing = False
        self.dragging = False
        self.dragStartX = 0
        self.dragStartY = 0
        self.panel = FlexTable()

        self.closeButton = Image('cancel.png')
        self.closeButton.addClickListener(self)
        dock = DockPanel()
        dock.setSpacing(0)

        dock.add(self.closeButton, DockPanel.EAST)
        dock.add(self.caption, DockPanel.WEST)

        dock.setCellHorizontalAlignment(self.closeButton,
                                        HasAlignment.ALIGN_RIGHT)
        dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
        dock.setCellWidth(self.caption, '100%')
        dock.setWidth('100%')

        self.panel.setWidget(0, 0, dock)
        self.panel.setHeight('100%')
        self.panel.setBorderWidth(0)
        self.panel.setCellPadding(0)
        self.panel.setCellSpacing(0)
        self.panel.getCellFormatter().setHeight(1, 0, '100%')
        self.panel.getCellFormatter().setWidth(1, 0, '100%')
        #self.panel.getCellFormatter().setAlignment(1, 0,
        # HasHorizontalAlignment.ALIGN_CENTER,
        # HasVerticalAlignment.ALIGN_MIDDLE)
        PopupPanel.setWidget(self, self.panel)

        self.setStyleName('gwt-DialogBox')
        self.caption.setStyleName('Caption')
        self.closeButton.setStyleName('Close')
        dock.setStyleName('Header')
        self.caption.addMouseListener(self)
コード例 #26
0
ファイル: Popups.py プロジェクト: wkornewald/pyjs
 def onEventPreview(self, event):
     # preventDefault on mousedown events, outside of the
     # dialog, to stop text-selection on dragging
     type = DOM.eventGetType(event)
     if type == 'mousedown':
         target = DOM.eventGetTarget(event)
         elem = self.caption.getElement()
         event_targets_popup = target and DOM.isOrHasChild(elem, target)
         if event_targets_popup:
             DOM.eventPreventDefault(event)
     return PopupPanel.onEventPreview(self, event)
コード例 #27
0
ファイル: PopupPagina.py プロジェクト: nielsonsantana/emath
 def onEventPreview(self, event):
     # preventDefault on mousedown events, outside of the
     # dialog, to stop text-selection on dragging
     type = DOM.eventGetType(event)
     if type == "mousedown":
         target = DOM.eventGetTarget(event)
         elem = self.caption.getElement()
         event_targets_popup = target and DOM.isOrHasChild(elem, target)
         if event_targets_popup:
             DOM.eventPreventDefault(event)
     return PopupPanel.onEventPreview(self, event)
    def onEventPreview(self, event):
        type = DOM.eventGetType(event)
        if type == "click":
            target = DOM.eventGetTarget(event)
            parentMenuElement = self.item.getElement()
            if DOM.isOrHasChild(parentMenuElement, target):
                if self.item.onBrowserEvent(event):
                    self.hide()
                return True

        return PopupPanel.onEventPreview(self, event)
コード例 #29
0
    def __init__(self, **kwargs):
        self.choicesPopup = PopupPanel(True, False)
        self.choices = ListBox()
        self.items = SimpleAutoCompletionItems()
        self.popupAdded = False
        self.visible = False

        self.choices.addClickListener(self)
        self.choices.addChangeListener(self)

        self.choicesPopup.add(self.choices)
        self.choicesPopup.addStyleName("AutoCompleteChoices")

        self.choices.setStyleName("list")

        if not kwargs.has_key('StyleName'):
            kwargs['StyleName'] = "gwt-AutoCompleteTextBox"

        TextBox.__init__(self, **kwargs)
        self.addKeyboardListener(self)
コード例 #30
0
ファイル: Popups.py プロジェクト: wkornewald/pyjs
    def __init__(self, identifier, autoHide=None, modal=False, rootpanel=None):
        PopupPanel.__init__(self, autoHide, modal, rootpanel)

        self.identifier = identifier
        self.caption = HTML()
        self.child = None
        self.showing = False
        self.dragging = False
        self.dragStartX = 0
        self.dragStartY = 0
        self.panel = FlexTable()

        self.closeButton = Image("images/cancel.png")
        self.closeButton.addClickListener(self)
        dock = DockPanel()
        dock.setSpacing(0)

        dock.add(self.closeButton, DockPanel.EAST)
        dock.add(self.caption, DockPanel.WEST)

        dock.setCellHorizontalAlignment(self.closeButton,
                                        HasAlignment.ALIGN_RIGHT)
        dock.setCellHorizontalAlignment(self.caption, HasAlignment.ALIGN_LEFT)
        dock.setCellWidth(self.caption, "100%")
        dock.setWidth("100%")

        self.panel.setWidget(0, 0, dock)
        self.panel.setHeight("100%")
        self.panel.setBorderWidth(0)
        self.panel.setCellPadding(0)
        self.panel.setCellSpacing(0)
        self.panel.getCellFormatter().setHeight(1, 0, "100%")
        self.panel.getCellFormatter().setWidth(1, 0, "100%")
        #self.panel.getCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE)
        PopupPanel.setWidget(self, self.panel)

        self.setStyleName("gwt-DialogBox")
        self.caption.setStyleName("Caption")
        self.closeButton.setStyleName("Close")
        dock.setStyleName("Header")
        self.caption.addMouseListener(self)
コード例 #31
0
ファイル: Contacts.py プロジェクト: Ludovic-Condette/pyjs
    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")
コード例 #32
0
ファイル: spinner.py プロジェクト: pombredanne/pysysdevel
    def __init__(self, text=''):
        PopupPanel.__init__(self)

        self.width       = 15
        self.r1          = 35
        self.r2          = 60
        self.cx          = self.r2 + self.width
        self.cy          = self.r2 + self.width
        self.numSectors  = 12
        self.size        = self.r2*2 + self.width*2
        self.speed       = 1.5  # seconds per rotation

        self.canvas = Raphael(self.size, self.size)
        self.sectors = []
        self.opacity = []
        vp = VerticalPanel()
        vp.add(self.canvas)
        blurb = HTML(text)
        blurb.setStyleAttribute('text-align', 'center')
        vp.add(blurb)
        self.add(vp)
コード例 #33
0
ファイル: popupPanel.py プロジェクト: Afey/pyjs
    def showPopup(self, event):
        contents = HTML("Hello, World!")
        contents.addClickListener(getattr(self, "onClick"))

        self._popup = PopupPanel(autoHide=True)
        self._popup.add(contents)
        self._popup.setStyleName("showcase-popup")

        left = self._btn.getAbsoluteLeft() + 10
        top  = self._btn.getAbsoluteTop() + 10
        self._popup.setPopupPosition(left, top)
        self._popup.show()
コード例 #34
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")
コード例 #35
0
    def __init__(self, sender, offsetX, offsetY, contents,
                       show_delay, hide_delay, styleName, **kwargs):
        """ contents may be a text string or it may be a widget
        """
        PopupPanel.__init__(self, True, **kwargs)
        self.show_delay = show_delay
        self.hide_delay = hide_delay
        
        if isinstance(contents, basestring):
            contents = HTML(contents)
        self.add(contents)

        left = sender.getAbsoluteLeft() + offsetX
        top = sender.getAbsoluteTop() + offsetY

        self.setPopupPosition(left, top)
        self.setStyleName(styleName)

        if tooltip_hide_timer:
            self.tooltip_show_timer = Timer(1, self)
        else:
            self.tooltip_show_timer = Timer(self.show_delay, self)
コード例 #36
0
    def onEventPreview(self, event):
        type = DOM.eventGetType(event)
        if type == "click":
            target = DOM.eventGetTarget(event)
            parentMenuElement = self.item.getElement()
            if DOM.isOrHasChild(parentMenuElement, target):
                if self.item.findItem(target):
                    self.hide()
                    DOM.eventCancelBubble(event, True)
                    DOM.eventStopPropagation(event)

                return True

        return PopupPanel.onEventPreview(self, event)
コード例 #37
0
    def onEventPreview(self, event):
        type = DOM.eventGetType(event)
        if type == "click":
            target = DOM.eventGetTarget(event)
            parentMenuElement = self.item.getElement()
            if DOM.isOrHasChild(parentMenuElement, target):
                if self.item.findItem(target):
                    self.hide()
                    DOM.eventCancelBubble(event, True)
                    DOM.eventStopPropagation(event)

                return True

        return PopupPanel.onEventPreview(self, event)
コード例 #38
0
ファイル: minesweeper.py プロジェクト: anandology/pyjamas
 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()
コード例 #39
0
	def __init__(self, url):
		self.choicesPopup = PopupPanel(True)
		self.choices = ListBox()
		self.items = AutoCompleteURL(url)
		self.popupAdded = False
		self.visible = False
		
		TextBox.__init__(self)
		self.addKeyboardListener(self)
		self.choices.addChangeListener(self)
		self.setStyleName("AutoCompleteTextBox")
		
		self.choicesPopup.add(self.choices)
		self.choicesPopup.addStyleName("AutoCompleteChoices")
		
		self.choices.setStyleName("list")
		self.url = url
コード例 #40
0
ファイル: AutoComplete.py プロジェクト: anandology/pyjamas
    def __init__(self, **kwargs):
        self.choicesPopup = PopupPanel(True, False)
        self.choices = ListBox()
        self.items = SimpleAutoCompletionItems()
        self.popupAdded = False
        self.visible = False

        self.choices.addClickListener(self)
        self.choices.addChangeListener(self)

        self.choicesPopup.add(self.choices)
        self.choicesPopup.addStyleName("AutoCompleteChoices")
            
        self.choices.setStyleName("list")

        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-AutoCompleteTextBox"

        TextBox.__init__(self, **kwargs)
        self.addKeyboardListener(self)
コード例 #41
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()
コード例 #42
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()
コード例 #43
0
class AutoCompleteByURLTextBox(AutoCompleteTextBox):
	def __init__(self, url):
		self.choicesPopup = PopupPanel(True)
		self.choices = ListBox()
		self.items = AutoCompleteURL(url)
		self.popupAdded = False
		self.visible = False
		
		TextBox.__init__(self)
		self.addKeyboardListener(self)
		self.choices.addChangeListener(self)
		self.setStyleName("AutoCompleteTextBox")
		
		self.choicesPopup.add(self.choices)
		self.choicesPopup.addStyleName("AutoCompleteChoices")
		
		self.choices.setStyleName("list")
		self.url = url
	
	"""
	def setCompletionItems(self, items):
		if not items.getCompletionItems:
			items = AutoCompletionURL(self.url)
		
		self.items = items

	def getCompletionItems(self):
		return self.items
	"""
	
	def onKeyUp(self, arg0, arg1, arg2):
		if arg1 == KeyboardListener.KEY_DOWN:
			selectedIndex = self.choices.getSelectedIndex()
			selectedIndex += 1
			if selectedIndex > self.choices.getItemCount():
				selectedIndex = 0
		
			self.choices.setSelectedIndex(selectedIndex)		   
			return

		if arg1 == KeyboardListener.KEY_UP:
			selectedIndex = self.choices.getSelectedIndex()
			selectedIndex -= 1
			if selectedIndex < 0:
				selectedIndex = self.choices.getItemCount()
			self.choices.setSelectedIndex(selectedIndex)
			return

		if arg1 == KeyboardListener.KEY_ENTER:
			if self.visible:
				self.complete()	  
			return

		if arg1 == KeyboardListener.KEY_ESCAPE:
			self.choices.clear()
			self.choicesPopup.hide()
			self.visible = False
			return

		text = self.getText()
		matches = []
		if len(text) > 0:
			matches = self.items.getCompletionItems(text)

		if len(matches) > 0:
			self.choices.clear()

			for i in range(len(matches)):
				self.choices.addItem(matches[i])
				
			if len(matches) == 1 and matches[0] == text:
				self.choicesPopup.hide()
			else:
				self.choices.setSelectedIndex(0)
				self.choices.setVisibleItemCount(len(matches) + 1)
					
				if not self.popupAdded:
					RootPanel().add(self.choicesPopup)
					self.popupAdded = True

				self.choicesPopup.show()
				self.visible = True
				self.choicesPopup.setPopupPosition(self.getAbsoluteLeft(), self.getAbsoluteTop() + self.getOffsetHeight())
				self.choices.setWidth(self.getOffsetWidth() + "px")
		else:
			self.visible = False
			self.choicesPopup.hide()
コード例 #44
0
 def _getProps(self):
     return PopupPanel._getProps() + self._props
コード例 #45
0
ファイル: PopupPagina.py プロジェクト: nielsonsantana/emath
    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)
コード例 #46
0
ファイル: PopupPagina.py プロジェクト: nielsonsantana/emath
 def doDetachChildren(self):
     PopupPanel.doDetachChildren(self)
     self.caption.onDetach()
 def __init__(self, item, **kwargs):
     self.item = item
     kwargs['Widget'] = item
     PopupPanel.__init__(self, True, **kwargs)
コード例 #48
0
 def hide(self, autoClosed=False):
     self.tooltip_show_timer.cancel()
     PopupPanel.hide(self, autoClosed)
コード例 #49
0
 def __init__(self, item, **kwargs):
     self.item = item
     kwargs['Widget'] = item
     PopupPanel.__init__(self, True, **kwargs)
コード例 #50
0
class MenuCmd:
    def __init__(self, menu, command):
        self.menu = menu
        self.command = command

    def execute(self):
        if self.command in ('Beginner', 'Intermediate', 'Expert', 'Custom'):
            body = doc().getElementsByTagName('body').item(0)
            body.setAttribute('id', self.command)

        modes = {
            'New': [(0, 0), 0],
            'Beginner': [(8, 8), 1],
            'Intermediate': [(16, 16), 2],
            'Expert': [(16, 32), 3]
        }
        level = modes.get(self.command)
        if level:
            if level[1]:
                self.menu.game.level = level[1]
            self.menu.game.next_game(level[0])
        elif self.command == 'Custom':
            self.menu.game.level = 4
            self.show_custom()
        elif self.command == 'Instructions':
            pass
        elif self.command == 'About':
            self.show_about()

    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()

    def new_game(self, event):
        try:
            row = int(self.row.getText())
        except:
            Window.alert('Invalid number in rows')
            return
        try:
            column = int(self.column.getText())
        except:
            Window.alert('Invalid number in columns')
            return
        try:
            bomb = int(self.bomb.getText())
        except:
            bomb = 0
        if bomb >= (row * column):
            Window.alert("Number of bombs should not be greater than " \
                         "rows x columns.")
        else:
            self.menu.game.next_game((row, column), bomb)
            self.close_dialog()

    def close_dialog(self, event):
        self.dialog.hide()

    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()
コード例 #51
0
class Dropdown(Element, ClickHandler, MouseHandler):
    def __init__(self,
                 text,
                 menuClick,
                 itemClick,
                 classIcon="",
                 rootPanel=None,
                 **kw):
        Element.__init__(self, Element=DOM.createElement('li'), **kw)
        ClickHandler.__init__(self)
        MouseHandler.__init__(self)
        self.text = text
        self.itemClick = itemClick
        self.menuClick = menuClick
        self.addClickListener(self)
        self.classIcon = classIcon
        self.rootPanel = rootPanel
        self.draw()

    def onClick(self, sender):
        if self.popup.showing: self.popup.hide()
        else:
            if self.menuClick is not None:
                self.menuClick()
            self.popup.show()

    def draw(self):
        if self.classIcon != "":
            self.icon = Element(Element=DOM.createElement("i"),
                                StyleName=self.classIcon)
            self.add(self.icon)

        if self.rootPanel is None:
            self.popup = PopupPanel(autoHide=True,
                                    modal=False,
                                    rootpanel=self,
                                    StyleName='dropdown_btn')
            DOM.setStyleAttribute(self.popup.element, "position", "static")
        else:  #o poup nao esta fechando!
            self.popup = PopupPanel(autoHide=True,
                                    modal=False,
                                    rootpanel=self.rootPanel,
                                    StyleName='dropdown_btn')

        self.dropdown_arrow = Element(Element=DOM.createElement('div'),
                                      StyleName='dropdown_arrow')
        self.title = Element(Element=DOM.createSpan(), StyleName='title')
        DOM.setInnerHTML(self.title.getElement(), self.text)
        self.add(self.title)
        self.add(Widget(Element=DOM.createDiv(), StyleName='r'))
        self.add(Widget(Element=DOM.createDiv(), StyleName='coverup'))
        self.popup.add(self.dropdown_arrow)

    def changeIcon(self, classIcon):
        DOM.setAttribute(self.icon.getElement(), "className", classIcon)

    def setText(self):
        DOM.setInnerHTML(self.title.getElement(), self.text)

    def changeTexts(self):
        for iten in self.dropdown_arrow.children:
            iten.changeTexts()

    def ItenClick(self, value):
        self.itemClick(value)

    def getValues(self):
        return self.dropdown_arrow.children

    def addValues(self, values):
        self.removeValues()
        for value in values:
            self.addValue(value)

    def addValue(self, value, classIcon=''):
        if classIcon == '':
            self.dropdown_arrow.append(
                MenuItenListener(self.ItenClick,
                                 value,
                                 StyleName='dropdownItem'))
        else:
            self.dropdown_arrow.append(
                MenuItenListenerIcon(self.ItenClick,
                                     value,
                                     classIcon,
                                     StyleName='dropdownItem'))

    def removeValues(self):
        self.dropdown_arrow.removeAll()
コード例 #52
0
ファイル: AutoComplete.py プロジェクト: anandology/pyjamas
class AutoCompleteTextBox(TextBox):
    def __init__(self, **kwargs):
        self.choicesPopup = PopupPanel(True, False)
        self.choices = ListBox()
        self.items = SimpleAutoCompletionItems()
        self.popupAdded = False
        self.visible = False

        self.choices.addClickListener(self)
        self.choices.addChangeListener(self)

        self.choicesPopup.add(self.choices)
        self.choicesPopup.addStyleName("AutoCompleteChoices")
            
        self.choices.setStyleName("list")

        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-AutoCompleteTextBox"

        TextBox.__init__(self, **kwargs)
        self.addKeyboardListener(self)

    def setCompletionItems(self, items):
        if not hasattr(items, 'getCompletionItems'):
            items = SimpleAutoCompletionItems(items)
        
        self.items = items

    def getCompletionItems(self):
        return self.items

    def onKeyDown(self, arg0, arg1, arg2):
        pass

    def onKeyPress(self, arg0, arg1, arg2):
        pass

    def onKeyUp(self, arg0, arg1, arg2):
        if arg1 == KeyboardListener.KEY_DOWN:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex += 1
            if selectedIndex >= self.choices.getItemCount():
                selectedIndex = 0
            self.choices.setSelectedIndex(selectedIndex)           
            return

        if arg1 == KeyboardListener.KEY_UP:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex -= 1
            if selectedIndex < 0:
                selectedIndex = self.choices.getItemCount() - 1
            self.choices.setSelectedIndex(selectedIndex)
            return

        if arg1 == KeyboardListener.KEY_ENTER:
            if self.visible:
                self.complete()      
            return

        if arg1 == KeyboardListener.KEY_ESCAPE:
            self.choices.clear()
            self.choicesPopup.hide()
            self.visible = False
            return

        text = self.getText()
        matches = []
        if len(text) > 0:
            matches = self.items.getCompletionItems(text)

        if len(matches) > 0:
            self.choices.clear()

            for i in range(len(matches)):
                self.choices.addItem(matches[i])
                
            if len(matches) == 1 and matches[0] == text:
                self.choicesPopup.hide()
            else:
                self.choices.setSelectedIndex(0)
                self.choices.setVisibleItemCount(len(matches) + 1)
                    
                if not self.popupAdded:
                    RootPanel().add(self.choicesPopup)
                    self.popupAdded = True

                self.choicesPopup.show()
                self.visible = True
                self.choicesPopup.setPopupPosition(self.getAbsoluteLeft(), self.getAbsoluteTop() + self.getOffsetHeight())
                self.choices.setWidth("%dpx" % self.getOffsetWidth())
        else:
            self.visible = False
            self.choicesPopup.hide()

    def onChange(self, arg0):
        self.complete()

    def onClick(self, arg0):
        self.complete()

    def complete(self):
        if self.choices.getItemCount() > 0:
            self.setText(self.choices.getItemText(self.choices.getSelectedIndex()))
            
        self.choices.clear()
        self.choicesPopup.hide()
        self.setFocus(True)
        self.visible = False
コード例 #53
0
ファイル: Popups.py プロジェクト: wkornewald/pyjs
 def doDetachChildren(self):
     PopupPanel.doDetachChildren(self)
     self.caption.onDetach()
コード例 #54
0
 def show(self):
     global tooltip_hide_timer
     
     # activate fast tooltips
     tooltip_hide_timer = Timer(self.hide_delay, self)
     PopupPanel.show(self)
コード例 #55
0
class AutoCompleteTextBox(TextBox):
    def __init__(self, **kwargs):
        self.choicesPopup = PopupPanel(True, False)
        self.choices = ListBox()
        self.items = SimpleAutoCompletionItems()
        self.popupAdded = False
        self.visible = False

        self.choices.addClickListener(self)
        self.choices.addChangeListener(self)

        self.choicesPopup.add(self.choices)
        self.choicesPopup.addStyleName("AutoCompleteChoices")

        self.choices.setStyleName("list")

        if not kwargs.has_key('StyleName'):
            kwargs['StyleName'] = "gwt-AutoCompleteTextBox"

        TextBox.__init__(self, **kwargs)
        self.addKeyboardListener(self)

    def setCompletionItems(self, items):
        if not hasattr(items, 'getCompletionItems'):
            items = SimpleAutoCompletionItems(items)

        self.items = items

    def getCompletionItems(self):
        return self.items

    def onKeyDown(self, arg0, arg1, arg2):
        pass

    def onKeyPress(self, arg0, arg1, arg2):
        pass

    def onKeyUp(self, arg0, arg1, arg2):
        if arg1 == KeyboardListener.KEY_DOWN:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex += 1
            if selectedIndex >= self.choices.getItemCount():
                selectedIndex = 0
            self.choices.setSelectedIndex(selectedIndex)
            return

        if arg1 == KeyboardListener.KEY_UP:
            selectedIndex = self.choices.getSelectedIndex()
            selectedIndex -= 1
            if selectedIndex < 0:
                selectedIndex = self.choices.getItemCount() - 1
            self.choices.setSelectedIndex(selectedIndex)
            return

        if arg1 == KeyboardListener.KEY_ENTER:
            if self.visible:
                self.complete()
            return

        if arg1 == KeyboardListener.KEY_ESCAPE:
            self.choices.clear()
            self.choicesPopup.hide()
            self.visible = False
            return

        text = self.getText()
        matches = []
        if len(text) > 0:
            matches = self.items.getCompletionItems(text)

        if len(matches) > 0:
            self.choices.clear()

            for i in range(len(matches)):
                self.choices.addItem(matches[i])

            if len(matches) == 1 and matches[0] == text:
                self.choicesPopup.hide()
            else:
                self.choices.setSelectedIndex(0)
                self.choices.setVisibleItemCount(len(matches) + 1)

                if not self.popupAdded:
                    RootPanel().add(self.choicesPopup)
                    self.popupAdded = True

                self.choicesPopup.show()
                self.visible = True
                self.choicesPopup.setPopupPosition(
                    self.getAbsoluteLeft(),
                    self.getAbsoluteTop() + self.getOffsetHeight())
                self.choices.setWidth("%dpx" % self.getOffsetWidth())
        else:
            self.visible = False
            self.choicesPopup.hide()

    def onChange(self, arg0):
        self.complete()

    def onClick(self, arg0):
        self.complete()

    def complete(self):
        if self.choices.getItemCount() > 0:
            self.setText(
                self.choices.getItemText(self.choices.getSelectedIndex()))

        self.choices.clear()
        self.choicesPopup.hide()
        self.setFocus(True)
        self.visible = False
 def __init__(self, item, **kwargs):
     self.item = item
     kwargs['Widget'] = item.getSubMenu()
     PopupPanel.__init__(self, True, False, **kwargs)
     item.getSubMenu().onShow()