Beispiel #1
0
    def addContact(self, contact):
        link = HTML("<a href='javascript:;'>" + contact.name + "</a>")
        self.panel.add(link)

        # Add a click listener that displays a ContactPopup when it is clicked.
        listener = ContactListener(contact, link)
        link.addClickListener(listener)
Beispiel #2
0
    def addContact(self, contact):
        link = HTML("<a href='javascript:;'>" + contact.name + "</a>")
        self.panel.add(link)

        # Add a click listener that displays a ContactPopup when it is clicked.
        listener = ContactListener(contact, link)
        link.addClickListener(listener)
Beispiel #3
0
    def __init__(self, grid_size):
        Grid.__init__(self)

        # populate the grid with some stuff
        #
        self.resize(grid_size, grid_size)

        self.setBorderWidth(2)
        self.setCellPadding(4)
        self.setCellSpacing(1)

        self.setStyleName("gameboard") # just doesn't work

        # Set up game board 
        #
        # Note that must iterate over indices, rather than Cell
        # instances, until the table positions are set up here
        #
        index = 0   # debug
        for i in range(grid_size):
            for j in range(grid_size):
                cell = HTML(SPACE)
#                cell.setVisible(False)  # causes to ignore click events
                cell.position = (i, j)  # might be handy at some point
                index+=1; cell.index = index    # debug
#                cell.setStyleName("cell_O")
                cell.addClickListener(getattr(self, "onCellClicked"))
                self.setWidget(i, j, cell)
Beispiel #4
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()
Beispiel #5
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()
Beispiel #6
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()
Beispiel #7
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()
Beispiel #8
0
class TopPanel(Composite):
    def __init__(self):

        Composite.__init__(self)

        self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>")
        self.aboutLink = HTML("<a href='javascript:;'>About</a>")

        outer = HorizontalPanel()
        inner = VerticalPanel()

        outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
        inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)

        links = HorizontalPanel()
        links.setSpacing(4)
        links.add(self.signOutLink)
        links.add(self.aboutLink)

        outer.add(inner)
        inner.add(HTML("<b>Welcome back, [email protected]</b>"))
        inner.add(links)

        self.signOutLink.addClickListener(self)
        self.aboutLink.addClickListener(self)

        self.initWidget(outer)
        inner.setStyleName("mail-TopPanel")
        links.setStyleName("mail-TopPanelLinks")

    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()
Beispiel #9
0
class TopPanel(Composite):

    def __init__(self):

        Composite.__init__(self)

        self.signOutLink = HTML("<a href='javascript:;'>Sign Out</a>")
        self.aboutLink = HTML("<a href='javascript:;'>About</a>")

        outer = HorizontalPanel()
        inner = VerticalPanel()

        outer.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
        inner.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)

        links = HorizontalPanel()
        links.setSpacing(4)
        links.add(self.signOutLink)
        links.add(self.aboutLink)

        outer.add(inner)
        inner.add(HTML("<b>Welcome back, [email protected]</b>"))
        inner.add(links)

        self.signOutLink.addClickListener(self)
        self.aboutLink.addClickListener(self)

        self.initWidget(outer)
        inner.setStyleName("mail-TopPanel")
        links.setStyleName("mail-TopPanelLinks")

    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()
Beispiel #10
0
class PrettyTab(Composite):
    def __init__(self, text, imageUrl):

        DecoratorPanel.__init__(self, DecoratorPanel.DECORATE_ALL)
        p = HorizontalPanel()
        p.setSpacing(3)
        self.img = Image(imageUrl)
        self.txt = HTML(text)
        p.add(self.img)
        p.add(self.txt)

        self.add(p)

    def addClickListener(self, listener):

        self.img.addClickListener(listener)
        self.txt.addClickListener(listener)
Beispiel #11
0
class PrettyTab(Composite):

    def __init__(self, text, imageUrl):

        DecoratorPanel.__init__(self, DecoratorPanel.DECORATE_ALL)
        p = HorizontalPanel()
        p.setSpacing(3)
        self.img = Image(imageUrl)
        self.txt = HTML(text)
        p.add(self.img)
        p.add(self.txt)

        self.add(p)

    def addClickListener(self, listener):

        self.img.addClickListener(listener)
        self.txt.addClickListener(listener)
	def addRow(self,Entry,r, row):
		#Window.alert(r['thumbimg'])
		title = HTML("<span title=\""+r['title']+"\"; style=\"color:black;\">"+r['title']+"</span>")
		title.setStyleName("pointer")
		author = HTML("<span title=\""+r['author']+"\" style=\"color:grey\">"+"Author(s): "+r['author']+"</span>")
		#asin = r['asin']
		img = r['thumbnail']
		nsellers = HTML("<span style=\"color:green\">"+"Sellers: "+str(r['numsellers'])+"</span>")
		isbn = HTML("<span style=\"color:#483D8B\">"+"ISBN: "+str(r['isbn'])+"</span>")
		onSell = r['onSell']
		onWish = r['onWish']
		if(img == "N/A"):
			img = "#"
		imghtml = HTML("<img src='"+img+"' alt='No Thumbnail'/>")
		imghtml.setStyleName("pointer")
		
		title.setWidth(str(self.table_width)+"px")
		author.setWidth(str(self.table_width)+"px")
		info_wrapper = VerticalPanel()
		info_wrapper.add(title)
		info_wrapper.add(isbn)
		info_wrapper.add(author)
		info_wrapper.add(nsellers)
		
		
		Entry.setWidget(row,0,imghtml)
		Entry.setWidget(row, 1, info_wrapper)
		Entry.getRowFormatter().addStyleName(row,"comments")
		#Entry.setWidget(row,1,title)
		#Entry.setText(row,2,nsellers)
		
		def _get_book_data_Click(event):
			self.remote.search_check(self,r)
		title.addClickListener(_get_book_data_Click)
		title.addStyleName("pointer")
		imghtml.addClickListener(_get_book_data_Click)
		imghtml.addStyleName("pointer")
		'''
Beispiel #13
0
    def __init__(self, worksheet, id):
        SimplePanel.__init__(self)
        MouseHandler.__init__(self)
        self._id = id
        self._worksheet = worksheet
        insert_new_cell = HTML("", StyleName="insert_new_cell")
        insert_new_cell.addClickListener(InsertListener(worksheet, self._id))
        input_prompt = HTML("In [%d]:" % self._id, Element=DOM.createSpan(),
                StyleName="input_prompt")
        cell_input = InputArea(worksheet, self._id, StyleName='cell_input')
        evaluate_button = HTML("evaluate", Element=DOM.createAnchor(),
                StyleName="eval_button", Visible=False)
        evaluate_button.getElement().setAttribute("href", "")
        evaluate_button.addClickListener(EvaluateListener(self))
        evaluate_button.addMouseListener(self)
        output_delimiter = HTML("", StyleName="output_delimiter")
        output_prompt = HTML("Out[%d]:" % self._id, Element=DOM.createSpan(),
                StyleName="output_prompt")
        cell_output = HTML("", Element=DOM.createSpan(),
                StyleName="cell_output")
        output_prompt.setVisible(False)
        p = FlowPanel(StyleName="cell")
        p.add(insert_new_cell)
        p.add(input_prompt)
        p.add(cell_input)
        p.add(evaluate_button)
        p.add(output_delimiter)
        p.add(output_prompt)
        p.add(cell_output)
        self.add(p)

        self._cell_input = cell_input
        self._cell_output = cell_output
        self._output_prompt = output_prompt
        self._evaluate_button = evaluate_button

        self._mouse_in = False
Beispiel #14
0
class MailList(Composite):

    VISIBLE_EMAIL_COUNT = 10

    def __init__(self, mailObject):
        Composite.__init__(self)

        self.countLabel = HTML()
        self.newerButton = HTML("<a href='javascript:;'>&lt; newer</a>", True)
        self.olderButton = HTML("<a href='javascript:;'>older &gt;</a>", True)
        self.startIndex = 0
        self.selectedRow = -1
        self.table = FlexTable()
        self.navBar = HorizontalPanel()
        self.mailObject = mailObject

        # Setup the table.
        self.table.setCellSpacing(0)
        self.table.setCellPadding(2)
        self.table.setWidth("100%")

        # Hook up events.
        self.table.addTableListener(self)
        self.newerButton.addClickListener(self)
        self.olderButton.addClickListener(self)

        # Create the 'navigation' bar at the upper-right.
        innerNavBar = HorizontalPanel()
        innerNavBar.setSpacing(8)
        innerNavBar.add(self.newerButton)
        innerNavBar.add(self.countLabel)
        innerNavBar.add(self.olderButton)

        self.navBar.setStyleName("mail-ListNavBar")
        self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
        self.navBar.add(innerNavBar)
        self.navBar.setWidth("100%")

        self.initWidget(self.table)
        self.setStyleName("mail-List")

        self.initTable()
        self.update()

    def onCellDoubleClicked(self, sender, row, cell):
    	pass

    def onCellClicked(self, sender, row, cell):
        # Select the row that was clicked (-1 to account for header row).
        if (row > 0):
            self.selectRow(row - 1)

    def onClick(self, sender):
        if (sender == self.olderButton):
            # Move forward a page.
            self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT
            if (self.startIndex >= MailItems().getMailItemCount()):
                self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
            else:
                self.styleRow(self.selectedRow, False)
                self.selectedRow = -1
                self.update()

        elif (sender == self.newerButton):
            # Move back a page.
            self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
            if (self.startIndex < 0):
                self.startIndex = 0
            else:
                self.styleRow(self.selectedRow, False)
                self.selectedRow = -1
                self.update()

    def initTable(self):
        # Create the header row.
        self.table.setText(0, 0, "sender")
        self.table.setText(0, 1, "email")
        self.table.setText(0, 2, "subject")
        self.table.setWidget(0, 3, self.navBar)
        self.table.getRowFormatter().setStyleName(0, "mail-ListHeader")

        # Initialize the rest of the rows.
        i = 0
        while i < MailList.VISIBLE_EMAIL_COUNT:
            self.table.setText(i + 1, 0, "")
            self.table.setText(i + 1, 1, "")
            self.table.setText(i + 1, 2, "")
            self.table.getCellFormatter().setWordWrap(i + 1, 0, False)
            self.table.getCellFormatter().setWordWrap(i + 1, 1, False)
            self.table.getCellFormatter().setWordWrap(i + 1, 2, False)
            self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2)
            i = i + 1


    def selectRow(self, row):
        # When a row (other than the first one, which is used as a header) is
        # selected, display its associated MailItem.
        item = MailItems().getMailItem(self.startIndex + row)
        if item is None:
            return

        self.styleRow(self.selectedRow, False)
        self.styleRow(row, True)

        item.read = True
        self.selectedRow = row
        self.mailObject.get().displayItem(item)


    def styleRow(self, row, selected):
        if (row != -1):
            if (selected):
                self.table.getRowFormatter().addStyleName(row + 1, "mail-SelectedRow")
            else:
                self.table.getRowFormatter().removeStyleName(row + 1, "mail-SelectedRow")

    def update(self):
        # Update the older/newer buttons & label.
        count = MailItems().getMailItemCount()
        max = self.startIndex + MailList.VISIBLE_EMAIL_COUNT
        if (max > count):
            max = count

        self.newerButton.setVisible(self.startIndex != 0)
        self.olderButton.setVisible(self.startIndex + MailList.VISIBLE_EMAIL_COUNT < count)
        startIndexPlusOne = self.startIndex + 1
        self.countLabel.setText("%d - %d of %d" % (startIndexPlusOne, max, count))

        # Show the selected emails.
        i = 0
        while (i < MailList.VISIBLE_EMAIL_COUNT):
            # Don't read past the end.
            if (self.startIndex + i >= MailItems().getMailItemCount()):
                break

            item = MailItems().getMailItem(self.startIndex + i)

            # Add a row to the table, then set each of its columns to the
            # email's sender and subject values.

            self.table.setText(i + 1, 0, item.sender)
            self.table.setText(i + 1, 1, item.email)
            self.table.setText(i + 1, 2, item.subject)

            i = i + 1

        # Clear any remaining slots.
        while (i < MailList.VISIBLE_EMAIL_COUNT):
            self.table.setHTML(i + 1, 0, "&nbsp;")
            self.table.setHTML(i + 1, 1, "&nbsp;")
            self.table.setHTML(i + 1, 2, "&nbsp;")
            i = i + 1

        # Select the first row if none is selected.
        if (self.selectedRow == -1):
            self.selectRow(0)
Beispiel #15
0
class MailList(Composite):

    VISIBLE_EMAIL_COUNT = 10

    def __init__(self, mailObject):
        Composite.__init__(self)

        self.countLabel = HTML()
        self.newerButton = HTML("<a href='javascript:;'>&lt; newer</a>", True)
        self.olderButton = HTML("<a href='javascript:;'>older &gt;</a>", True)
        self.startIndex = 0
        self.selectedRow = -1
        self.table = FlexTable()
        self.navBar = HorizontalPanel()
        self.mailObject = mailObject

        # Setup the table.
        self.table.setCellSpacing(0)
        self.table.setCellPadding(2)
        self.table.setWidth("100%")

        # Hook up events.
        self.table.addTableListener(self)
        self.newerButton.addClickListener(self)
        self.olderButton.addClickListener(self)

        # Create the 'navigation' bar at the upper-right.
        innerNavBar = HorizontalPanel()
        innerNavBar.setSpacing(8)
        innerNavBar.add(self.newerButton)
        innerNavBar.add(self.countLabel)
        innerNavBar.add(self.olderButton)

        self.navBar.setStyleName("mail-ListNavBar")
        self.navBar.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT)
        self.navBar.add(innerNavBar)
        self.navBar.setWidth("100%")

        self.initWidget(self.table)
        self.setStyleName("mail-List")

        self.initTable()
        self.update()

    def onCellClicked(self, sender, row, cell):
        # Select the row that was clicked (-1 to account for header row).
        if (row > 0):
            self.selectRow(row - 1)

    def onClick(self, sender):
        if (sender == self.olderButton):
            # Move forward a page.
            self.startIndex = self.startIndex + MailList.VISIBLE_EMAIL_COUNT
            if (self.startIndex >= MailItems().getMailItemCount()):
                self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
            else:
                self.styleRow(self.selectedRow, False)
                self.selectedRow = -1
                self.update()

        elif (sender == self.newerButton):
            # Move back a page.
            self.startIndex = self.startIndex - MailList.VISIBLE_EMAIL_COUNT
            if (self.startIndex < 0):
                self.startIndex = 0
            else:
                self.styleRow(self.selectedRow, False)
                self.selectedRow = -1
                self.update()

    def initTable(self):
        # Create the header row.
        self.table.setText(0, 0, "sender")
        self.table.setText(0, 1, "email")
        self.table.setText(0, 2, "subject")
        self.table.setWidget(0, 3, self.navBar)
        self.table.getRowFormatter().setStyleName(0, "mail-ListHeader")

        # Initialize the rest of the rows.
        i = 0
        while i < MailList.VISIBLE_EMAIL_COUNT:
            self.table.setText(i + 1, 0, "")
            self.table.setText(i + 1, 1, "")
            self.table.setText(i + 1, 2, "")
            self.table.getCellFormatter().setWordWrap(i + 1, 0, False)
            self.table.getCellFormatter().setWordWrap(i + 1, 1, False)
            self.table.getCellFormatter().setWordWrap(i + 1, 2, False)
            self.table.getFlexCellFormatter().setColSpan(i + 1, 2, 2)
            i = i + 1

    def selectRow(self, row):
        # When a row (other than the first one, which is used as a header) is
        # selected, display its associated MailItem.
        item = MailItems().getMailItem(self.startIndex + row)
        if item is None:
            return

        self.styleRow(self.selectedRow, False)
        self.styleRow(row, True)

        item.read = True
        self.selectedRow = row
        self.mailObject.get().displayItem(item)

    def styleRow(self, row, selected):
        if (row != -1):
            if (selected):
                self.table.getRowFormatter().addStyleName(
                    row + 1, "mail-SelectedRow")
            else:
                self.table.getRowFormatter().removeStyleName(
                    row + 1, "mail-SelectedRow")

    def update(self):
        # Update the older/newer buttons & label.
        count = MailItems().getMailItemCount()
        max = self.startIndex + MailList.VISIBLE_EMAIL_COUNT
        if (max > count):
            max = count

        self.newerButton.setVisible(self.startIndex != 0)
        self.olderButton.setVisible(
            self.startIndex + MailList.VISIBLE_EMAIL_COUNT < count)
        startIndexPlusOne = self.startIndex + 1
        self.countLabel.setText("%d - %d of %d" %
                                (startIndexPlusOne, max, count))

        # Show the selected emails.
        i = 0
        while (i < MailList.VISIBLE_EMAIL_COUNT):
            # Don't read past the end.
            if (self.startIndex + i >= MailItems().getMailItemCount()):
                break

            item = MailItems().getMailItem(self.startIndex + i)

            # Add a row to the table, then set each of its columns to the
            # email's sender and subject values.

            self.table.setText(i + 1, 0, item.sender)
            self.table.setText(i + 1, 1, item.email)
            self.table.setText(i + 1, 2, item.subject)

            i = i + 1

        # Clear any remaining slots.
        while (i < MailList.VISIBLE_EMAIL_COUNT):
            self.table.setHTML(i + 1, 0, "&nbsp;")
            self.table.setHTML(i + 1, 1, "&nbsp;")
            self.table.setHTML(i + 1, 2, "&nbsp;")
            i = i + 1

        # Select the first row if none is selected.
        if (self.selectedRow == -1):
            self.selectRow(0)