def __init__(self): Logger.instances.append(self) Grid.__init__(self) self.targets = [] self.targets.append("app") # self.targets.append("ui") self.resize(len(self.targets) + 1, 2) self.setBorderWidth(1) self.counter = 0 self.setHTML(0, 0, "<b>Log</b>") self.setText(1, 0, "app") for i in range(len(self.targets)): target = self.targets[i] self.setText(i + 1, 0, target)
def __init__(self, ): self.__init__._super() self.outer.addStyleName(u"gwittit-Stream_publishAttachment") self.publishButton.addClickHandler(self.PublishHandler()) self.images[0] = Image(java.str(self.baseUrl) + u"/imgsamples/please.jpg") self.images[1] = Image(java.str(self.baseUrl) + u"/imgsamples/with.jpg") self.images[2] = Image(java.str(self.baseUrl) + u"/imgsamples/ahard.jpg") self.images[3] = Image(java.str(self.baseUrl) + u"/imgsamples/forsale.jpg") self.images[4] = Image(java.str(self.baseUrl) + u"/imgsamples/help.jpg") self.images[5] = Image(java.str(self.baseUrl) + u"/imgsamples/rubber.jpg") self.images[6] = Image(java.str(self.baseUrl) + u"/imgsamples/revolver.jpg") self.images[7] = Image(java.str(self.baseUrl) + u"/imgsamples/sgt_pepper.jpg") self.images[8] = Image(java.str(self.baseUrl) + u"/imgsamples/white.jpg") self.images[9] = Image(java.str(self.baseUrl) + u"/imgsamples/submarine.jpg") self.images[10] = Image(java.str(self.baseUrl) + u"/imgsamples/abbey.jpg") self.images[11] = Image(java.str(self.baseUrl) + u"/imgsamples/letitbe.jpg") grid = Grid(2, 6) grid.addStyleName(u"grid") numRows = grid.getRowCount() numColumns = grid.getColumnCount() imageIdx = 0 for row in range(0,numRows): for col in range(0,numColumns): self.images[imageIdx].setWidth(u"60px") self.images[imageIdx].addClickHandler(self.SelectFavoriteHandler(imageIdx)) grid.setWidget(row, col, self.images[imageIdx]) imageIdx += 1 self.outer.add(self.header) self.outer.add(grid) self.outer.add(self.createFavoriteWidget()) self.initWidget(self.outer)
class DynaTableWidget(Composite): def __init__(self, provider, columns, columnStyles, rowCount): Composite.__init__(self) self.acceptor = RowDataAcceptorImpl(self) self.outer = DockPanel() self.startRow = 0 self.grid = Grid() self.navbar = NavBar(self) self.provider = provider self.initWidget(self.outer) self.grid.setStyleName("table") self.outer.add(self.navbar, DockPanel.NORTH) self.outer.add(self.grid, DockPanel.CENTER) self.initTable(columns, columnStyles, rowCount) self.setStyleName("DynaTable-DynaTableWidget") def initTable(self, columns, columnStyles, rowCount): self.grid.resize(rowCount + 1, len(columns)) for i in range(len(columns)): self.grid.setText(0, i, columns[i]) if columnStyles: self.grid.cellFormatter.setStyleName(0, i, columnStyles[i] + "header") def setStatusText(self, text): self.navbar.status.setText(text) def clearStatusText(self, text): self.navbar.status.setHTML(" ") def refresh(self): self.navbar.gotoFirst.setEnabled(False) self.navbar.gotoPrev.setEnabled(False) self.navbar.gotoNext.setEnabled(False) self.setStatusText("Please wait...") self.provider.updateRowData(self.startRow, self.grid.getRowCount() - 1, self.acceptor) def setRowCount(self, rows): self.grid.resizeRows(rows) def getDataRowCount(self): return self.grid.getRowCount() - 1
def multicolumn(self, list, cols=4): """Format a list of items into a multi-column list.""" result = Grid() result.setWidth("100%") rows = (len(list)+cols-1)/cols result.resize(rows, cols) for col in range(cols): for i in range(rows*col, rows*col+rows): if i < len(list): result.setHTML(0, i, list[i] + "<br />\n") return result
def __init__(self, target="", message=""): if message: return Logger().write(target, message) # make sure there is only one instance of this class if _logger: return _logger self.setSingleton() Grid.__init__(self) self.targets = [] self.targets.append("app") # self.targets.append("ui") self.resize(len(self.targets) + 1, 2) self.setBorderWidth(1) self.counter = 0 self.setHTML(0, 0, "<b>Log</b>") self.setText(1, 0, "app") for i in range(len(self.targets)): target = self.targets[i] self.setText(i + 1, 0, target)
def multicolumn(self, items, cols=4): """Format a list of items into a multi-column list.""" result = Grid() result.setWidth("100%") rows = (len(items)+cols-1)/cols result.resize(rows, cols) i = 0 for col in range(cols): for row in range(rows): if items and i < len(items): result.setHTML(row, col, items[i] + "<br />\n") i += 1 return result
def __init__(self, provider, columns, columnStyles, rowCount): Composite.__init__(self) self.acceptor = RowDataAcceptorImpl(self) self.outer = DockPanel() self.startRow = 0 self.grid = Grid() self.navbar = NavBar(self) self.provider = provider self.initWidget(self.outer) self.grid.setStyleName("table") self.outer.add(self.navbar, DockPanel.NORTH) self.outer.add(self.grid, DockPanel.CENTER) self.initTable(columns, columnStyles, rowCount) self.setStyleName("DynaTable-DynaTableWidget")
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 __init__(self): Sink.__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, "%d" % i + ",%d" % j) inner.setWidth("100%") outer.setWidth("100%") inner.setBorderWidth(1) outer.setBorderWidth(1) self.initWidget(outer)
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, event): if sender==self.add: self.page+=1 elif sender==self.sub: self.page-=1 print "onClick", 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): self.g.setText(y, x, str(self.page) + ' (' + str(y) + ',' + str(x) + ')')