本文整理汇总了Python中pyjamas.ui.FlexTable.FlexTable.getRowFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python FlexTable.getRowFormatter方法的具体用法?Python FlexTable.getRowFormatter怎么用?Python FlexTable.getRowFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.FlexTable.FlexTable
的用法示例。
在下文中一共展示了FlexTable.getRowFormatter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FlexTableDemo
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowFormatter [as 别名]
class FlexTableDemo(SimplePanel):
def __init__(self):
SimplePanel.__init__(self)
self._table = FlexTable(BorderWidth=1, Width="100%")
cellFormatter = self._table.getFlexCellFormatter()
rowFormatter = self._table.getRowFormatter()
self._table.setHTML(0, 0, "<b>Mammals</b>")
self._table.setText(1, 0, "Cow")
self._table.setText(1, 1, "Rat")
self._table.setText(1, 2, "Dog")
cellFormatter.setColSpan(0, 0, 3)
cellFormatter.setHorizontalAlignment(0, 0, HasAlignment.ALIGN_CENTER)
self._table.setWidget(2, 0, Button("Hide", getattr(self, "hideRows")))
self._table.setText(2, 1, "1,1")
self._table.setText(2, 2, "2,1")
self._table.setText(3, 0, "1,2")
self._table.setText(3, 1, "2,2")
cellFormatter.setRowSpan(2, 0, 2)
cellFormatter.setVerticalAlignment(2, 0, HasAlignment.ALIGN_MIDDLE)
self._table.setWidget(4, 0, Button("Show", getattr(self, "showRows")))
cellFormatter.setColSpan(4, 0, 3)
rowFormatter.setVisible(4, False)
self.add(self._table)
def hideRows(self, sender):
rowFormatter = self._table.getRowFormatter()
rowFormatter.setVisible(2, False)
rowFormatter.setVisible(3, False)
rowFormatter.setVisible(4, True)
def showRows(self, sender):
rowFormatter = self._table.getRowFormatter()
rowFormatter.setVisible(2, True)
rowFormatter.setVisible(3, True)
rowFormatter.setVisible(4, False)
示例2: MailList
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowFormatter [as 别名]
class MailList(Composite):
VISIBLE_EMAIL_COUNT = 10
def __init__(self, mailObject):
Composite.__init__(self)
self.countLabel = HTML()
self.newerButton = HTML("<a href='javascript:;'>< newer</a>", True)
self.olderButton = HTML("<a href='javascript:;'>older ></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
#.........这里部分代码省略.........
示例3: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowFormatter [as 别名]
class StockWatcher:
def onModuleLoad(self):
'''
This is the main entry point method.
'''
# Setup JSON RPC
self.remote = DataService()
# Initialize member variables
self.mainPanel = VerticalPanel()
self.stocksFlexTable = FlexTable()
self.addPanel = HorizontalPanel()
self.newSymbolTextBox = TextBox()
self.lastUpdatedLabel = Label()
self.addStockButton = Button('Add', self.addStock)
self.stocks = []
self.stocksTableColumns = ['Symbol', 'Price', 'Change', 'Remove']
# Add styles to elements in the stock list table
self.stocksFlexTable.getRowFormatter().addStyleName(0, 'watchListHeader')
self.stocksFlexTable.addStyleName('watchList')
self.stocksFlexTable.getCellFormatter().addStyleName(0, 1, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(0, 2, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(0, 3, 'watchListRemoveColumn')
# Create table for stock data
for i in range(len(self.stocksTableColumns)):
self.stocksFlexTable.setText(0, i, self.stocksTableColumns[i])
# Assemble Add Stock panel
self.addPanel.add(self.newSymbolTextBox)
self.addPanel.add(self.addStockButton)
self.addPanel.addStyleName('addPanel')
# Assemble Main panel
self.mainPanel.add(self.stocksFlexTable)
self.mainPanel.add(self.addPanel)
self.mainPanel.add(self.lastUpdatedLabel)
# Associate the Main panel with the HTML host page
RootPanel().add(self.mainPanel)
# Move cursor focus to the input box
self.newSymbolTextBox.setFocus(True)
# Setup timer to refresh list automatically
refresh = self.refreshWatchlist
class MyTimer(Timer):
def run(self):
refresh()
refreshTimer = MyTimer()
refreshTimer.scheduleRepeating(5000)
# Listen for keyboard events in the input box
self_addStock = self.addStock
class StockTextBox_KeyboardHandler():
def onKeyPress(self, sender, keycode, modifiers):
if keycode == KEY_ENTER:
self_addStock()
def onKeyDown(self, sender, keycode, modifiers): return
def onKeyUp(self, sender, keycode, modifiers): return
self.newSymbolTextBox.addKeyboardListener(StockTextBox_KeyboardHandler())
# Load the stocks
self.remote.getStocks(self)
def addStock(self, sender, symbol=None):
'''
Add stock to FlexTable. Executed when the user clicks the addStockButton
or presses enter in the newSymbolTextBox
'''
if symbol is None:
# Get the symbol
symbol = self.newSymbolTextBox.getText().upper().trim()
self.newSymbolTextBox.setText('')
# Don't add the stock if it's already in the table
if symbol in self.stocks:
return
# Tell the server that we're adding this stock
self.remote.addStock(symbol, self)
self.newSymbolTextBox.setFocus(True)
# Stocks code must be between 1 and 10 chars that are numbers/letters/dots
p = re.compile('^[0-9A-Z\\.]{1,10}$')
if p.match(symbol) == None:
Window.alert('"%s" is not a valid symbol.' % symbol)
self.newSymbolTextBox.selectAll()
return
# Add the stock to the table
row = self.stocksFlexTable.getRowCount()
self.stocks.append(symbol)
self.stocksFlexTable.setText(row, 0, symbol)
self.stocksFlexTable.setWidget(row, 2, Label())
self.stocksFlexTable.getCellFormatter().addStyleName(row, 1, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(row, 2, 'watchListNumericColumn')
self.stocksFlexTable.getCellFormatter().addStyleName(row, 3, 'watchListRemoveColumn')
# Add a button to remove this stock from the table
#.........这里部分代码省略.........
示例4: onModuleLoad
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowFormatter [as 别名]
class MovieRatings:
def onModuleLoad(self):
# Setup JSON RPC
self.remote = DataService()
### Initialize member variables
self.mainPanel = HorizontalPanel()
self.rightPanel = VerticalPanel()
self.moviesPanel = VerticalPanel()
self.topRatedPanel = VerticalPanel()
self.categoriesPanel = VerticalPanel()
self.moviesFlexTable = FlexTable()
self.topRatedMoviesFlexTable = FlexTable()
self.topCategoryMoviesFlexTable = FlexTable()
self.lessThanFiveLabel = Label('There are less than 5 movies. Add more movies!')
self.moviesListLabel = Label('Movies List')
self.addPanel = VerticalPanel()
self.newMovieCategoryTextBox = TextBox()
self.newMovieNameTextBox = TextBox()
self.newMovieRatingListBox = ListBox(False)
self.addMovieButton = Button('Add', self.addMovieButton_Click)
self.movies = []
self.topRatedMovies = []
self.categories = {}
self.MAX_RATING = 10
### Add Movie Panel
# Add ratings to list box
for i in range(self.MAX_RATING + 1):
self.newMovieRatingListBox.addItem(str(i))
# Add label and textbox to horizontal panel
self.labelPanel = HorizontalPanel()
self.labelPanel.add(Label("Add a movie:"))
self.categoryPanel = HorizontalPanel()
self.categoryPanel.add(Label("Category: "))
self.categoryPanel.add(self.newMovieCategoryTextBox)
self.namePanel = HorizontalPanel()
self.namePanel.add(Label("Movie Name: "))
self.namePanel.add(self.newMovieNameTextBox)
self.ratingPanel = HorizontalPanel()
self.ratingPanel.add(Label("Movie Rating: "))
self.ratingPanel.add(self.newMovieRatingListBox)
self.labelPanel.addStyleName("addLabel")
self.labelPanel.setSpacing(5)
self.categoryPanel.addStyleName("addPanel")
self.categoryPanel.setSpacing(5)
self.namePanel.addStyleName("addPanel")
self.namePanel.setSpacing(5)
self.ratingPanel.addStyleName("addPanel")
self.ratingPanel.setSpacing(5)
self.newMovieCategoryTextBox.addStyleName("addPanel-input")
self.newMovieNameTextBox.addStyleName("addPanel-input")
self.newMovieRatingListBox.addStyleName("addPanel-input")
self.addPanel.add(self.labelPanel)
self.addPanel.add(self.categoryPanel)
self.addPanel.add(self.namePanel)
self.addPanel.add(self.ratingPanel)
self.addPanel.add(self.addMovieButton)
self.addPanel.addStyleName("addPanel")
self.addMovieButton.addStyleName('addButton')
self.addPanel.add(self.addMovieButton)
self.addPanel.addStyleName('addPanel')
### Movies table
self.moviesFlexTable.setText(0, 1, "Category")
self.moviesFlexTable.setText(0, 2, "Title")
self.moviesFlexTable.setText(0, 3, "Rating")
self.moviesFlexTable.addStyleName("movieList")
self.moviesFlexTable.getRowFormatter().addStyleName(0, "listHeader")
self.moviesFlexTable.setCellPadding(6)
self.moviesFlexTable.getCellFormatter().setStyleName(0, 1, "listHeaderColumn")
self.moviesFlexTable.getCellFormatter().setStyleName(0, 2, "listHeaderColumn")
self.moviesListLabel.addStyleName("listLabel")
self.moviesPanel.add(self.moviesListLabel)
self.moviesPanel.add(self.moviesFlexTable)
self.moviesPanel.setStyleName("moviesPanel")
### Top rated movies table
self.topRatedMoviesFlexTable.setText(0, 0, "Category")
self.topRatedMoviesFlexTable.setText(0, 1, "Title")
self.topRatedMoviesFlexTable.setText(0, 2, "Rating")
self.topRatedMoviesFlexTable.addStyleName("topMoviesList")
self.topRatedMoviesFlexTable.getRowFormatter().addStyleName(0, "listHeader")
self.topRatedMoviesFlexTable.setCellPadding(6)
self.topRatedMoviesFlexTable.getCellFormatter().setStyleName(0, 0, "listHeaderColumn")
self.topRatedMoviesFlexTable.getCellFormatter().setStyleName(0, 1, "listHeaderColumn")
self.topRatedLabel = Label("Top 5 Rated Movies")
#.........这里部分代码省略.........
示例5: DialogBox
# 需要导入模块: from pyjamas.ui.FlexTable import FlexTable [as 别名]
# 或者: from pyjamas.ui.FlexTable.FlexTable import getRowFormatter [as 别名]
class DialogBox(PopupPanel):
_props = [
("caption", "Caption", "HTML", None),
]
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()
rf = self.panel.getRowFormatter()
# Arguments section
self.modal = modal
self.caption = HTML()
self.caption.setStyleName("Caption")
self.caption.addMouseListener(self)
# Make the DialogBox a 3x3 table, like GWT does, with
# empty elements with specific style names. These can be
# used with CSS to, for example, create border around the
# dialog box.
self.generate_gwt15 = kwargs.pop('gwt15', False) and True
if not self.generate_gwt15:
cf.setHeight(1, 0, "100%")
cf.setWidth(1, 0, "100%")
cf.setAlignment(
1, 0,
HasHorizontalAlignment.ALIGN_CENTER,
HasVerticalAlignment.ALIGN_MIDDLE,
)
self.panel.setWidget(0, 0, self.caption)
else:
row_labels = ['Top', 'Middle', 'Bottom']
col_labels = ['Left', 'Center', 'Right']
for r in range(3):
rf.setStyleName(r, 'dialog%s' % row_labels[r])
for c in range(3):
cf.setStyleName(r, c, 'dialog%s%s' % (row_labels[r],
col_labels[c]))
sp = SimplePanel()
sp.setStyleName('dialog%s%sInner' % (row_labels[r],
col_labels[c]))
self.panel.setWidget(r, c, sp)
cf.setAlignment(
1, 1,
HasHorizontalAlignment.ALIGN_CENTER,
HasVerticalAlignment.ALIGN_MIDDLE,
)
self.dialog_content = SimplePanel()
self.dialog_content.setStyleName('dialogContent')
self.panel.getWidget(0, 1).add(self.caption)
self.panel.getWidget(1, 1).add(self.dialog_content)
# Finalize
kwargs['StyleName'] = kwargs.get('StyleName', "gwt-DialogBox")
PopupPanel.__init__(self, autoHide, modal, **kwargs)
PopupPanel.setWidget(self, self.panel)
self.centered = centered
def onWindowResized(self, width, height):
super(DialogBox, self).onWindowResized(width, height)
if self.centered:
self.centerBox()
def show(self):
super(DialogBox, self).show()
if self.centered:
self.centerBox()
@classmethod
def _getProps(self):
return PopupPanel._getProps() + self._props
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)
#.........这里部分代码省略.........