本文整理汇总了Python中pyjamas.ui.Label.Label.setText方法的典型用法代码示例。如果您正苦于以下问题:Python Label.setText方法的具体用法?Python Label.setText怎么用?Python Label.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Label.Label
的用法示例。
在下文中一共展示了Label.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QueueSize
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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()
示例2: addDropWidget
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
def addDropWidget(self):
s = len(self.children)
w = Label(Element=DOM.createElement('li'))
w.setID('effectdrop' + str(s))
w.setStyleName('drophere')
w.setText('Drop %s (%s)' % (s, self.data[s]))
self.append(w)
示例3: HorizontalToolbar
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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
示例4: _add_statusbar
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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
示例5: EditPanel
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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("")
示例6: GettextExample
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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))
示例7: WritePanel
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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: ParticleDemoControls
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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
示例9: addRow
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
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)
示例10: addDragWidget
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
def addDragWidget(self):
s = len(self.children)
w = Label(Element=DOM.createElement('li'))
w.setID('effectdrag' + str(s))
w.setStyleName('dragme')
w.setText('Drag %s (%s)' % (s, self.data[s]))
self.add(w)
makeDraggable(w)
示例11: onRemoteResponse
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
def onRemoteResponse(self, response, request_info):
if(isinstance(response, (dict,))):
if("echo" in response):
msg = "Celery echo: %s\nElapsed Time: %d"
self.setText(msg % (response["echo"], self.wait_cnt))
else:
msg = "Waiting for Celery (id, checkno): %s, %d"
Label.setText(self, msg % (self.task_id, self.wait_cnt))
else:
self.setText("Could not get remote response as a dictionary")
示例12: AuthPanel
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
class AuthPanel(VerticalPanel):
def __init__(self, beginVerifyAuth, onClose, baseStyleName='gwt-authdlgbox'):
"""Initialize a new instance.
beginVerifyAuth: callable that takes (string username, string password).Should call 'endVerifyAuth' when
finished.
onClose: callable that takes (AuthDlgBox sender, bool wasAuthorized, string username, string password). Called
when Cancel is pressed, or OK is pressed and verification is successful.
baseStyleName: base css name for type. baseStyleName + -label, -textbox, and -warninglabel should also be
defined.
"""
VerticalPanel.__init__(self, StyleName=baseStyleName)
self.onClose = onClose
self.wasAuthorized = False
self._beginVerifyAuth = beginVerifyAuth
self.baseStyleName = baseStyleName
self._createContent()
def _createContent(self):
self.add(self._createUsernamePanel())
self.add(self._createPasswordPanel())
self.add(self._createButtonPanel())
self.warningLabel = Label('', StyleName='-warninglabel')
self.add(self.warningLabel)
def _createUsernamePanel(self):
hp = HorizontalPanel()
hp.add(Label('Username: ', StyleName=self.baseStyleName + '-label'))
self.usernameTB = TextBox(StyleName=self.baseStyleName + '-textbox')
hp.add(self.usernameTB)
return hp
def _createPasswordPanel(self):
hp = HorizontalPanel()
hp.add(Label('Password: ', StyleName=self.baseStyleName + '-label'))
self.passTB = PasswordTextBox(StyleName=self.baseStyleName + '-textbox')
hp.add(self.passTB)
return hp
def _createButtonPanel(self):
hp = HorizontalPanel()
self.okBtn = Button('OK', self.onOk, StyleName=self.baseStyleName + '-button')
self.cancelBtn = Button('Cancel', self.onCancel, StyleName=self.baseStyleName + '-button')
hp.add(self.okBtn)
hp.add(self.cancelBtn)
return hp
def getUserAndPass(self):
return self.usernameTB.getText(), self.passTB.getText()
def onOk(self, sender):
self._beginVerifyAuth(*self.getUserAndPass())
return
def onCancel(self, sender):
self.onClose(self, False, None, None)
return
def endVerifyAuth(self, result, username, password, msg='Username/password invalid.'):
if result:
self.onClose(self, True, username, password)
else:
self.warningLabel.setText(msg)
示例13: PauseResume
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
class PauseResume(HorizontalPanel):
def __init__(self):
HorizontalPanel.__init__(self, Spacing=4)
self.add(Label('Dispatch:', StyleName='section'))
self.pause = Button('Pause', self)
self.add(self.pause)
self.resume = Button('Resume', self)
self.add(self.resume)
self.refresh = Button('Refresh', self, StyleName='refresh')
self.add(self.refresh)
self.err = Label()
self.add(self.err)
self._refresh()
def _refresh(self):
self.refresh.setEnabled(False)
self.pause.setEnabled(False)
self.resume.setEnabled(False)
remote = server.AdminService()
id = remote.queuePaused(self)
if id < 0:
self.err.setText('oops: could not call getQueueSize')
def onClick(self, sender):
self.err.setText('')
if sender is self.refresh:
self._refresh()
elif sender is self.pause:
self._pause()
else:
self._resume()
def _pause(self):
remote = server.AdminService()
id = remote.pause(Paused(self))
if id < 0:
self.err.setText('oops: could not call pause.')
def _resume(self):
remote = server.AdminService()
id = remote.resume(Resumed(self))
if id < 0:
self.err.setText('oops: could not call resume.')
def onRemoteResponse(self, paused, request_info):
self.refresh.setEnabled(True)
if paused:
self.resume.setEnabled(True)
else:
self.pause.setEnabled(True)
def onRemoteError(self, code, message, request_info):
self.refresh.setEnabled(True)
self.err.setText('Error from queuePaused: ' + message)
示例14: onModuleLoad
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
class CookieExample:
COOKIE_NAME = "myCookie"
def onModuleLoad(self):
try:
setCookie(COOKIE_NAME, "setme", 100000)
except:
pass
self.status = Label()
self.text_area = TextArea()
self.text_area.setText(r"Me eat cookie!")
self.text_area.setCharacterWidth(80)
self.text_area.setVisibleLines(8)
self.button_py_set = Button("Set Cookie", self)
self.button_py_read = Button("Read Cookie ", self)
buttons = HorizontalPanel()
buttons.add(self.button_py_set)
buttons.add(self.button_py_read)
buttons.setSpacing(8)
info = r"This demonstrates setting and reading information using cookies."
panel = VerticalPanel()
panel.add(HTML(info))
panel.add(self.text_area)
panel.add(buttons)
panel.add(self.status)
RootPanel().add(panel)
def onClick(self, sender):
"""
Run when any button is clicked
"""
if sender.getText() == "Set Cookie":
# clicked the set cookie button
text = self.text_area.getText()
# print goes to console.log
print "setting cookie to:", text
# Note: this sets the cookie on the top level
setCookie(COOKIE_NAME, text, 10000, path="/")
else:
cookie_text = getCookie(COOKIE_NAME)
if cookie_text is None:
print "No Cookie"
else:
print "myCookie", cookie_text
self.status.setText(cookie_text)
示例15: Timer
# 需要导入模块: from pyjamas.ui.Label import Label [as 别名]
# 或者: from pyjamas.ui.Label.Label import setText [as 别名]
class Clock:
# pyjamas doesn't generate __doc__
__doc__ = '''This demonstrates using Timer instantiated with the
notify keyword, as in:<pre> timer = Timer(notify=func) </pre>When
the timer fires it will call func() with no arguments (or
<code>self</code> if it is a bound method as in this example).
This timer is scheduled with the <code>scheduleRepeating()</code>
method, so after func() is called, it is automatically rescheduled
to fire again after the specified period. The timer can be
cancelled by calling the <code>cancel()</code> method; this
happens when you click on the button.
'''
start_txt = 'Click to start the clock'
stop_txt = 'Click to stop the clock'
def __init__(self):
# the button
self.button = Button(listener=self)
# set an attr on the button to keep track of its state
self.button.stop = False
# date label
self.datelabel = Label(StyleName='clock')
# the timer
self.timer = Timer(notify=self.updateclock)
# kick start
self.onClick(self.button)
def onClick(self, button):
if self.button.stop:
# we're stopping the clock
self.button.stop = False
self.timer.cancel()
self.button.setText(self.start_txt)
else:
# we're starting the clock
self.button.stop = True
self.timer.scheduleRepeating(1000)
self.button.setText(self.stop_txt)
def updateclock(self, timer):
# the callable attached to the timer with notify
dt = datetime.now().replace(microsecond=0)
self.datelabel.setText(dt.isoformat(' '))