本文整理汇总了Python中pyjamas.ui.Label.Label类的典型用法代码示例。如果您正苦于以下问题:Python Label类的具体用法?Python Label怎么用?Python Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HorizontalToolbar
class HorizontalToolbar(SimplePanel):
def __init__(self, onRequestMore=None, onCollapseAll=None, onExpandAll=None, onSort=None):
super(HorizontalToolbar, self).__init__(StyleName=Styles.TOOLBAR_HORIZONTAL)
self.content = HorizontalPanel()
self.requestMoreButton = Button('More', onRequestMore, StyleName=Styles.TOOLBAR_BUTTON)
self.content.add(self.requestMoreButton)
self.itemsShowingLabel = Label(StyleName=Styles.TOOLBAR_TEXT)
self.content.add(self.itemsShowingLabel)
self.setNumberOfItemsShowingText(0, 0)
self.collapseAllButton = Button('Collapse All', onCollapseAll, StyleName=Styles.TOOLBAR_BUTTON)
self.content.add(self.collapseAllButton)
self.expandAllButton = Button('Expand All', onExpandAll, StyleName=Styles.TOOLBAR_BUTTON)
self.content.add(self.expandAllButton)
if onSort:
self.content.add(SortPanel(onSort))
self.setWidget(self.content)
return
def setNumberOfItemsShowingText(self, number, total):
self.itemsShowingLabel.setText('Showing %s of %s total items.' % (number, total))
return
示例2: GettextExample
class GettextExample(object):
def __init__(self):
self.b = Button(_("Click me"), self.greet, StyleName='teststyle')
self.h = HTML(_("<b>Hello World</b> (html)"), StyleName='teststyle')
self.l = Label(_("Hello World (label)"), StyleName='teststyle')
self.base = HTML(_("Hello from %s") % pygwt.getModuleBaseURL(),
StyleName='teststyle')
RootPanel().add(self.b)
RootPanel().add(self.h)
RootPanel().add(self.l)
RootPanel().add(self.base)
def change_texts(self, text):
self.b.setText(_("Click me"))
self.h.setHTML(_("<b>Hello World</b> (html)"))
self.l.setText(_("Hello World (label)"))
text = [_("Hello from %s") % pygwt.getModuleBaseURL()]
for i in range(4):
text.append(ngettext('%(num)d single', '%(num)d plural', i) % dict(num=i))
text = '<br />'.join(text)
self.base.setHTML(text)
def greet(self, fred):
fred.setText(_("No, really click me!"))
Window.alert(_("Hello, there!"))
i18n.load(lang=lang[0], onCompletion=self.change_texts)
lang.append(lang.pop(0))
示例3: __init__
def __init__(self, n, limit):
Label.__init__(self,
"Sorry, your query had too many (%s) results! The current "
"supported limit is %s." % (
utils.splitthousands(n),
utils.splitthousands(limit)),
StyleName='userlist-error-title')
示例4: make_panel
def make_panel(self):
message = Label(
'The configuration has been changed.\n'
'You must apply the changes in order for them to take effect.')
DOM.setStyleAttribute(message.getElement(), "whiteSpace", 'pre')
msgbox = Grid(1, 2, StyleName='changes')
msgbox.setWidget(0, 0, Image('icons/exclam.png'))
msgbox.setWidget(0, 1, message)
msgbox.getCellFormatter().setStyleName(0, 0, 'changes-image')
msgbox.getCellFormatter().setStyleName(0, 1, 'changes-text')
button = Button('apply changes')
button.addClickListener(self.apply_clicked)
self.changes = VerticalPanel()
self.changes.setHorizontalAlignment('right')
self.changes.setVisible(False)
self.changes.add(msgbox)
self.changes.add(button)
panel = VerticalPanel()
panel.setSpacing(10)
panel.add(self.table)
panel.add(self.status)
panel.add(self.changes)
return panel
示例5: _add_statusbar
def _add_statusbar ( self ):
""" Adds a statusbar to the dialog.
"""
if self.ui.view.statusbar is not None:
control = HorizontalPanel()
# control.setSizeGripEnabled(self.ui.view.resizable)
listeners = []
for item in self.ui.view.statusbar:
# Create the status widget with initial text
name = item.name
item_control = Label()
item_control.setText(self.ui.get_extended_value(name))
# Add the widget to the control with correct size
# width = abs(item.width)
# stretch = 0
# if width <= 1.0:
# stretch = int(100 * width)
# else:
# item_control.setMinimumWidth(width)
control.add(item_control)
# Set up event listener for updating the status text
col = name.find('.')
obj = 'object'
if col >= 0:
obj = name[:col]
name = name[col+1:]
obj = self.ui.context[obj]
set_text = self._set_status_text(item_control)
obj.on_trait_change(set_text, name, dispatch='ui')
listeners.append((obj, set_text, name))
self.master.add(control)
self.ui._statusbar = listeners
示例6: __init__
def __init__(self, ctype, data):
Label.__init__(self)
AddablePanel.__init__(self)
self.setStyleName('content_text')
self.setText("'%s' content:" % ctype)
self.content = HTML(data, StyleName='content')
self.append(self.content)
示例7: WritePanel
class WritePanel(AbsolutePanel):
def __init__(self, parent):
AbsolutePanel.__init__(self)
self.post_header = Label("Write a Post", StyleName="header_label")
self.post_write_title_label = Label("Title:")
self.post_title = TextBox()
self.post_content = TextArea()
self.post_button = Button("Post")
self.cancel_button = Button("Cancel")
self.error_message_label = Label("", StyleName="error_message_label")
contents = VerticalPanel(StyleName="Contents", Spacing=4)
contents.add(self.post_header)
contents.add(self.post_write_title_label)
contents.add(self.post_title)
contents.add(self.post_content)
contents.add(self.post_button)
contents.add(self.cancel_button)
contents.add(self.error_message_label)
self.dialog = DialogBox(glass=True)
self.dialog.setHTML('<b>Blog Post Form</b>')
self.dialog.setWidget(contents)
left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft()
top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop()
self.dialog.setPopupPosition(left, top)
self.dialog.hide()
def clear_write_panel(self):
self.post_title.setText("")
self.post_content.setText("")
self.error_message_label.setText("")
示例8: __init__
def __init__(self, text=None, forid=None, wordWrap=True, **kwargs):
if not kwargs.has_key('Element'):
element = DOM.createLabel()
if forid:
element.setAttribute("for", forid)
kwargs['Element'] = element
Label.__init__(self, text, wordWrap, **kwargs)
示例9: QueueSize
class QueueSize(HorizontalPanel):
def __init__(self):
HorizontalPanel.__init__(self, Spacing=4)
self.add(Label('Queue size:', StyleName='section'))
self.underway = Label()
self.add(self.underway)
self.queued = Label()
self.add(self.queued)
self.button = Button('Refresh', self, StyleName='refresh')
self.add(self.button)
self.err = Label()
self.add(self.err)
self.update()
def update(self):
remote = server.AdminService()
id = remote.queueSize(self)
if id < 0:
self.err.setText('oops: could not call getQueueSize')
def onRemoteResponse(self, result, request_info):
self.button.setEnabled(True)
underway, queued = result
self.underway.setText('Underway: %d' % underway)
self.queued.setText('Queued: %d' % queued)
def onRemoteError(self, code, message, request_info):
self.button.setEnabled(True)
self.err.setText('Could not getQueueWidth: ' + message)
def onClick(self, sender):
self.err.setText('')
self.button.setEnabled(False)
self.update()
示例10: __init__
def __init__(self, milestone_names, milestone_dates):
# We need to use old form of inheritance because of pyjamas
SimplePanel.__init__(self)
self.milestone_dates = milestone_dates
self.hpanel = HorizontalPanel()
self.hpanel.setVerticalAlignment(HasAlignment.ALIGN_TOP)
self.name = ListBox(Height='34px', Width='208px')
self.name.setStyleName('form-control input-lg')
self.name.addChangeListener(getattr(self, 'on_milestone_changed'))
for m in milestone_names:
self.name.addItem(m)
if len(self.milestone_dates) > 0:
self.planned_completion = Label(self.milestone_dates[0])
else:
self.planned_completion = Label('Undefined')
self.planned_completion.setStyleName('form-control text-normal')
self.expected_completion = Report_Date_Field(cal_ID='end')
self.expected_completion.getTextBox().setStyleName('form-control')
self.expected_completion.setRegex(DATE_MATCHER)
self.expected_completion.appendValidListener(self._display_ok)
self.expected_completion.appendInvalidListener(self._display_error)
self.expected_completion.validate(None)
self.hpanel.add(self.name)
self.hpanel.add(Label(Width='10px'))
self.hpanel.add(self.planned_completion)
self.hpanel.add(Label(Width='10px'))
self.hpanel.add(self.expected_completion)
示例11: __init__
def __init__(self, row, column=0):
super(Game, self).__init__(StyleName='game')
self.sinkEvents(Event.ONCONTEXTMENU) # to disable right click
self.row = row
self.column = column or row
self.level = 1
self.toppers = [[], [], []] # storage for top scorers for 3 levels.
self.remote = DataService()
self.remote_handler = RemoteHandler(self)
self.remote.get_scores(self.remote_handler)
# contents of Game
menubar = MineMenuBar(self)
score_board = HorizontalPanel(StyleName='score-board')
self.grid_panel = SimplePanel(StyleName='grid-panel')
self.add(menubar)
self.add(score_board)
self.add(self.grid_panel)
# contents of score_board
self.counter = Label('000', StyleName='digit counter')
self.face = Smiley(self)
self.timer = Label('000', StyleName='digit timer')
for one in (self.counter, self.face, self.timer):
score_board.add(one)
score_board.setCellWidth(self.face, '100%')
self.create_grid()
self.start()
示例12: EditPanel
class EditPanel(AbsolutePanel):
def __init__(self, key, title, content):
AbsolutePanel.__init__(self)
self.edit_header = Label("Edit a Post", StyleName="header_label")
self.edit_title_label = Label("Title:")
self.edit_title = TextBox()
self.edit_title.setMaxLength(255)
self.edit_content = TextArea()
self.edit_content.setVisibleLines(2)
self.edit_button = Button("Save")
self.edit_cancel_button = Button("Cancel")
self.edit_hidden_key = Hidden()
self.error_message_label = Label("", StyleName="error_message_label")
edit_contents = VerticalPanel(StyleName="Contents", Spacing=4)
edit_contents.add(self.edit_header)
edit_contents.add(self.edit_title_label)
edit_contents.add(self.edit_title)
edit_contents.add(self.edit_content)
edit_contents.add(self.edit_button)
edit_contents.add(self.edit_cancel_button)
edit_contents.add(self.error_message_label)
edit_contents.add(self.edit_hidden_key)
self.edit_dialog = DialogBox(glass=True)
self.edit_dialog.setHTML('<b>Blog Post Form</b>')
self.edit_dialog.setWidget(edit_contents)
left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft()
top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop()
self.edit_dialog.setPopupPosition(left, top)
self.edit_dialog.hide()
def clear_edit_panel(self):
self.edit_title.setText("")
self.edit_content.setText("")
self.error_message_label.setText("")
示例13: Form_Row
class Form_Row(SimplePanel):
'''
Create row that will be put in the Form
'''
def __init__(self, name, widget, help=''):
SimplePanel.__init__(self)
# Container
self.mainpanel = VerticalPanel()
self.lbl = Label(name)
self.hlp = Label(help)
self.lbl.setStyleName('h3')
self.hlp.setStyleName('text-muted')
self.wdg = widget
self.mainpanel.add(self.lbl)
self.mainpanel.add(self.wdg)
self.mainpanel.add(self.hlp)
def panel(self):
return self.mainpanel
def widget(self):
return self.wdg
def help(self):
return self.hlp
示例14: ParticleDemoControls
class ParticleDemoControls(Composite):
def __init__(self):
self.average = 1
self.iterations = 1
self.startTime = -1
self.refreshRateLabel = Label("")
self.averageLabel = Label("")
layout = VerticalPanel()
layout.add(self.refreshRateLabel)
layout.add(self.averageLabel)
Composite.__init__(self, layout)
def doBenchmark(self, now):
if self.startTime < 0:
self.startTime = now
else:
self.refreshRate = now - self.startTime
self.startTime = now
self.average = ((self.average * self.iterations) + self.refreshRate) / (self.iterations + 1)
self.iterations += 1
self.refreshRateLabel.setText("Refresh Interval: " + str(refreshRate))
self.averageLabel.setText("Average Interval: " + str(average))
def resetBenchmark(self):
self.average = 1
self.iterations = 1
self.startTime = -1
示例15: addRow
def addRow(self, values):
self.rows += 1
col = -1
for name, maxLength, visibleLength in self.columns:
col += 1
label = Label()
label.setText(values[col])
self.setWidget(self.rows, col, label)