本文整理汇总了Python中pyjamas.ui.TextBox.TextBox类的典型用法代码示例。如果您正苦于以下问题:Python TextBox类的具体用法?Python TextBox怎么用?Python TextBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_custom
def show_custom(self):
self.dialog = DialogBox(StyleName='custom-dialog')
self.dialog.setHTML('Custom Settings')
contents = VerticalPanel(StyleName='contents')
self.dialog.setWidget(contents)
# contents of contents
rows = HorizontalPanel()
columns = HorizontalPanel()
bombs = HorizontalPanel()
buttons = HorizontalPanel()
ADD(contents, rows, columns, bombs, buttons)
self.row = TextBox()
ADD(rows, Label('Rows:'), self.row)
self.column = TextBox()
ADD(columns, Label('Columns:'), self.column)
self.bomb = TextBox()
ADD(bombs, Label('Bombs:'), self.bomb)
ADD(buttons, Button("OK", getattr(self, 'new_game')), \
Button("Cancel", getattr(self, 'close_dialog')))
left = (Window.getClientWidth() - 201) / 2
top = (Window.getClientHeight() - 190) / 2
self.dialog.setPopupPosition(left, top)
self.dialog.show()
示例2: PreferencesDlg
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
示例3: __init__
def __init__(self):
AbsolutePanel.__init__(self)
self.app = CompaniesApp()
self.history = []
self.save = Button("save", self)
self.selectDepartment = Button("select", self)
self.selectEmployee = Button("select", self)
self.edit = Button("edit", self)
self.cut = Button("cut", self)
self.back = Button("back", self)
self.name = TextBox()
self.address = TextBox()
self.manager = TextBox()
self.departments = ListBox(Size=("100%"), VisibleItemCount="5")
self.employees = ListBox(Size=("100%"), VisibleItemCount="5")
self.total = TextBox()
self.errors = VerticalPanel()
self.grid = Grid()
self.allPanels = VerticalPanel()
self.allPanels.add(self.grid)
self.allPanels.add(self.errors)
self.add(self.allPanels)
self.initCompanyGUI()
示例4: onModuleLoad
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()
示例5: 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("")
示例6: 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("")
示例7: TextEditor
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
示例8: DirectAdd
class DirectAdd(HorizontalPanel):
def __init__(self):
HorizontalPanel.__init__(self, Spacing=4)
self.add(Label('Directly add:', StyleName='section'))
self.name = TextBox()
self.name.setMaxLength(18)
self.name.setVisibleLength(18)
self.add(self.name)
self.update = Button('Add', self)
self.add(self.update)
self.err = Label()
self.add(self.err)
def onClick(self, sender):
self.err.setText('')
name = self.name.getText().strip()
if name == '':
return
else:
self.update.setEnabled(False)
remote = server.AdminService()
id = remote.directAddUser(name, self)
if id < 0:
self.err.setText('oops: could not add')
def onRemoteResponse(self, result, request_info):
self.update.setEnabled(True)
def onRemoteError(self, code, message, request_info):
self.update.setEnabled(True)
self.err.setText('Could not add: ' + message['data']['message'])
示例9: __init__
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 )
示例10: __init__
def __init__(self, **kwargs):
TextBox.__init__(self)
self.max_length = kwargs.get('max_length', None)
self.min_length = kwargs.get('min_length', None)
self.required = kwargs.get('required', None)
if kwargs.get('initial'):
self.setValue(kwargs['initial'])
示例11: __init__
def __init__(self):
SimplePanel.__init__(self)
field = TextBox()
field.setVisibleLength(20)
field.setMaxLength(10)
self.add(field)
示例12: onModuleLoad
class FormPanelExample:
def onModuleLoad(self):
# Create a FormPanel and point it at a service.
self.form = FormPanel()
self.form.setAction("/chat-service/test/")
# Because we're going to add a FileUpload widget, we'll need to set the
# form to use the POST method, and multipart MIME encoding.
self.form.setEncoding(FormPanel.ENCODING_MULTIPART)
self.form.setMethod(FormPanel.METHOD_POST)
# Create a panel to hold all of the form widgets.
panel = VerticalPanel()
self.form.setWidget(panel)
# Create a TextBox, giving it a name so that it will be submitted.
self.tb = TextBox()
self.tb.setName("textBoxFormElement")
panel.add(self.tb)
# Create a ListBox, giving it a name and some values to be associated with
# its options.
lb = ListBox()
lb.setName("listBoxFormElement")
lb.addItem("foo", "fooValue")
lb.addItem("bar", "barValue")
lb.addItem("baz", "bazValue")
panel.add(lb)
# Create a FileUpload widget.
upload = FileUpload()
upload.setName("uploadFormElement")
panel.add(upload)
# Add a 'submit' button.
panel.add(Button("Submit", self))
# Add an event handler to the form.
self.form.addFormHandler(self)
RootPanel().add(self.form)
def onClick(self, sender):
self.form.submit()
def onSubmitComplete(self, event):
# When the form submission is successfully completed, this event is
# fired. Assuming the service returned a response of type text/plain,
# we can get the result text here (see the FormPanel documentation for
# further explanation).
Window.alert(event.getResults())
def onSubmit(self, event):
# This event is fired just before the form is submitted. We can take
# this opportunity to perform validation.
if self.tb.getText().length == 0:
Window.alert("The text box must not be empty")
event.setCancelled(True)
示例13: __init__
def __init__(self,parent):
AbsolutePanel.__init__(self)
ftable = FlexTable()
ftable.setWidget(0, 0, Label("First Name", wordWrap=False))
ftableFormatter = ftable.getFlexCellFormatter()
self.firstInput = TextBox()
self.firstInput.addChangeListener(self.checkValid)
self.firstInput.addKeyboardListener(self)
ftable.setWidget(0, 1, self.firstInput)
ftable.setWidget(1, 0, Label("Last Name", wordWrap=False))
self.lastInput = TextBox()
self.lastInput.addChangeListener(self.checkValid)
self.lastInput.addKeyboardListener(self)
ftable.setWidget(1, 1, self.lastInput)
ftable.setWidget(2, 0, Label("Email", wordWrap=False))
self.emailInput = TextBox()
self.emailInput.addChangeListener(self.checkValid)
self.emailInput.addKeyboardListener(self)
ftable.setWidget(2, 1, self.emailInput)
ftable.setWidget(3, 0, Label("Username", wordWrap=False))
self.usernameInput = TextBox()
self.usernameInput.addChangeListener(self.checkValid)
self.usernameInput.addKeyboardListener(self)
ftable.setWidget(3, 1, self.usernameInput)
ftable.setWidget(4, 0, Label("Password", wordWrap=False))
self.passwordInput = PasswordTextBox()
self.passwordInput.addChangeListener(self.checkValid)
self.passwordInput.addKeyboardListener(self)
ftable.setWidget(4, 1, self.passwordInput)
ftable.setWidget(5, 0, Label("Confirm", wordWrap=False))
self.confirmInput = PasswordTextBox()
self.confirmInput.addChangeListener(self.checkValid)
self.confirmInput.addKeyboardListener(self)
ftable.setWidget(5, 1, self.confirmInput)
ftable.setWidget(6, 0, Label("Department", wordWrap=False))
self.departmentCombo = ListBox()
self.departmentCombo.addChangeListener(self.checkValid)
self.departmentCombo.addKeyboardListener(self)
ftable.setWidget(6, 1, self.departmentCombo)
hpanel = HorizontalPanel()
self.addBtn = Button("Add User", self.onAdd)
self.addBtn.setEnabled(False)
hpanel.add(self.addBtn)
self.cancelBtn = Button("Cancel", self.onCancel)
hpanel.add(self.cancelBtn)
ftable.setWidget(7, 0, hpanel)
ftableFormatter.setColSpan(7, 0, 2)
self.add(ftable)
return
示例14: LoginDialgoBox
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)
示例15: __init__
def __init__(self):
self.artist =''
self.start_date = ''
self.end_date = ''
self.period_search =''
self.search_option = 1
#declare the general interface widgets
self.panel = DockPanel(StyleName = 'background')
self.ret_area = TextArea()
self.ret_area.setWidth("350px")
self.ret_area.setHeight("90px")
self.options = ListBox()
self.search_button = Button("Search", getattr(self, "get_result"), StyleName = 'button')
#set up the date search panel; it has different text boxes for
#to and from search dates
self.date_search_panel = VerticalPanel()
self.date_search_start = TextBox()
self.date_search_start.addInputListener(self)
self.date_search_end = TextBox()
self.date_search_end.addInputListener(self)
self.date_search_panel.add(HTML("Enter as month/day/year", True, StyleName = 'text'))
self.date_search_panel.add(HTML("From:", True, StyleName = 'text'))
self.date_search_panel.add(self.date_search_start)
self.date_search_panel.add(HTML("To:", True, StyleName = 'text'))
self.date_search_panel.add(self.date_search_end)
#set up the artist search panel
self.artist_search = TextBox()
self.artist_search.addInputListener(self)
self.artist_search_panel = VerticalPanel()
self.artist_search_panel.add(HTML("Enter artist's name:",True,
StyleName = 'text'))
self.artist_search_panel.add(self.artist_search)
#Put together the list timespan search options
self.period_search_panel = VerticalPanel()
self.period_search_panel.add(HTML("Select a seach period:",True,
StyleName = 'text'))
self.period_search = ListBox()
self.period_search.setVisibleItemCount(1)
self.period_search.addItem("last week")
self.period_search.addItem("last month")
self.period_search.addItem("last year")
self.period_search.addItem("all time")
self.period_search_panel.add(self.period_search)
#add the listeners to the appropriate widgets
self.options.addChangeListener(self)
self.period_search.addChangeListener(self)
self.ret_area_scroll = ScrollPanel()
self.search_panel = HorizontalPanel()
self.options_panel = VerticalPanel()