Example #1
0
    def __init__(self):
        inner = Grid(10, 5)
        outer = FlexTable()

        outer.setWidget(
            0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
        outer.getFlexCellFormatter().setColSpan(0, 0, 2)
        outer.getFlexCellFormatter().setHorizontalAlignment(
            0, 0, HasHorizontalAlignment.ALIGN_CENTER)

        outer.setHTML(
            1, 0, "Look to the right...<br>That's a nested table component ->")
        outer.setWidget(1, 1, inner)
        outer.getCellFormatter().setColSpan(1, 1, 2)

        for i in range(10):
            for j in range(5):
                inner.setText(i, j, "" + i + "," + j)

        inner.setWidth("100%")
        outer.setWidth("100%")

        inner.setBorderWidth(1)
        outer.setBorderWidth(1)

        self.setWidget(outer)
Example #2
0
class GridTest:
	def onModuleLoad(self):
		self.page=0
		self.min_page=1
		self.max_page=10
		
		self.add=Button("Next >", self)
		self.sub=Button("< Prev", self)
		
		self.g=Grid()
		self.g.resize(5, 5)
		self.g.setHTML(0, 0, "<b>Grid Test</b>")
		self.g.setBorderWidth(2)
		self.g.setCellPadding(4)
		self.g.setCellSpacing(1)
		
		self.updatePageDisplay()
		RootPanel().add(self.sub)
		RootPanel().add(self.add)
		RootPanel().add(self.g)

	def onClick(self, sender):

		print "click", sender, self.add, self.sub

		if sender==self.add:
			self.page+=1
		elif sender==self.sub:
			self.page-=1
		print sender, self.page
		self.updatePageDisplay()
		

	def updatePageDisplay(self):
		if self.page<self.min_page: self.page=self.min_page
		elif self.page>self.max_page: self.page=self.max_page
		total_pages=(self.max_page-self.min_page) + 1
		
		self.g.setHTML(0, 4, "<b>page " + str(self.page) + ' of ' + str(total_pages) + "</b>")
		
		if self.page>=self.max_page:
			self.add.setEnabled(False)
		else:
			self.add.setEnabled(True)
			
		if self.page<=self.min_page:
			self.sub.setEnabled(False)
		else:
			self.sub.setEnabled(True)

		for y in range(1, 5):
			for x in range(5):
				txt = str(self.page) + ' (' + str(y) + ',' + str(x) + ')'
				print txt
				self.g.setText(y, x, txt)
Example #3
0
class GridTest:
    def onModuleLoad(self):
        self.page = 0
        self.min_page = 1
        self.max_page = 10

        self.add = Button("Next >", self)
        self.sub = Button("< Prev", self)

        self.g = Grid()
        self.g.resize(5, 5)
        self.g.setHTML(0, 0, "<b>Grid Test</b>")
        self.g.setBorderWidth(2)
        self.g.setCellPadding(4)
        self.g.setCellSpacing(1)

        self.updatePageDisplay()
        RootPanel().add(self.sub)
        RootPanel().add(self.add)
        RootPanel().add(self.g)

    def onClick(self, sender):
        if sender == self.add:
            self.page += 1
        elif sender == self.sub:
            self.page -= 1
        self.updatePageDisplay()

    def updatePageDisplay(self):
        if self.page < self.min_page: self.page = self.min_page
        elif self.page > self.max_page: self.page = self.max_page
        total_pages = (self.max_page - self.min_page) + 1

        self.g.setHTML(0, 4,
                       "<b>page " + self.page + ' of ' + total_pages + "</b>")

        if self.page >= self.max_page:
            self.add.setEnabled(False)
        else:
            self.add.setEnabled(True)

        if self.page <= self.min_page:
            self.sub.setEnabled(False)
        else:
            self.sub.setEnabled(True)

        for y in range(1, 5):
            for x in range(5):
                self.g.setText(y, x, self.page + ' (' + y + ',' + x + ')')
Example #4
0
    def __init__(self):
        inner = Grid(10, 5)
        outer = FlexTable()

        outer.setWidget(0, 0, Image(self.baseURL() + "rembrandt/LaMarcheNocturne.jpg"))
        outer.getFlexCellFormatter().setColSpan(0, 0, 2)
        outer.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER)

        outer.setHTML(1, 0, "Look to the right...<br>That's a nested table component ->")
        outer.setWidget(1, 1, inner)
        outer.getCellFormatter().setColSpan(1, 1, 2)
        
        for i in range(10):
            for j in range(5):
                inner.setText(i, j, "" + i + "," + j)

        inner.setWidth("100%")
        outer.setWidth("100%")

        inner.setBorderWidth(1)
        outer.setBorderWidth(1)

        self.setWidget(outer)