本文整理汇总了Python中pyjamas.ui.Button.Button.addStyleDependentName方法的典型用法代码示例。如果您正苦于以下问题:Python Button.addStyleDependentName方法的具体用法?Python Button.addStyleDependentName怎么用?Python Button.addStyleDependentName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Button.Button
的用法示例。
在下文中一共展示了Button.addStyleDependentName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addStock
# 需要导入模块: from pyjamas.ui.Button import Button [as 别名]
# 或者: from pyjamas.ui.Button.Button import addStyleDependentName [as 别名]
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
def _removeStockButton_Click(event):
if symbol not in self.stocks:
return
removedIndex = self.stocks.index(symbol)
self.remote.deleteStock(symbol, self)
self.stocks.remove(symbol)
self.stocksFlexTable.removeRow(removedIndex + 1)
removeStockButton = Button('x', _removeStockButton_Click)
removeStockButton.addStyleDependentName('remove')
self.stocksFlexTable.setWidget(row, 3, removeStockButton)
# Get the stock price
self.refreshWatchlist()