本文整理汇总了Python中pyjamas.ui.HorizontalPanel.HorizontalPanel.addStyleName方法的典型用法代码示例。如果您正苦于以下问题:Python HorizontalPanel.addStyleName方法的具体用法?Python HorizontalPanel.addStyleName怎么用?Python HorizontalPanel.addStyleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.HorizontalPanel.HorizontalPanel
的用法示例。
在下文中一共展示了HorizontalPanel.addStyleName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawFull
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import addStyleName [as 别名]
def drawFull(self, month, year):
# should be called only once when we draw the calendar for
# the first time
self.vp = VerticalPanel()
self.vp.setSpacing(2)
self.vp.addStyleName("calendarbox calendar-module calendar")
self.setWidget(self.vp)
self.setVisible(False)
#
mth = int(month)
yr = int(year)
tp = HorizontalPanel()
tp.addStyleName("calendar-top-panel")
tp.setSpacing(5)
h1 = Hyperlink('<<')
h1.addClickListener(getattr(self, 'onPreviousYear'))
h2 = Hyperlink('<')
h2.addClickListener(getattr(self, 'onPreviousMonth'))
h4 = Hyperlink('>')
h4.addClickListener(getattr(self, 'onNextMonth'))
h5 = Hyperlink('>>')
h5.addClickListener(getattr(self, 'onNextYear'))
tp.add(h1)
tp.add(h2)
# titlePanel can be changed, whenever we draw, so keep the reference
txt = "<b>"
txt += self.getMonthsOfYear()[mth-1] + " " + str(yr)
txt += "</b>"
self.titlePanel = SimplePanel()
self.titlePanel.setWidget(HTML(txt))
self.titlePanel.setStyleName("calendar-center")
tp.add(self.titlePanel)
tp.add(h4)
tp.add(h5)
tvp = VerticalPanel()
tvp.setSpacing(10)
tvp.add(tp)
self.vp.add(tvp)
# done with top panel
self.middlePanel = SimplePanel()
grid = self.drawGrid(mth, yr)
self.middlePanel.setWidget(grid)
self.vp.add(self.middlePanel)
self.defaultGrid = grid
self._gridShortcutsLinks()
self._gridCancelLink()
#
# add code to test another way of doing the layout
#
self.setVisible(True)
return
示例2: _gridShortcutsLinks
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import addStyleName [as 别名]
def _gridShortcutsLinks(self):
bh1 = Hyperlink(_("Current"))
bh1.addClickListener(getattr(self, 'onToday'))
b2 = Button(_("Choose"),self.onMonthSelected)
bh3 = Hyperlink(self.cancel)
bh3.addClickListener(getattr(self, 'onCancel'))
b = HorizontalPanel()
b.addStyleName("calendar-shortcuts")
b.add(bh1)
b.add(b2)
b.add(bh3)
self.vp.add(b)
示例3: _gridShortcutsLinks
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import addStyleName [as 别名]
def _gridShortcutsLinks(self):
#
# some links & handlers
#
bh1 = Hyperlink(self.yesterday)
bh1.addClickListener(getattr(self, 'onYesterday'))
bh2 = Hyperlink(self.today)
bh2.addClickListener(getattr(self, 'onToday'))
bh3 = Hyperlink(self.tomorrow)
bh3.addClickListener(getattr(self, 'onTomorrow'))
b = HorizontalPanel()
b.add(bh1)
b.add(bh2)
b.add(bh3)
b.addStyleName("calendar-shortcuts")
self.vp.add(b)
示例4: onModuleLoad
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import addStyleName [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
#.........这里部分代码省略.........
示例5: onModuleLoad
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import addStyleName [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")
#.........这里部分代码省略.........
示例6: RichTextEditor
# 需要导入模块: from pyjamas.ui.HorizontalPanel import HorizontalPanel [as 别名]
# 或者: from pyjamas.ui.HorizontalPanel.HorizontalPanel import addStyleName [as 别名]
class RichTextEditor(Composite):
def run(self):
try:
self.getSelection()
rng = Selection.getRange()
if (self.m_timerRange is None) or (not self.m_timerRange.equals(rng)):
self.onSelectionChange(rng)
self.m_timerRange = rng
except:
GWT.log("Error in timer selection", ex)
def __init__(self):
Composite.__init__(self)
self.m_isInText = False
self.m_lastText = ""
self.trigger = False
self.m_lastRange = None
# Timer for trying real time selection change stuff
self.m_timerRange = None
self.m_selTimer = Timer()
self.m_mainPanel = DockPanel()
self.m_toolbarPanel = HorizontalPanel()
self.m_toolbarPanel.setWidth("100%")
self.m_toolbarPanel.setHeight("25px")
self.m_toolbarPanel.setBorderWidth(1)
self.m_toolbarPanel.addStyleName("timeline-RichTextToolbar")
self.m_textW = RichTextArea()
self.m_textW.addClickListener(self)
self.m_textW.addKeyboardListener(self)
self.m_textW.addFocusListener(self)
self.m_textW.addMouseListener(self)
# According to gwt doc, these do need to be set because this is a frame
self.m_textW.setHeight("100%")
self.m_textW.setWidth("100%")
# Add buttons
self.m_formatter = self.getFormatter()
self.m_boldW = self.addToggleButton(self.m_toolbarPanel,
Icons.bold_icon, "Bold")
self.m_italicW = self.addToggleButton(self.m_toolbarPanel,
Icons.italics_icon, "Italic")
self.m_underlineW = self.addToggleButton(self.m_toolbarPanel,
Icons.underline_icon, "Underline")
self.m_subscriptW = self.addToggleButton(self.m_toolbarPanel,
Icons.subscript_icon, "Subscript")
self.m_superscriptW = self.addToggleButton(self.m_toolbarPanel,
Icons.superscript_icon, "Superscript")
self.m_strikethroughW = self.addToggleButton(self.m_toolbarPanel,
Icons.strikethrough_icon, "Strikethrough")
self.m_indentW = self.addPushButton(self.m_toolbarPanel,
Icons.indentmore_icon, "Indent Right")
self.m_outdentW = self.addPushButton(self.m_toolbarPanel,
Icons.indentless_icon, "Indent Left")
self.m_justifyLeftW = self.addPushButton(self.m_toolbarPanel,
Icons.justifyleft_icon, "Justify Left")
self.m_justifyCenterW = self.addPushButton(self.m_toolbarPanel,
Icons.justifycenter_icon, "Justify Center")
self.m_justifyRightW = self.addPushButton(self.m_toolbarPanel,
Icons.justifyright_icon, "Justify Right")
self.m_hrW = self.addPushButton(self.m_toolbarPanel,
Icons.horizontalrule_icon, "Horizontal Rule")
self.m_olW = self.addPushButton(self.m_toolbarPanel,
Icons.numberedlist_icon, "Numbered List")
self.m_ulW = self.addPushButton(self.m_toolbarPanel, Icons.list_icon, "List")
self.m_newLinkW = self.addPushButton(self.m_toolbarPanel,
Icons.link_icon, "Link Document")
self.m_removeFormatW = self.addPushButton(self.m_toolbarPanel,
Icons.noformat_icon, "No Format")
self.m_mainPanel.add(self.m_toolbarPanel, DockPanel.NORTH)
self.m_mainPanel.add(self.m_textW, DockPanel.CENTER)
self.initWidget(self.m_mainPanel)
self.sinkEvents(Event.ONCLICK)
def getFormatter(self):
return self.m_textW.getExtendedFormatter()
def getRichTextArea(self):
return self.m_textW
def addPushButton(self, panel, imagep, tip):
img = Image(imagep)
img.setWidth("20px")
img.setHeight("20px")
pb = PushButton(img)
self.addAnyButton(panel, pb, tip)
return pb
#.........这里部分代码省略.........