class NavBar(Composite):

    def __init__(self, owner):
        Composite.__init__(self)
        self.owner = owner
        self.bar = DockPanel()
        self.gotoFirst = Button("<<", self)
        self.gotoNext = Button(">", self)
        self.gotoPrev = Button("<", self)
        self.status = HTML()
        
        self.initWidget(self.bar)
        self.bar.setStyleName("navbar")
        self.status.setStyleName("status")
        
        buttons = HorizontalPanel()
        buttons.add(self.gotoFirst)
        buttons.add(self.gotoPrev)
        buttons.add(self.gotoNext)
        self.bar.add(buttons, DockPanel.EAST)
        self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT)
        self.bar.add(self.status, DockPanel.CENTER)
        self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT)
        self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE)
        self.bar.setCellWidth(self.status, "100%")
        
        self.gotoPrev.setEnabled(False)
        self.gotoFirst.setEnabled(False)
        
    def onClick(self, sender):
        if sender == self.gotoNext:
            self.owner.startRow += self.owner.getDataRowCount()
            self.owner.refresh()
        elif sender == self.gotoPrev:
            self.owner.startRow -= self.owner.getDataRowCount()
            if self.owner.startRow < 0:
                self.owner.startRow = 0
            self.owner.refresh()
        elif sender == self.gotoFirst:
            self.owner.startRow = 0
            self.owner.refresh()
Esempio n. 2
0
 def __init__(self):
     DialogBox.__init__(self)
     self.setText("Sample DialogBox with embedded Frame")
     
     iframe = Frame(Popups().baseURL() + "rembrandt/LaMarcheNocturne.html")
     closeButton = Button("Close", self)
     msg = HTML("<center>This is an example of a standard dialog box component.<br>  You can put pretty much anything you like into it,<br>such as the following IFRAME:</center>", True)
     
     dock = DockPanel()
     dock.setSpacing(4)
     
     dock.add(closeButton, DockPanel.SOUTH)
     dock.add(msg, DockPanel.NORTH)
     dock.add(iframe, DockPanel.CENTER)
     
     dock.setCellHorizontalAlignment(closeButton, HasAlignment.ALIGN_RIGHT)
     dock.setCellWidth(iframe, "100%")
     dock.setWidth("100%")
     iframe.setWidth("36em")
     iframe.setHeight("20em")
     self.setWidget(dock)
class DockPanelTest:

    def onModuleLoad(self):
        self.panel=DockPanel()
        
        east = Label("east")
        self.panel.add(east, DockPanel.EAST)
        self.panel.add(Label("west"), DockPanel.WEST)
        self.panel.add(Label("north"), DockPanel.NORTH)
        self.panel.add(Label("south"), DockPanel.SOUTH)
        self.south2 = Label("south2")
        self.panel.add(self.south2, DockPanel.SOUTH)
        self.center = Label("center")
        self.panel.add(self.center, DockPanel.CENTER)

        self.panel.setWidth("300px")
        self.panel.setHeight("300px")

        self.panel.setBorderWidth("1px")

        self.panel.setCellVerticalAlignment(east, HasAlignment.ALIGN_BOTTOM)
        self.panel.setCellHorizontalAlignment(east, HasAlignment.ALIGN_RIGHT)


        self.r = Button("remove", self)
        self.a = Button("add", self)

        RootPanel().add(self.panel)
        RootPanel().add(self.r)
        RootPanel().add(self.a)

    def onClick(self, sender):

        if sender == self.r:
            self.center.removeFromParent()
            self.south2.removeFromParent()
        if sender == self.a:
            self.panel.add(self.south2, DockPanel.SOUTH)
            self.panel.add(self.center, DockPanel.CENTER)