本文整理汇总了Python中pyjamas.ui.TextBox.TextBox.setText方法的典型用法代码示例。如果您正苦于以下问题:Python TextBox.setText方法的具体用法?Python TextBox.setText怎么用?Python TextBox.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.TextBox.TextBox
的用法示例。
在下文中一共展示了TextBox.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TextEditor
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class TextEditor(Editor):
""" Base class for text style editors, which displays an editable text
field, containing a text representation of the object trait value.
"""
# ---------------------------------------------------------------------------
# Finishes initializing the editor by creating the underlying toolkit
# widget:
# ---------------------------------------------------------------------------
def init(self, parent):
""" Finishes initializing the editor by creating the underlying toolkit
widget.
"""
self.control = TextBox()
self.control.setText(self.str_value)
self.control.addChangeListener(getattr(self, "update_object"))
self.set_tooltip()
# ---------------------------------------------------------------------------
# Handles the user changing the contents of the edit control:
# ---------------------------------------------------------------------------
def update_object(self, sender):
""" Handles the user changing the contents of the edit control.
"""
try:
self.value = unicode(self.control.getText())
except TraitError, excp:
pass
示例2: onModuleLoad
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class TestDict:
def onModuleLoad(self):
self.r = WrapperDict()
self.kbox = TextBox()
self.addbutton = Button("Click to look up key value (hello or goodbye)")
self.addbutton.addClickListener(self)
self.kbox.setText("hello") # default to make life easier
RootPanel().add(HTML("Key:"))
RootPanel().add(self.kbox)
RootPanel().add(self.addbutton)
def display_value(self):
key = self.kbox.getText()
RootPanel().add(HTML("Value using python:" ))
RootPanel().add(HTML(self.r.python_get_value(key)))
RootPanel().add(HTML("Value using javascript:" ))
RootPanel().add(HTML(self.r.javascript_get_value(key)))
def onClick(self, sender):
self.display_value()
示例3: onModuleLoad
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class GridEdit:
def onModuleLoad(self):
self.input = TextBox()
self.input.setEnabled(False)
self.input.addKeyboardListener(self)
self.g=Grid()
self.g.resize(5, 5)
self.g.setHTML(0, 0, "<b>Grid Edit</b>")
self.g.setBorderWidth(2)
self.g.setCellPadding(4)
self.g.setCellSpacing(1)
self.g.setWidth("500px")
self.g.setHeight("120px")
self.g.addTableListener(self)
self.initGrid()
RootPanel().add(self.input)
RootPanel().add(self.g)
def onKeyDown(self, sender, keycode, modifiers):
pass
def onKeyUp(self, sender, keycode, modifiers):
pass
def onKeyPress(self, sender, keycode, modifiers):
if keycode == KeyboardListener.KEY_ESCAPE:
self.input.setEnabled(False)
elif keycode == KeyboardListener.KEY_ENTER:
self.input.setEnabled(False)
val = self.input.getText()
self.set_grid_value(self.row, self.col, val)
def onCellClicked(self, sender, row, col):
self.row = row
self.col = col
val = self.values[row][col]
self.input.setText(val)
self.input.setEnabled(True)
self.input.setFocus(True)
def set_grid_value(self, row, col, val):
self.values[row][col] = val
if val == "":
val = " "
self.g.setHTML(row, col, val)
def initGrid(self):
self.values = {}
for y in range(5):
self.values[y] = {}
for x in range(5):
self.values[y][x] = ""
for y in range(5):
for x in range(5):
val = self.values[y][x]
self.set_grid_value(y, x, val)
示例4: Cancel
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class Cancel(HorizontalPanel):
def __init__(self):
HorizontalPanel.__init__(self, Spacing=4)
self.add(Label('Cancel:', StyleName='section'))
self.name = TextBox()
self.name.setMaxLength(18)
self.name.setVisibleLength(18)
self.add(self.name)
self.cancel = Button('Do it', self)
self.add(self.cancel)
self.err = Label()
self.add(self.err)
def onClick(self, sender):
self.err.setText('')
name = self.name.getText().strip()
if name == '':
return
else:
self.cancel.setEnabled(False)
remote = server.AdminService()
id = remote.cancel(name, self)
if id < 0:
self.err.setText('oops: could not cancel')
def onRemoteResponse(self, result, request_info):
self.cancel.setEnabled(True)
self.name.setText('')
def onRemoteError(self, code, message, request_info):
self.cancel.setEnabled(True)
self.err.setText('Could not cancel: ' + message['data']['message'])
示例5: __init__
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
def __init__ (self, **kwargs):
ZillaWindow.__init__(self, kwargs)
DialogBox.__init__(self, kwargs)
self.dockPanel = DockPanel()
self.dockPanel.setSpacing(4)
self.setText ("Logowanie")
hpanel1 = HorizontalPanel()
login = TextBox()
login.setText("Login")
#hpanel1.add(login)
passwd = TextBox()
passwd.setText("Hasło")
self.dockPanel.add(login, DockPanel.NORTH)
self.dockPanel.add(passwd, DockPanel.NORTH)
#hpanel1.add(passwd)
#self.add(hpanel1)
self.add(login)
self.add(passwd)
示例6: onModuleLoad
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class TestRect:
def onModuleLoad(self):
self.r = Rect(0.0, 0.0)
self.xbox = TextBox()
self.ybox = TextBox()
self.addbutton = Button("Click to add x and y to Rectangle")
self.addbutton.addClickListener(self)
self.xbox.setText("2")
self.ybox.setText("5")
RootPanel().add(HTML("X Value:"))
RootPanel().add(self.xbox)
RootPanel().add(HTML("Y Value:"))
RootPanel().add(self.ybox)
RootPanel().add(self.addbutton)
RootPanel().add(HTML("Current value: %d %d" % ( self.r.get_x(), self.r.get_y())))
def onClick(self, sender):
x = int(self.xbox.getText())
y = int(self.ybox.getText())
r = Rect(x, y)
self.r.add(r)
RootPanel().add(HTML("New value: %d" % ( self.r.get_x())))
RootPanel().add(HTML("New value: %d" % ( self.r.get_y())))
RootPanel().add(HTML("New value: %d %d" % ( self.r.get_x(), self.r.get_y())))
RootPanel().add(HTML("New Area: %d" % self.r.area()))
示例7: editMovieButton_Click
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
def editMovieButton_Click(sender):
# Add textboxes and listbox
editMovieButton.setVisible(False)
cancelButton.setVisible(True)
saveButton.setVisible(True)
editCategory = TextBox()
editName = TextBox()
editRating = ListBox(False)
for i in range(self.MAX_RATING + 1):
editRating.addItem(str(i))
# Variable width textboxes
catlen = len(movie.category)
namelen = len(movie.name)
if (catlen > 8):
editCategory.setWidth(str(catlen*10) + "px")
else:
editCategory.setWidth("80px")
if (namelen > 8):
editName.setWidth(str(namelen*10) + "px")
else:
editName.setWidth("80px")
self.moviesFlexTable.setWidget(row, 1, editCategory)
self.moviesFlexTable.setWidget(row, 2, editName)
self.moviesFlexTable.setWidget(row, 3, editRating)
editCategory.setText(movie.category)
editName.setText(movie.name)
editRating.setSelectedIndex(movie.rating)
示例8: WritePanel
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox 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("")
示例9: EditPanel
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox 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("")
示例10: PreferencesDlg
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class PreferencesDlg(DialogBox):
fileLocation = None
def __init__(self, left = 50, top = 50):
DialogBox.__init__(self, modal = False)
self.setPopupPosition(left, top)
self.setText("Preferences")
ftable = FlexTable()
ftableFormatter = ftable.getFlexCellFormatter()
row = 0
self.fileLocation = getCookie("fileLocation")
row += 1
ftable.setWidget(row, 0, Label("Sheet loaded on startup", wordWrap=False))
self.fileLocationInput = TextBox()
self.fileLocationInput.addChangeListener(self.checkValid)
self.fileLocationInput.addKeyboardListener(self)
self.fileLocationInput.setVisibleLength(30)
self.fileLocationInput.setText(self.fileLocation)
ftable.setWidget(row, 1, self.fileLocationInput)
row += 1
hpanel = HorizontalPanel()
self.saveBtn = Button("Save", self.onSave)
self.saveBtn.setEnabled(False)
hpanel.add(self.saveBtn)
self.cancelBtn = Button("Cancel", self.onCancel)
hpanel.add(self.cancelBtn)
ftable.setWidget(row, 0, hpanel)
ftableFormatter.setColSpan(row, 0, 2)
self.setWidget(ftable)
def onCancel(self, sender):
self.hide()
def onSave(self, sender):
setCookie("fileLocation", self.fileLocationInput.getText(), 1000000000)
self.hide()
def checkValid(self, evt=None):
if self.fileLocation != self.fileLocationInput.getText():
self.saveBtn.setEnabled(True)
else:
self.saveBtn.setEnabled(False)
def onClick(self, sender):
pass
def onKeyUp(self, sender, keyCode, modifiers):
self.checkValid()
def onKeyDown(self, sender, keyCode, modifiers):
pass
def onKeyPress(self, sender, keyCode, modifiers):
pass
示例11: DatePicker
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class DatePicker(HorizontalPanel):
time = None
dateBox = None
def __init__(self):
try:
HorizontalPanel.__init__(self)
self.time = time.time()
prevDayBtn = Button(" < ", self.onPrevDay)
nextDayBtn = Button(" > ", self.onNextDay)
prevWeekBtn = Button(" << ", self.onPrevWeek)
nextWeekBtn = Button(" >> ", self.onNextWeek)
self.dateBox = TextBox()
self.dateBox.setMaxLength(10)
self.dateBox.setVisibleLength(10)
self.add(prevWeekBtn)
self.add(prevDayBtn)
self.add(self.dateBox)
self.add(nextDayBtn)
self.add(nextWeekBtn)
except:
raise
def onPrevDay(self, sender):
self.mediator.sendNotification(Notification.PREV_DAY)
def onNextDay(self, sender):
self.mediator.sendNotification(Notification.NEXT_DAY)
def onPrevWeek(self, sender):
self.mediator.sendNotification(Notification.PREV_WEEK)
def onNextWeek(self, sender):
self.mediator.sendNotification(Notification.NEXT_WEEK)
def displayDay(self):
self.dateBox.setText(time.strftime("%d/%m/%Y", time.localtime(self.time)))
date = time.strftime("%Y%m%d", time.localtime(self.time))
self.mediator.sendNotification(Notification.DATE_SELECTED, date)
def prevDay(self):
self.time -= 86400
self.displayDay()
def nextDay(self):
self.time += 86400
self.displayDay()
def prevWeek(self):
self.time -= 7*86400
self.displayDay()
def nextWeek(self):
self.time += 7*86400
self.displayDay()
示例12: LoginDialgoBox
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class LoginDialgoBox(DialogBox,RPCBase):
def __init__(self, app):
DialogBox.__init__(self)
self.app = app
self.table=FlexTable()
self.table.setText(0, 0, "Please enter username and password")
self.table.getFlexCellFormatter().setColSpan(0, 0, 2)
self.table.setText(1, 0, "Username")
self.handle = TextBox()
h = getCookie('handle')
self.handle.setText(h)
self.table.setWidget(1, 1, self.handle)
self.table.setText(2, 0, "Password")
self.pwd = PasswordTextBox()
self.table.setWidget(2, 1, self.pwd)
self.table.setHTML(3,0,"")
self.table.getFlexCellFormatter().setColSpan(3, 0, 2)
h = HorizontalPanel()
self.table.setWidget(4,0, h)
self.table.getFlexCellFormatter().setColSpan(4, 0, 2)
h.add(Button("Ok", getattr(self, "onOk")))
h.add(Button("Cancel", getattr(self, "onClose")))
h.setSpacing(4)
self.setHTML("<b>Login</b>")
self.setWidget(self.table)
left = (Window.getClientWidth() - 200) / 2
top = (Window.getClientHeight() - 100) / 2
self.setPopupPosition(left,top)
def onRemoteResponse(self, response, request_info):
if response == "invalid_cookie":
self.show()
elif response == None or len(response) < 3:
self.table.setHTML(3,0,"<b>Invalid username or password</b>")
else:
self.app.cookie = response[0]
setCookie('cookie',response[0],1000*60*60*24)
self.hide()
self.app.logininit(response[1],response[2])
def onClose(self,env):
Window.getLocation().setHref("http://www.google.com")
def onOk(self, env):
global gw
setCookie('handle',self.handle.getText(),24*60*60*1000)
x = self.pwd.getText()
x = pwhash(x)
gw.login(self.handle.getText(), x, self)
def login(self):
global gw
if not self.app.cookie:
self.show()
else:
gw.validateCookie(self.app.cookie, self)
示例13: CalibrateChannelTrimsView
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class CalibrateChannelTrimsView(object) :
"""
Class that takes care of the purely UI parts of the trim calibration
"""
def __init__( self ) :
numberOfLoopsPanel=HorizontalPanel()
numberOfLoopsPanel.add( HTML("Maximum number of loops") )
self.maximumNumberOfLoops=TextBox()
self.maximumNumberOfLoops.setText(10)
numberOfLoopsPanel.add( self.maximumNumberOfLoops )
numberOfLoopsPanel.setCellHorizontalAlignment( self.maximumNumberOfLoops, HasHorizontalAlignment.ALIGN_RIGHT )
numberOfLoopsPanel.setWidth("100%")
aimPointPanel=HorizontalPanel()
aimPointPanel.add( HTML("Aim point") )
self.aimPoint=TextBox()
self.aimPoint.setText(127)
aimPointPanel.add( self.aimPoint )
aimPointPanel.setCellHorizontalAlignment( self.aimPoint, HasHorizontalAlignment.ALIGN_RIGHT )
aimPointPanel.setWidth("100%")
self.start=Button("Start")
self.echo=HTML("Initiating...")
self.mainPanel = VerticalPanel()
self.mainPanel.add( numberOfLoopsPanel )
self.mainPanel.add( aimPointPanel )
self.mainPanel.add( self.start )
self.mainPanel.add( self.echo )
def getMaxNumberOfLoops( self ) :
return int(self.maximumNumberOfLoops.getText())
def getAimPoint( self ) :
return int(self.aimPoint.getText())
def getStartButton( self ) :
return self.start
def setEchoText( self, text ) :
self.echo.setText( text )
def enable( self ) :
self.start.setEnabled(True)
def disable( self ) :
self.start.setEnabled(False)
def getPanel( self ) :
return self.mainPanel
示例14: InputControl
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
class InputControl(Control):
def __init__(self, min_value, max_value, start_value=None, step=None,
**kwargs):
if not kwargs.has_key("StyleName"):
kwargs['StyleName'] = "gwt-InputControl"
self.input = TextBox()
self.input.addKeyboardListener(self)
#element = DOM.createDiv()
if kwargs.has_key('Element'):
# XXX FIXME: unlikely to work!
element = kwargs.pop('Element')
else:
element = self.input.getElement() # YUK!!!
Control.__init__(self, element, min_value, max_value, start_value, step,
**kwargs)
self.addClickListener(self)
self.addFocusListener(self)
self.addKeyboardListener(self)
def onFocus(self, sender):
self.addStyleName("gwt-InputControl-focussed")
def onLostFocus(self, sender):
self.removeStyleName("gwt-InputControl-focussed")
def setControlPos(self, value):
self.input.setText(value)
def onKeyPress(self, sender, keycode, modifiers):
if keycode == KeyboardListener.KEY_ENTER:
DOM.eventPreventDefault(DOM.eventGetCurrentEvent())
txt = self.input.getText()
if not txt:
return
new_value = float(txt)
new_value = self.processValue(new_value)
self.setControlPos(new_value)
self.setValue(new_value)
else:
Control.onKeyPress(self, sender, keycode, modifiers)
示例15: createStatesPanel
# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setText [as 别名]
def createStatesPanel(self):
vertPanel=VerticalPanel()
vertPanel.setSpacing(10)
selectionNames = (["Main Control", "Masks", "Trims"])
registerSelection = VerticalPanel()
for name in selectionNames :
checkBox = CheckBox(name)
checkBox.setTitle(name)
self.stateValueEntries[name]=checkBox
registerSelection.add(checkBox)
#Tidy up
loadPanel = HorizontalPanel()
loadFileTextBox = TextBox()
loadFileTextBox.setText("MyI2cCfg")
loadFileTextBox.setWidth(80)
self.loadFileName = loadFileTextBox
loadPanel.add(loadFileTextBox)
self.load = Button("Load",getattr(self,"onChange")) #overrides default and sends it to onChange
loadPanel.add(self.load)
self.load.setEnabled(False)
savePanel = HorizontalPanel()
saveFileTextBox = TextBox()
saveFileTextBox.setText("MyI2cCfg")
saveFileTextBox.setWidth(80)
self.saveFileName = saveFileTextBox
savePanel.add(saveFileTextBox)
self.save = Button("Save", getattr(self,"onChange"))
savePanel.add(self.save)
self.save.setEnabled(False)
self.returnStatement = Label()
vertPanel.add(registerSelection)
vertPanel.add(loadPanel)
vertPanel.add(savePanel)
vertPanel.add(self.returnStatement)
return vertPanel