本文整理汇总了Python中pyjamas.ui.Label.Label.addStyleName方法的典型用法代码示例。如果您正苦于以下问题:Python Label.addStyleName方法的具体用法?Python Label.addStyleName怎么用?Python Label.addStyleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Label.Label
的用法示例。
在下文中一共展示了Label.addStyleName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onRemoteError
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addStyleName [as 别名]
def onRemoteError(self, code, message, request_info):
""" Called when a returned response is invalid or Server Error
"""
code = str(code)
message = str(message)
if len(code) > 200: code = code[0:200] + "..."
if len(message) > 200: message = message[0:200] + "..."
err_msg = Label("Server Error or invalid response: ERROR " + str(code) + " - " + str(message))
err_msg.addStyleName("status")
Window.alert(err_msg.getText())
示例2: onModuleLoad
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label 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")
#.........这里部分代码省略.........
示例3: TemplatePanel
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import addStyleName [as 别名]
#.........这里部分代码省略.........
# Make the ids unique and store a pointer to each named element
for node in DOM.walkChildren(self.getElement()):
#console.log("Passing node with name %s", node.nodeName)
if node.nodeName == "META":
name = node.getAttribute("name")
content = node.getAttribute("content")
console.log("Found meta %o name %s content %s",
node, name, content)
self.metaTags[name] = content
self.metaTagList.append(node)
elif node.nodeName == "BODY":
self.body = node
elif node.nodeName == "TITLE":
self.title = DOM.getInnerText(node)
elif node.nodeName == "FORM":
self.forms.append(node)
nodeId = DOM.getAttribute(node, "id")
if nodeId:
self.elementsById[nodeId] = node
DOM.setAttribute(node, "id", self.id + ":" + node.id)
nodeHref = DOM.getAttribute(node, "href")
if nodeHref:
self.links.append(node)
self.loaded = True
if self.attached:
self.attachWidgets()
self.widgetsAttached = True
if self.allowEdit:
self.editor = None
self.editButton = Label("edit "+unescape(self.templateName))
self.editButton.addStyleName("link")
self.editButton.addStyleName("ContentPanelEditLink")
self.editButton.addClickListener(EventDelegate("onClick", self,
self.onEditContentClick))
ComplexPanel.insert(self, self.editButton, self.getElement(),
len(self.children))
self.notifyLoadListeners()
def onError(self, html, statusCode):
if statusCode == 404 and self.allowEdit:
self.editor = None
self.originalText = ""
DOM.setInnerHTML(self.getElement(), '')
self.editButton = Label("create "+unescape(self.templateName))
self.editButton.addStyleName("link")
self.editButton.addStyleName("ContentPanelEditLink")
self.editButton.addClickListener(EventDelegate("onClick", self,
self.onEditContentClick))
ComplexPanel.insert(self, self.editButton, self.getElement(),
len(self.children))
return
# Show the page we got in an iframe, which will hopefully show
# the error better than we can.
# DOM.setInnerHTML(self.getElement(), '<iframe src="'+self.getTemplatePath(self.templateName)+'"/>')
def onTimeout(self, text):
self.onError("Page loading timed out: "+text)
def getElementsById(self):
"""Return a dict mapping an id to an element with that id
inside the template; useful for post-processing."""