当前位置: 首页>>代码示例>>Python>>正文


Python TextArea.addChangeListener方法代码示例

本文整理汇总了Python中pyjamas.ui.TextArea.TextArea.addChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Python TextArea.addChangeListener方法的具体用法?Python TextArea.addChangeListener怎么用?Python TextArea.addChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.ui.TextArea.TextArea的用法示例。


在下文中一共展示了TextArea.addChangeListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Wiki

# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import addChangeListener [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())
开发者ID:brodybits,项目名称:pyjs,代码行数:44,代码来源:Wiki.py

示例2: htmlElements

# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import addChangeListener [as 别名]
    def htmlElements(self, addList = None):
        if not self._htmlElements:
            h = HTML("<h1>Hello from %s</h1>" % location.getHref(), StyleName='font-s07em')
            p = HorizontalPanel(HTML('Valid/tested combinations'))
            grid = Grid(2,2)
            grid.setHTML(0, 0, "app")
            grid.setHTML(0, 1, "themes")
            grid.setHTML(1, 0, "a")
            grid.setHTML(1, 1, "0 - 1 - ff0000 - cms - pypress - wordpress")
            t = TextArea()
            t.addChangeListener(Index.onTextAreaChange)
            self._htmlElements = [['h', h], ['p', p], ['grid', grid], ['t', t]]   
            for i in range(len(self._htmlElements)):
                RootPanel().add(self._htmlElements[i][1])
        if addList:
            self._htmlElements+=addList
            for i in range(len(self._htmlElements)):
                RootPanel().add(addList[i][1])

        return self._htmlElements
开发者ID:molhokwai,项目名称:a,代码行数:22,代码来源:Index0.py

示例3: __init__

# 需要导入模块: from pyjamas.ui.TextArea import TextArea [as 别名]
# 或者: from pyjamas.ui.TextArea.TextArea import addChangeListener [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
开发者ID:antialize,项目名称:djudge,代码行数:83,代码来源:main.py


注:本文中的pyjamas.ui.TextArea.TextArea.addChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。