本文整理汇总了Python中pyjamas.ui.TextArea.TextArea.getText方法的典型用法代码示例。如果您正苦于以下问题:Python TextArea.getText方法的具体用法?Python TextArea.getText怎么用?Python TextArea.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.TextArea.TextArea
的用法示例。
在下文中一共展示了TextArea.getText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BulkDirectAdd
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
class BulkDirectAdd(HorizontalPanel):
def __init__(self):
HorizontalPanel.__init__(self, Spacing=4)
self.add(Label('Directly add in bulk:', StyleName='section'))
self.names = TextArea(VisibleLines=5)
self.add(self.names)
self.update = Button('Add', self)
self.add(self.update)
self.err = HTML()
self.add(self.err)
def onClick(self, sender):
self.err.setHTML('')
names = self.names.getText().strip()
if names == '':
return
else:
self.update.setEnabled(False)
remote = server.AdminService()
id = remote.bulkAddUsers(names, self)
if id < 0:
self.err.setText('oops: could not add')
def onRemoteResponse(self, result, request_info):
self.update.setEnabled(True)
self.err.setText('OK, adding.')
def onRemoteError(self, code, message, request_info):
self.update.setEnabled(True)
self.err.setHTML('Errors:<br/>' +
'<br/>'.join(message['data']['message']))
示例2: Email
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
class Email(Composite):
def __init__(self, **kwargs):
element = None
if kwargs.has_key('Element'):
element = kwargs.pop('Element')
panel = VerticalPanel(Element=element)
Composite.__init__(self, panel, **kwargs)
self.TEXT_WAITING = "Please wait..."
self.TEXT_ERROR = "Server Error"
self.remote_py = EchoServicePython()
self.status=Label()
self.subject = TextBox()
self.subject.setVisibleLength(60)
self.sender = TextBox()
self.sender.setVisibleLength(40)
self.message = TextArea()
self.message.setCharacterWidth(60)
self.message.setVisibleLines(15)
self.button_py = Button("Send", self)
buttons = HorizontalPanel()
buttons.add(self.button_py)
buttons.setSpacing(8)
panel.add(HTML("Subject:"))
panel.add(self.subject)
panel.add(HTML("From:"))
panel.add(self.sender)
panel.add(HTML("Your Message - please keep it to under 1,000 characters"))
panel.add(self.message)
panel.add(buttons)
panel.add(self.status)
def onClick(self, sender):
self.status.setText(self.TEXT_WAITING)
text = self.message.getText()
msg_sender = self.sender.getText()
msg_subject = self.subject.getText()
# demonstrate proxy & callMethod()
if sender == self.button_py:
id = self.remote_py.send(msg_sender, msg_subject, text, self)
if id<0:
self.status.setText(self.TEXT_ERROR)
def onRemoteResponse(self, response, request_info):
self.status.setText(response)
def onRemoteError(self, code, message, request_info):
self.status.setText("Server Error or Invalid Response: ERROR " + \
str(code) + " - " + str(message))
示例3: Wiki
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
class Wiki(KeyboardHandler):
def __init__(self):
self.remote = DataService()
self.title = Label()
self.h = WikiBox()
self.t = TextArea()
self.t.addKeyboardListener(self)
self.t.addChangeListener(self)
RootPanel().add(self.title)
RootPanel().add(self.h)
RootPanel().add(self.t)
History.addHistoryListener(self)
self.name = None
initToken = History.getToken()
if not (initToken and len(initToken)):
initToken = 'welcomepage'
self.onHistoryChanged(initToken)
def onHistoryChanged(self,token):
self.name = token
self.title.setText('Wiki page for: ' + token)
self.remote.find_one(token,self)
def onChange(self, sender):
if sender == self.t:
self.remote.insert(self.name,
self.t.getText(),
self)
def onRemoteResponse(self, response, request_info):
if request_info.method == 'find_one':
self.h.setHTML(response['content'])
self.t.setText(response['content'])
def onRemoteError(self, code, message, request_info):
log.debug('remote error! ' + str(message))
log.debug('remote error! ' + str(request_info))
def onKeyUp(self, sender, keycode, modifiers):
if sender == self.t:
self.h.setHTML(self.t.getText())
示例4: onModuleLoad
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [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)
示例5: onModuleLoad
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
class JSONRPCExample:
def onModuleLoad(self):
self.TEXT_WAITING = "Waiting for response..."
self.TEXT_ERROR = "Server Error"
self.METHOD_ECHO = "Echo"
self.METHOD_REVERSE = "Reverse"
self.METHOD_UPPERCASE = "UPPERCASE"
self.METHOD_LOWERCASE = "lowercase"
self.METHOD_NONEXISTANT = "Non existant"
self.methods = [self.METHOD_ECHO, self.METHOD_REVERSE,
self.METHOD_UPPERCASE, self.METHOD_LOWERCASE,
self.METHOD_NONEXISTANT]
self.remote_php = EchoServicePHP()
self.remote_py = EchoServicePython()
self.status=Label()
self.text_area = TextArea()
self.text_area.setText("""{'Test'} [\"String\"]
\tTest Tab
Test Newline\n
after newline
""" + r"""Literal String:
{'Test'} [\"String\"]
""")
self.text_area.setCharacterWidth(80)
self.text_area.setVisibleLines(8)
self.method_list = ListBox()
self.method_list.setName("hello")
self.method_list.setVisibleItemCount(1)
for method in self.methods:
self.method_list.addItem(method)
self.method_list.setSelectedIndex(0)
method_panel = HorizontalPanel()
method_panel.add(HTML("Remote string method to call: "))
method_panel.add(self.method_list)
method_panel.setSpacing(8)
self.button_php = Button("Send to PHP Service", self)
self.button_py = Button("Send to Python Service", self)
buttons = HorizontalPanel()
buttons.add(self.button_php)
buttons.add(self.button_py)
buttons.setSpacing(8)
info = """<h2>JSON-RPC Example</h2>
<p>This example demonstrates the calling of server services with
<a href="http://json-rpc.org/">JSON-RPC</a>.
</p>
<p>Enter some text below, and press a button to send the text
to an Echo service on your server. An echo service simply sends the exact same text back that it receives.
</p>"""
panel = VerticalPanel()
panel.add(HTML(info))
panel.add(self.text_area)
panel.add(method_panel)
panel.add(buttons)
panel.add(self.status)
RootPanel().add(panel)
def onClick(self, sender):
self.status.setText(self.TEXT_WAITING)
method = self.methods[self.method_list.getSelectedIndex()]
text = self.text_area.getText()
# demonstrate proxy & callMethod()
if sender == self.button_php:
if method == self.METHOD_ECHO:
id = self.remote_php.echo(text, self)
elif method == self.METHOD_REVERSE:
id = self.remote_php.callMethod("reverse", [text], self)
elif method == self.METHOD_UPPERCASE:
id = self.remote_php.uppercase(text, self)
elif method == self.METHOD_LOWERCASE:
id = self.remote_php.lowercase(self, msg=text)
elif method == self.METHOD_NONEXISTANT:
id = self.remote_php.nonexistant(text, self)
else:
if method == self.METHOD_ECHO:
id = self.remote_py.echo(text, self)
elif method == self.METHOD_REVERSE:
id = self.remote_py.reverse(text, self)
elif method == self.METHOD_UPPERCASE:
id = self.remote_py.uppercase(text, self)
elif method == self.METHOD_LOWERCASE:
id = self.remote_py.lowercase(text, self)
elif method == self.METHOD_NONEXISTANT:
id = self.remote_py.nonexistant(text, self)
def onRemoteResponse(self, response, request_info):
self.status.setText(response)
def onRemoteError(self, code, errobj, request_info):
# onRemoteError gets the HTTP error code or 0 and
# errobj is an jsonrpc 2.0 error dict:
#.........这里部分代码省略.........
示例6: EditDialogWindow
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
#.........这里部分代码省略.........
theme : "advanced",
plugins : "inlinepopups",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,table,image,removeformat",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true
});
ed.render();
ed.load();
tinymce.add(ed);
""" % self.editor_id
print new_script.innerHTML
DOM.setElemAttribute(new_script, "type", "text/javascript")
doc().body.appendChild(new_script)
def load(self, token, fname, data):
left = 50 # self.fDialogButton.getAbsoluteLeft() + 10
top = 50 # self.fDialogButton.getAbsoluteTop() + 10
self.setPopupPosition(left, top)
self.show()
self.token = token
self.fname = fname
self.msg.setHTML("<center>This is an example of a standard dialog box component.<br> You can put pretty much anything you like into it,<br>such as the following image '%s':</center>" % fname)
self.txt.setText(data)
if not self.editor_created:
self.editor_created = True
if self.fname.endswith(".html"):
Timer(1500, notify=self._load_tinymce)
def _load_tinymce(self, timer):
self.add_tinymce()
#self.load_tinymce()
def load_tinymce(self):
# activate tinymce
new_script = DOM.createElement("script")
new_script.innerHTML = """
var ed = tinyMCE.get('%s');
ed.init();
ed.render();
""" % self.editor_id
print new_script.innerHTML
DOM.setElemAttribute(new_script, "type","text/javascript")
doc().body.appendChild(new_script)
def transfer_tinymce(self):
new_script = DOM.createElement("script")
new_script.innerHTML = """
var ed = tinyMCE.get('%s');
var data = ed.getContent({'format': 'raw'});
frame = document.getElementById('__edit_%s');
frame.innerText = data;
ed.save();
ed.remove();
""" % (self.editor_id, self.editor_id)
self.editor_created = False
DOM.setElemAttribute(new_script, "type","text/javascript")
doc().body.appendChild(new_script)
self.hide()
t = Timer(notify=self)
t.scheduleRepeating(1000)
def onTimer(self, timer):
iframe = doc().getElementById("__edit_%s" % self.editor_id)
print dir(iframe)
txt = iframe.innerText
if not txt:
return
timer.cancel()
doc().body.removeChild(iframe)
self.app.save_page(self.token, self.fname, txt)
def onClick(self, sender):
if sender == self.saveButton:
if self.fname.endswith(".html"):
self.transfer_tinymce()
else:
txt = self.txt.getText()
self.app.save_page(self.token, self.fname, txt)
self.hide()
else:
self.hide()
示例7: onSelectionChange
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
#.........这里部分代码省略.........
def set_html_focus(self):
self.m_html.setFocus(True)
def createTextBox(self, startVal):
res = TextBox()
res.setWidth("35px")
res.setText(str(startVal))
return res
def reset(self):
self.m_rte.setHTML(
"The <span style=\"font-weight: bold;\">quick</span> " +
"<span style=\"font-style: italic;\">brown </span>" +
"fox jumped<br>ov" +
"<a href=\"http:#google.com\">er </a>" +
"<span style=\"text-decoration: underline;\">" +
"<a href=\"http:#google.com\">th</a>e la</span>zy dogs<br>" +
"Some spaces<br>")
def refresh(self, rng=None):
if rng is None:
rng = self.m_tb.getRange()
self.m_html.setText(self.m_tb.getHtml())
if rng is not None:
if rng.isCursor():
rep = rng.getCursor()
self.m_sel.setText(str(rep))
else:
self.m_sel.setText(rng.getHtmlText())
else:
self.m_sel.setText("")
def font1(self):
self.m_tb._surround(FontFamilyManager, "Times New Roman")
def font2(self):
self.m_tb._surround(FontFamilyManager, "Arial")
def surround1(self):
self.m_tb._surround(CustomStyleManager, "editor-cls1")
def surround2(self):
self.m_tb._surround(CustomStyleManager, "editor-cls2")
def onClick(self, wid):
if wid == self.m_getCurr:
self.refresh()
elif wid == self.m_deleteSel:
self.m_tb.delete()
elif wid == self.m_reset:
self.reset()
elif wid == self.m_toECursor:
self.m_tb.toCursor(False)
elif wid == self.m_toSCursor:
self.m_tb.toCursor(True)
elif wid == self.m_font1:
self.font1()
elif wid == self.m_font2:
self.font2()
elif wid == self.m_surround1:
self.surround1()
elif wid == self.m_surround2:
self.surround2()
elif wid == self.m_setHtml:
self.toHtml()
elif wid == self.m_select:
self.selectNodes(True)
elif wid == self.m_cursor:
self.selectNodes(False)
def toHtml(self):
self.m_tb.setHtml(self.m_html.getText())
def selectNodes(self, fullSel):
startNode = int(self.m_startNode.getText())
startOffset = int(self.m_startOffset.getText())
if fullSel:
endNode = int(self.m_endNode.getText())
endOffset = int(self.m_endOffset.getText())
else:
endNode = startNode
endOffset = startOffset
self.m_tb.selectNodes(startNode, startOffset, endNode, endOffset)
示例8: __init__
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
class SubmitTab:
def __init__(self,app):
self.app=app
self.form = FormPanel()
self.form.setEncoding("multipart/form-data")
self.form.setMethod("post")
self.msg = HTML("<b>Uploading</b>")
self.table = FlexTable()
self.table.setText(0,0, "Problem")
self.table.setText(1,0, "Language")
self.table.setText(2,0, "Program File")
self.table.setText(3,0, "Program source")
self.problem = ListBox()
self.problem.insertItem("Detect",-1,-1)
self.problem.setName("problem")
self.table.setWidget(0,1,self.problem)
self.lang = ListBox()
self.lang.insertItem("Detect","",-1)
self.lang.insertItem("C/C++","cc",-1)
self.lang.insertItem("Java","Java",-1)
self.lang.insertItem("Python","Python",-1)
self.lang.setName("lang")
self.table.setWidget(1,1,self.lang)
self.cookie = Hidden()
self.cookie.setName("cookie")
self.table.setWidget(5,0,self.cookie)
self.file = FileUpload()
self.file.setName("file");
self.table.setWidget(2,1,self.file)
self.source = TextArea()
self.source.setName("source")
self.source.setWidth("600");
self.source.setHeight("400");
self.source.setText("""//$$problem: 1$$
//$$language: cc$$
#include <unistd.h>
#include <stdio.h>
int main() {
int a,b;
scanf("%d %d",&a,&b);
printf("%d\\n",a+b);
return 0;
}""")
self.source.addChangeListener(self.onChange)
self.table.setWidget(3,1,self.source)
self.button = Button("Submit",self)
self.table.setWidget(4,1, self.button)
self.table.setWidget(5,1, self.msg)
self.msg.setVisible(False)
self.form.setWidget(self.table)
self.form.setAction("../upload.py/submit")
self.form.addFormHandler(self)
def onChange(self, src):
if self.source.getText():
self.file = FileUpload()
self.file.setName("file");
self.table.setWidget(2,1,self.file)
def onSubmitComplete(self,event):
self.msg.setVisible(False)
def onSubmit(self,evt):
self.msg.setVisible(True)
def onClick(self,evt):
if self.app.cookie == None:
self.app.login()
else:
self.cookie.setValue(self.app.cookie)
self.form.submit()
def getRoot(self):
return self.form
示例9: Circuit
# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import getText [as 别名]
class Circuit(object):
def __init__(self, handle):
self.log = logging.getConsoleLogger(type(self).__name__, lev)
self.log.disabled = False
self.log.debug("__init__: Instantiation")
self._cacheBreaker = 0
self._handle = handle
self.remoteService = DiagramService(handle.spinner)
labelDisplay = Label("Diagram")
self.display = HTMLPanel("No circuit created.")
self.latex = TextArea()
buttonPanel = HorizontalPanel()
labelFormatting = Label("Formatting")
labelCheckbox = Label("Show: ")
self.checkboxValue = CheckBox("value")
self.checkboxValue.setID("CBXV1")
self.checkboxValue.addClickListener(self.onCirctuiTikzClick)
self.checkboxSymbol = CheckBox("symbol")
self.checkboxSymbol.setID("CBXS1")
self.checkboxSymbol.addClickListener(self.onCirctuiTikzClick)
checkboxPanel = HorizontalPanel()
checkboxPanel.add(labelCheckbox)
checkboxPanel.add(self.checkboxSymbol)
checkboxPanel.add(self.checkboxValue)
# layout
self.layout = VerticalPanel(HorizontalAlignment=HasAlignment.ALIGN_LEFT, Spacing=10)
self.layout.add(labelDisplay)
self.layout.add(self.display)
self.layout.add(Label("Circuitikz Markup"))
self.layout.add(self.latex)
self.layout.add(buttonPanel)
self.layout.add(labelFormatting)
self.layout.add(checkboxPanel)
RootPanel().add(self.layout)
# Set Default view
self.actCircuitTikzLock(lock=True)
def actClear(self):
self.latex.setText("")
self.layout.remove(self.display)
self.display = HTMLPanel("No circuit created.")
self.layout.insert(self.display, 1)
def onMenuResume(self):
self.remoteService.session_resume(self._handle)
def onCirctuiTikzClick(self, sender, event):
sendId = sender.getID()
if sendId == "CBXV1":
self.log.debug("click value")
self.remoteService.change_display(self._handle, "value", self.checkboxValue.getChecked())
elif sendId == "CBXS1":
self.log.debug("click symbol")
self.remoteService.change_display(self._handle, "symbol", self.checkboxSymbol.getChecked())
def onCircuitTikzSubmit(self):
self.log.debug("onCircuitTikzSubmit - entry")
self.remoteService.render_circuitikz(self._handle, self.latex.getText())
def actCircuitTikzSubmit(self, **kwargs):
id = kwargs.get("id")
app = "Circuit"
sessionId = getCookie("session_id")
image = "api/image?app=Diagram&tab=Circuit&Id=%d&Cache=%d" % (id, self._cacheBreaker)
self.layout.remove(self.display)
self.display = Image(image)
self.layout.insert(self.display, 1)
self._cacheBreaker = self._cacheBreaker + 1
def actCircuitTikzLock(self, **kwargs):
lock = bool(kwargs.get("lock"))
self.latex.setReadonly(lock)
self.latex.setStyleName("os-diagram-code-lock")
def actCircuitTikzSet(self, **kwargs):
latex = kwargs["latex"]
self.latex.setText(latex)
def actCircuitTikzFail(self):
pass
def actCircuitTikzDisplayUpdate(self, **kwargs):
symbol = kwargs.get("symbol", None)
value = kwargs.get("value", None)
if symbol != None:
self.checkboxSymbol.setChecked(symbol)
if value != None:
self.checkboxValue.setChecked(value)