Example #1
0
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("")
Example #2
0
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("")
Example #3
0
    def __init__(self):
        SimplePanel.__init__(self)

        field = TextArea()
        field.setCharacterWidth(20)
        field.setVisibleLines(4)
        self.add(field)
Example #4
0
 def __init__(self, panel,  text ='', left=0, top=0, width=0 , height=0, 
              color = None, background = None, click = None, focus = None):
     TextArea.__init__(self)#, text=text)
     self.panel = panel
     
     attrs = dict (position = 'absolute', left=dpx(left), top=dpx(top) ,
                   width=dpx(width) , height=dpx(height),
                   color = color, background = background)
     for key in attrs:
         if not attrs[key]: del(attrs[key])
     #self.setName(source)
     self.setText(text)
     self.setStyleAttribute(attrs)
     #self.setStyleAttribute({'position':'absolute',
     #    'top':'175px','left':'158px'
     #    ,'color':COLOR['maroon']
     #    ,'background':COLOR['peachpuff']
     #    ,'background-color':COLOR['peachpuff']})
     #self.setSize(width,height)
     #self.setReadonly('readonly')
     if click :
         self.addClickListener(click)
     if focus :
         self.addFocusListener(focus)
     self.panel.add(self)
Example #5
0
File: Text.py Project: Afey/pyjs
    def __init__(self):
        Sink.__init__(self)
        self.fPasswordText = PasswordTextBox()
        self.fTextArea = TextArea()
        self.fTextBox = TextBox()

        panel = VerticalPanel()
        panel.setSpacing(8)
        panel.add(HTML("Normal text box:"))
        panel.add(self.createTextThing(self.fTextBox))
        panel.add(HTML("Password text box:"))
        panel.add(self.createTextThing(self.fPasswordText))
        panel.add(HTML("Text area:"))
        panel.add(self.createTextThing(self.fTextArea))

        panel.add(HTML("""Textarea below demos oninput event. oninput allows
to detect when the content of an element has changed. This is different
from examples above, where changes are detected only if they are made with
keyboard. oninput occurs when the content is changed through any user
interface(keyboard, mouse, etc.). For example, at first type few chars, but
then paste some text to the text areas above and below by selecting 'Paste'
command from context menu or by dragging&dropping and see the difference.
oninput is similar to onchange event, but onchange event fires only when a
text-entry widget loses focus."""))
        vp = VerticalPanel()
        self.echo = HTML()
        textArea = TextArea()
        vp.add(textArea)
        vp.add(self.echo)
        textArea.addInputListener(self)
        panel.add(vp)

        self.initWidget(panel)
Example #6
0
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))
Example #7
0
 def __init__(self, worksheet, cell_id, **kwargs):
     TextArea.__init__(self, **kwargs)
     self._worksheet = worksheet
     self._cell_id = cell_id
     self.addKeyboardListener(self)
     #self.addClickListener(self)
     self.addFocusListener(self)
     self.set_rows(1)
     self.setCharacterWidth(80)
Example #8
0
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))
Example #9
0
    def __init__(self):
        VerticalPanel.__init__(self)
        self.setSpacing("10px")

        field = TextArea()
        field.setCharacterWidth(20)
        field.setVisibleLines(4)
        self.add(field)

        self.add(AutoTextArea(self))
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        if (self.item.resizable is True) or (self.item.height != -1.0):
            control = TextArea()
        else:
            control = TextBox()

        control.setEnabled(False)
        #        control.setStyleName( element = "color", style = WindowColor )

        self.control = control
        self.set_tooltip()
Example #11
0
class AMSSnoopStack:
    def onModuleLoad(self):
        global statusbar
        statusbar = Label()
        self.button = Button("Display Current Stack Frames", self)
        self.buttonupdate = Button("Update data from AMS publisher", self)

        buttons = HorizontalPanel()
        buttons.add(self.button)
        buttons.add(self.buttonupdate)
        buttons.setSpacing(8)

        info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>"""

        self.panel = VerticalPanel()
        self.panel.add(HTML(info))
        self.panel.add(buttons)
        self.panel.add(statusbar)
        RootPanel().add(self.panel)
        self.commobj = AMS.AMS_Comm()
        self.textarea = None

    def onClick(self, sender):
        global statusbar, boxes
        statusbar.setText('Button pressed')
        pass
        if sender == self.buttonupdate:
            self.commobj = AMS.AMS_Comm()
            statusbar.setText(
                'Updating data: Press Display list button to refesh')
        if sender == self.button:
            if AMS.sent > AMS.recv:
                statusbar.setText('Press button again: sent ' + str(AMS.sent) +
                                  ' recv ' + str(AMS.recv))
            if self.commobj.commname == 'No AMS publisher running' or not self.commobj.commname or self.commobj.comm == -1:
                if self.textarea: self.panel.remove(self.textarea)
                pass
            else:
                statusbar.setText('Memories for AMS Comm: ' +
                                  self.commobj.commname)
                result = self.commobj.get_memory_list()
                if self.textarea: self.panel.remove(self.textarea)
                self.textarea = TextArea()
                memory = self.commobj.memory_attach("Stack")
                size = memory.get_field_info("current size")
                functions = memory.get_field_info("functions")
                funcs = '\n'.join(functions[4])
                self.textarea.setText(str(funcs))
                self.textarea.setVisibleLines(size[4])
                self.panel.add(self.textarea)
Example #12
0
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']))
Example #13
0
    def __init__(self, app):
        self.app = app
        DialogWindow.__init__(
            self, modal=False,
            minimize=True, maximize=True, close=True,
        )
        self.closeButton = Button("Close", self)
        self.saveButton = Button("Save", self)
        self.setText("Sample DialogWindow with embedded image")
        self.msg = HTML("", True)

        global _editor_id
        _editor_id += 1
        editor_id = "editor%d" % _editor_id

        #self.ht = HTML("", ID=editor_id)
        self.txt = TextArea(Text="", VisibleLines=30, CharacterWidth=80,
                        ID=editor_id)
        dock = DockPanel()
        dock.setSpacing(4)

        hp = HorizontalPanel(Spacing="5")
        hp.add(self.saveButton)
        hp.add(self.closeButton)

        dock.add(hp, DockPanel.SOUTH)
        dock.add(self.msg, DockPanel.NORTH)
        dock.add(self.txt, DockPanel.CENTER)

        dock.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(self.txt, "100%")
        dock.setWidth("100%")
        self.setWidget(dock)
        self.editor_id = editor_id
        self.editor_created = False
Example #14
0
    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.methods = [self.METHOD_ECHO, self.METHOD_REVERSE, self.METHOD_UPPERCASE, self.METHOD_LOWERCASE]

        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)
Example #15
0
 def __init__(self, remove_callback):
     self._remove_callback = remove_callback
     self.dimension = None
     self.panel = VerticalPanel()
     self.panel.add(
         HTML(
             "Enter the mapping between coordinates and weights.  "
             "Each line must be <b>comma-separated list of coordinates</b> "
             "followed by a <b>colon</b> and a <b>weight value</b>.  "
             "Spaces are ignored.<br/>"
             "Example line: <code>1,2,5: 0.7</code>."))
     self._text = TextArea(CharacterWidth=20, VisibleLines=8)
     self.panel.add(self._text)
     link = Hyperlink("remove", StyleName="action")
     link.addClickListener(getattr(self, '_remove'))
     self.panel.add(link)
Example #16
0
class ProjectionDependentWeights(object):
    NAME = 'Projection-Dependent Weights'

    def __init__(self, remove_callback):
        self._remove_callback = remove_callback
        self.dimension = None
        self.panel = VerticalPanel()
        self.panel.add(
            HTML(
                "Enter the mapping between coordinates and weights.  "
                "Each line must be <b>comma-separated list of coordinates</b> "
                "followed by a <b>colon</b> and a <b>weight value</b>.  "
                "Spaces are ignored.<br/>"
                "Example line: <code>1,2,5: 0.7</code>."))
        self._text = TextArea(CharacterWidth=20, VisibleLines=8)
        self.panel.add(self._text)
        link = Hyperlink("remove", StyleName="action")
        link.addClickListener(getattr(self, '_remove'))
        self.panel.add(link)

    def as_arg(self):
        arg = 'projection-dependent'
        for line in self._text.getText().strip().replace(' ', '').split('\n'):
            arg += ':' + line.strip()
        return arg

    # private methods

    def _remove(self):
        self._remove_callback(self)
Example #17
0
    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)
Example #18
0
 def onClick(self, sender):
     global statusbar,boxes
     statusbar.setText('Button pressed')
     pass
     if sender == self.buttonupdate:
         self.commobj = AMS.AMS_Comm()
         statusbar.setText('Updating data: Press Display list button to refesh')
     if sender == self.button:
         if AMS.sent > AMS.recv:
            statusbar.setText('Press button again: sent '+str(AMS.sent)+' recv '+str(AMS.recv))
         if self.commobj.commname == 'No AMS publisher running' or not self.commobj.commname or  self.commobj.comm == -1:
            if self.textarea: self.panel.remove(self.textarea)
            pass
         else:
            statusbar.setText('Memories for AMS Comm: '+self.commobj.commname)
            result = self.commobj.get_memory_list()
            if self.textarea: self.panel.remove(self.textarea)
            self.textarea = TextArea()
            memory = self.commobj.memory_attach("Stack")
            size = memory.get_field_info("current size")
            functions = memory.get_field_info("functions")
            funcs = '\n'.join(functions[4])
            self.textarea.setText(str(funcs))
            self.textarea.setVisibleLines(size[4])
            self.panel.add(self.textarea)
Example #19
0
class AMSSnoopStack:
    def onModuleLoad(self):
        global statusbar
        statusbar = Label()
        self.button = Button("Display Current Stack Frames", self)
        self.buttonupdate = Button("Update data from AMS publisher", self)

        buttons = HorizontalPanel()
        buttons.add(self.button)
        buttons.add(self.buttonupdate)
        buttons.setSpacing(8)

        info = """<p>This example demonstrates the calling of the Memory Snooper in PETSc with Pyjamas and <a href="http://json-rpc.org/">JSON-RPC</a>.</p>"""

        self.panel = VerticalPanel()
        self.panel.add(HTML(info))
        self.panel.add(buttons)
        self.panel.add(statusbar)
        RootPanel().add(self.panel)
        self.commobj = AMS.AMS_Comm()
        self.textarea = None

    def onClick(self, sender):
        global statusbar,boxes
        statusbar.setText('Button pressed')
        pass
        if sender == self.buttonupdate:
            self.commobj = AMS.AMS_Comm()
            statusbar.setText('Updating data: Press Display list button to refesh')
        if sender == self.button:
            if AMS.sent > AMS.recv:
               statusbar.setText('Press button again: sent '+str(AMS.sent)+' recv '+str(AMS.recv))
            if self.commobj.commname == 'No AMS publisher running' or not self.commobj.commname or  self.commobj.comm == -1:
               if self.textarea: self.panel.remove(self.textarea)
               pass
            else:
               statusbar.setText('Memories for AMS Comm: '+self.commobj.commname)
               result = self.commobj.get_memory_list()
               if self.textarea: self.panel.remove(self.textarea)
               self.textarea = TextArea()
               memory = self.commobj.memory_attach("Stack")
               size = memory.get_field_info("current size")
               functions = memory.get_field_info("functions")
               funcs = '\n'.join(functions[4])
               self.textarea.setText(str(funcs))
               self.textarea.setVisibleLines(size[4])
               self.panel.add(self.textarea)
Example #20
0
    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)
Example #21
0
    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)
Example #22
0
 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)
Example #23
0
    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
Example #24
0
    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()
Example #25
0
    def __init__(self, app):
        self.app = app
        DialogWindow.__init__(
            self,
            modal=False,
            minimize=True,
            maximize=True,
            close=True,
        )
        self.closeButton = Button("Close", self)
        self.saveButton = Button("Save", self)
        self.setText("Sample DialogWindow with embedded image")
        self.msg = HTML("", True)

        global _editor_id
        _editor_id += 1
        editor_id = "editor%d" % _editor_id

        #self.ht = HTML("", ID=editor_id)
        self.txt = TextArea(Text="",
                            VisibleLines=30,
                            CharacterWidth=80,
                            ID=editor_id)
        dock = DockPanel()
        dock.setSpacing(4)

        hp = HorizontalPanel(Spacing="5")
        hp.add(self.saveButton)
        hp.add(self.closeButton)

        dock.add(hp, DockPanel.SOUTH)
        dock.add(self.msg, DockPanel.NORTH)
        dock.add(self.txt, DockPanel.CENTER)

        dock.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(self.txt, "100%")
        dock.setWidth("100%")
        self.setWidget(dock)
        self.editor_id = editor_id
        self.editor_created = False
Example #26
0
    def __init__(self):
        SimplePanel.__init__(self)

        field = TextArea()
        field.setCharacterWidth(20)
        field.setVisibleLines(4)
        self.add(field)
Example #27
0
 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)
Example #28
0
    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)
Example #29
0
 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()
Example #30
0
    def __init__(self):
        Sink.__init__(self)
        self.fPasswordText = PasswordTextBox()
        self.fTextArea = TextArea()
        self.fTextBox = TextBox()

        panel = VerticalPanel()
        panel.setSpacing(8)
        panel.add(HTML("Normal text box:"))
        panel.add(self.createTextThing(self.fTextBox))
        panel.add(HTML("Password text box:"))
        panel.add(self.createTextThing(self.fPasswordText))
        panel.add(HTML("Text area:"))
        panel.add(self.createTextThing(self.fTextArea))
        self.initWidget(panel)
Example #31
0
    def __init__(self):
        VerticalPanel.__init__(self)
        self.setSpacing("10px")

        field = TextArea()
        field.setCharacterWidth(20)
        field.setVisibleLines(4)
        self.add(field)

        self.add(AutoTextArea(self))
Example #32
0
    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)
Example #33
0
class Editor:
    def __init__(self, db_url, parent_panel):
        self.db_url = db_url
        self.doc_id = None
        self.parent_panel = parent_panel

    def loadDocument(self, doc_id):
        # Load document into editor
        HTTPRequest().asyncGet(None, None, url=self.db_url+doc_id,
                                handler=DocLoader(self))
    def reloadDocument(self):
        if self.doc_id is None:
            Window.Alert('Trying to reload blank doc')
        else:
            self.loadDocument(self.doc_id)

    def updateDoc(self, json):
        doc_obj = JSONParser().decode(json)
        self.doc_id = doc_obj['_id']
        self.id_label.setText('ID : %s'%doc_obj['_id'])
        self.rev_label.setText('REV: %s'%doc_obj['_rev'])
        self.save_button.setEnabled(True)
        self.doc_area.setText(json)
        self.doc_area.setEnabled(True)
        self.doc_area.setFocus(True)

    def saveDocument(self):
        self.doc_area.setEnabled(False)
        self.save_button.setEnabled(False)
        HTTPRequest().asyncPut(None, None, url=self.db_url+self.doc_id,
                                postData=self.doc_area.getText(),
                                handler=DocSaver(self))

    def onModuleLoad(self):
        # Editor
        self.editor_panel = VerticalPanel()
        self.id_label = Label('ID: ')
        self.editor_panel.add(self.id_label)
        self.rev_label = Label('REV: ')
        self.editor_panel.add(self.rev_label)
        self.doc_area = TextArea()
        self.doc_area.setCharacterWidth(80)
        self.doc_area.setVisibleLines(24)
        self.doc_area.setEnabled(False)
        self.editor_panel.add(self.doc_area)
        self.parent_panel.add(self.editor_panel)

        # Buttons
        self.button_panel = HorizontalPanel()
        self.save_button = Button("Save", self.saveDocument)
        self.save_button.setEnabled(False)
        self.button_panel.add(self.save_button)
        self.parent_panel.add(self.button_panel)
Example #34
0
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)
Example #35
0
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)
Example #36
0
    def __init__ (self, **kwargs):
        ZillaWindow.__init__(self, kwargs)
        FocusPanel.__init__(self, kwargs)

        area1 = TextArea()
        area1.setText("Zakładka 1")

        area2 = TextArea()
        area2.setText("Zakładka 2")

        area3 = TextArea()
        area3.setText("Zakładka 2")

        tabs = TabPanel()
        tabs.add(area2, tabText="Gra nr 1")
        tabs.add(area1, tabText="Pokój gier")
        tabs.add(area3, tabText="Pokój gier")

        self.add (tabs)

        lwindow = LoginWindow(centered=True)
        lwindow.setPopupPosition (100, 100)
        lwindow.show()
Example #37
0
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())
Example #38
0
 def __init__(self, handle, idx, image, variables = None, code = None, 
              perspective = '', checkOptions = [False, True]):
     VerticalPanel.__init__(self)
     self._handle = handle
     self.idx = idx
     # set style
     self.setStyleName('os-mech-drawing')  
     # create widgets
     self._img = Image(image)
     self._img.setStyleName('os-mech-thumb')
     self._img.addClickListener(self.onClickDrawing)
     self._perspective = '%d - %s'%(idx, perspective.capitalize())
     self._optionPanel = MechOptionPanel(handle, idx, checkOptions)
     textArea  = TextArea(code)
     textArea.setText(code)
     textArea.setStyleName('os-mech-code-locked')
     textArea.setReadonly(self, True)
     # populate drawing
     self.add(self._img)
     self.add(self._optionPanel)
     self.add(textArea)
Example #39
0
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.writebr('remote error! ' + str(message))
        log.writebr('remote error! ' + str(request_info))

    def onKeyUp(self, sender, keycode, modifiers):
        if sender == self.t:
            self.h.setHTML(self.t.getText())
Example #40
0
    def onModuleLoad(self):
        # Editor
        self.editor_panel = VerticalPanel()
        self.id_label = Label('ID: ')
        self.editor_panel.add(self.id_label)
        self.rev_label = Label('REV: ')
        self.editor_panel.add(self.rev_label)
        self.doc_area = TextArea()
        self.doc_area.setCharacterWidth(80)
        self.doc_area.setVisibleLines(24)
        self.doc_area.setEnabled(False)
        self.editor_panel.add(self.doc_area)
        self.parent_panel.add(self.editor_panel)

        # Buttons
        self.button_panel = HorizontalPanel()
        self.save_button = Button("Save", self.saveDocument)
        self.save_button.setEnabled(False)
        self.button_panel.add(self.save_button)
        self.parent_panel.add(self.button_panel)
Example #41
0
    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)
Example #42
0
    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)
Example #43
0
    This function is used to make buttons for allowing more computation time,
    step by step, in reduceterm().    
    """

    orders = 0
    while prevmaxlines >= 10:
        orders += 1
        prevmaxlines /= 10
    if prevmaxlines >= 3:
        maxlines = 10
    else:
        maxlines = 3
    for _ in range(orders):
        maxlines *= 10
    return maxlines


if __name__ == '__main__':
    b = Button("Reduce", queuereduce)
    RootPanel("buttons").add(b)
    fileChooser = makeFileChooser()
    RootPanel("file-chooser").add(fileChooser)
    RootPanel("loading-notify").setVisible(False)
    inputArea = TextArea(VisibleLines=5, CharacterWidth=80)
    RootPanel("input").add(inputArea)
    outputPanel = RootPanel("output")
    loadFile('called from main')
    showOutputMeta(BEGINMESSAGES, iswidgetlist=True)
    b.setFocus(True)
Example #44
0
 def __init__(self, doneHandler):
     TextArea.__init__(self)
     self.doneHandler = doneHandler  #this handler will be called when user press ctrl-enter
Example #45
0
 def setText(self, text):
     TextArea.setText(self, text)
     self.autoHeight()
Example #46
0
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:
        #     {
        #       'code': jsonrpc-error-code (integer) ,
        #       'message': jsonrpc-error-message (string) ,
        #       'data' : extra-error-data
        #     }
        message = errobj['message']
        if code != 0:
            self.status.setText("HTTP error %d: %s" % (code, message))
        else:
            code = errobj['code']
            self.status.setText("JSONRPC Error %s: %s" % (code, message))
Example #47
0
 def __init__(self, name, help):
     widget = TextArea()
     widget.setCharacterWidth(72)
     widget.setStyleName('form-control')
     widget.setVisibleLines(5)
     Form_Row.__init__(self, name, widget, help=help)
Example #48
0
class SelectionTest:
    def onSelectionChange(self, selection):
        self.refresh(selection)

    """*
    * This is the entry point method.
    """

    def onModuleLoad(self):
        dlp = DockPanel(Width="100%", Height="100%")

        self.m_rte = RichTextArea(Width="500px", Height="400px")
        self.m_tb = RichTextToolbar(self.m_rte, self)

        buts = FlowPanel()
        self.m_getCurr = Button("Refresh v", self)
        self.m_setHtml = Button("Set html ^", self)
        self.m_setHtml.setTitle("Set html from the lower left text area")
        self.m_toSCursor = Button("< To Cursor", self)
        self.m_toSCursor.setTitle(
            "Set the selection to be a cursor at the beginning of the current selection"
        )
        self.m_toECursor = Button("To Cursor >", self)
        self.m_toECursor.setTitle(
            "Set the selection to be a cursor at the end of the current selection"
        )
        self.m_surround1 = Button("Surround1", self)
        self.m_surround2 = Button("Surround2", self)
        self.m_font1 = Button("Times New Roman", self)
        self.m_font2 = Button("Arial", self)

        grid = Grid(2, 2)
        self.m_startNode = self.createTextBox(1)
        self.m_startOffset = self.createTextBox(3)
        self.m_endNode = self.createTextBox(4)
        self.m_endOffset = self.createTextBox(5)
        self.m_select = Button("`>Select", self)
        self.m_select.setTitle("Select the texts/offsets in the boxes above")
        self.m_cursor = Button("`>Cursor", self)
        self.m_cursor.setTitle(
            "Set cursor to text/offset of top 2 boxes above")
        grid.setWidget(0, 0, self.m_startNode)
        grid.setWidget(0, 1, self.m_startOffset)
        grid.setWidget(1, 0, self.m_endNode)
        grid.setWidget(1, 1, self.m_endOffset)

        self.m_deleteSel = Button("Delete", self)
        self.m_reset = Button("Reset", self)

        buts.add(self.m_getCurr)
        buts.add(self.m_setHtml)
        buts.add(self.m_toSCursor)
        buts.add(self.m_toECursor)
        buts.add(self.m_font1)
        buts.add(self.m_font2)
        buts.add(self.m_surround1)
        buts.add(self.m_surround2)
        buts.add(grid)
        buts.add(self.m_select)
        buts.add(self.m_cursor)

        buts.add(self.m_deleteSel)
        buts.add(self.m_reset)

        dlp.add(buts, DockPanel.WEST)

        textPanels = DockPanel()

        self.m_html = TextArea()
        self.m_html.setSize("100%", "100%")
        self.m_sel = TextArea()
        self.m_sel.setSize("100%", "100%")

        textPanels.add(self.m_sel, DockPanel.EAST)
        textPanels.add(self.m_html, DockPanel.WEST)

        dlp.add(textPanels, DockPanel.SOUTH)
        dlp.add(self.m_tb, DockPanel.NORTH)
        dlp.add(self.m_rte, DockPanel.CENTER)

        rp = RootPanel.get()
        rp.add(dlp)

        DeferredCommand.add(getattr(self, "set_html_focus"))

        self.reset()

    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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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)
Example #49
0
    def onModuleLoad(self):
        dlp = DockPanel(Width="100%", Height="100%")

        self.m_rte = RichTextArea(Width="500px", Height="400px")
        self.m_tb = RichTextToolbar(self.m_rte, self)

        buts = FlowPanel()
        self.m_getCurr = Button("Refresh v", self)
        self.m_setHtml = Button("Set html ^", self)
        self.m_setHtml.setTitle("Set html from the lower left text area")
        self.m_toSCursor = Button("< To Cursor", self)
        self.m_toSCursor.setTitle(
            "Set the selection to be a cursor at the beginning of the current selection"
        )
        self.m_toECursor = Button("To Cursor >", self)
        self.m_toECursor.setTitle(
            "Set the selection to be a cursor at the end of the current selection"
        )
        self.m_surround1 = Button("Surround1", self)
        self.m_surround2 = Button("Surround2", self)
        self.m_font1 = Button("Times New Roman", self)
        self.m_font2 = Button("Arial", self)

        grid = Grid(2, 2)
        self.m_startNode = self.createTextBox(1)
        self.m_startOffset = self.createTextBox(3)
        self.m_endNode = self.createTextBox(4)
        self.m_endOffset = self.createTextBox(5)
        self.m_select = Button("`>Select", self)
        self.m_select.setTitle("Select the texts/offsets in the boxes above")
        self.m_cursor = Button("`>Cursor", self)
        self.m_cursor.setTitle(
            "Set cursor to text/offset of top 2 boxes above")
        grid.setWidget(0, 0, self.m_startNode)
        grid.setWidget(0, 1, self.m_startOffset)
        grid.setWidget(1, 0, self.m_endNode)
        grid.setWidget(1, 1, self.m_endOffset)

        self.m_deleteSel = Button("Delete", self)
        self.m_reset = Button("Reset", self)

        buts.add(self.m_getCurr)
        buts.add(self.m_setHtml)
        buts.add(self.m_toSCursor)
        buts.add(self.m_toECursor)
        buts.add(self.m_font1)
        buts.add(self.m_font2)
        buts.add(self.m_surround1)
        buts.add(self.m_surround2)
        buts.add(grid)
        buts.add(self.m_select)
        buts.add(self.m_cursor)

        buts.add(self.m_deleteSel)
        buts.add(self.m_reset)

        dlp.add(buts, DockPanel.WEST)

        textPanels = DockPanel()

        self.m_html = TextArea()
        self.m_html.setSize("100%", "100%")
        self.m_sel = TextArea()
        self.m_sel.setSize("100%", "100%")

        textPanels.add(self.m_sel, DockPanel.EAST)
        textPanels.add(self.m_html, DockPanel.WEST)

        dlp.add(textPanels, DockPanel.SOUTH)
        dlp.add(self.m_tb, DockPanel.NORTH)
        dlp.add(self.m_rte, DockPanel.CENTER)

        rp = RootPanel.get()
        rp.add(dlp)

        DeferredCommand.add(getattr(self, "set_html_focus"))

        self.reset()
Example #50
0
class NewBlog:
    def onModuleLoad(self):
        loggedInUser = getCookie("LoggedInUser")
        loggedInUserJsonData = json.loads(loggedInUser)

        self.username = loggedInUserJsonData["username"]

        self.remote_py = MyBlogService()

        dockPanel = DockPanel(BorderWidth=0,
                              Padding=0,
                              HorizontalAlignment=HasAlignment.ALIGN_CENTER,
                              VerticalAlignment=HasAlignment.ALIGN_MIDDLE)

        dockPanel.setSize('100%', '100%')

        headerDockPanel = DockPanel(
            BorderWidth=0,
            Padding=0,
            HorizontalAlignment=HasAlignment.ALIGN_LEFT,
            VerticalAlignment=HasAlignment.ALIGN_CENTER)
        headerDockPanel.setStyleName('header')
        headerDockPanel.setWidth('100%')

        dockPanel.add(headerDockPanel, DockPanel.NORTH)
        dockPanel.setCellHeight(headerDockPanel, '60px')

        self.siteImage = Image("/images/Testware_logo.png")
        self.siteImage.setStyleName('logo-image')
        headerDockPanel.add(self.siteImage, DockPanel.WEST)
        headerDockPanel.setCellWidth(self.siteImage, '30%')

        self.pageTitle = Label('New Blog')
        self.pageTitle.setStyleName('center-header')
        headerDockPanel.add(self.pageTitle, DockPanel.CENTER)
        headerDockPanel.setCellWidth(self.pageTitle, '40%')

        rightHeaderPanel = VerticalPanel(StyleName='right-header')
        headerDockPanel.add(rightHeaderPanel, DockPanel.EAST)
        headerDockPanel.setCellWidth(rightHeaderPanel, '30%')

        welcomeNoteLabel = Label('Hi %s %s!' %
                                 (loggedInUserJsonData["first_name"],
                                  loggedInUserJsonData["last_name"]))
        rightHeaderPanel.add(welcomeNoteLabel)

        logoutAnchor = Anchor(Widget=HTML('Logout'), Href='/', Title='Logout')
        logoutAnchor.setStyleName('logout')
        rightHeaderPanel.add(logoutAnchor)

        panel = HorizontalPanel(StyleName="header2")
        dockPanel.add(panel, DockPanel.NORTH)
        dockPanel.setCellHeight(panel, '50px')

        self.blogTitle = TextBox()
        self.blogTitle.setStyleName('blog-title')
        self.blogTitle.setPlaceholder("Blog Title")
        panel.add(self.blogTitle)

        self.blogContent = TextArea()
        self.blogContent.setStyleName('blog-content')

        dockPanel.add(self.blogContent, DockPanel.CENTER)
        createBlogButton = Button("Create Blog", self)
        createBlogButton.setStyleName('btn')
        panel.add(createBlogButton)

        RootPanel().add(dockPanel)

    def onClick(self, sender):
        self.createBlog()

    def createBlog(self):
        self.remote_py.callMethod('createBlog', [
            self.blogTitle.getText(),
            self.blogContent.getText(), self.username
        ], self)

    def onRemoteResponse(self, response, requestInfo):
        Window.setLocation("/home.html")

    def onRemoteError(self, code, error_dict, requestInfo):
        if code == 401:
            self.errorlabel.setText("Invalid Credentials. Please try again.")
Example #51
0
 def __init__(self, doneHandler):
     TextArea.__init__(self)
     self.doneHandler = doneHandler #this handler will be called when user press ctrl-enter
Example #52
0
 def setText(self, text):
     TextArea.setText(self, text)
     self.autoHeight()
Example #53
0
    def __init__(self, **kwargs):
        ZillaWindow.__init__(self, kwargs)
        FocusPanel.__init__(self, kwargs)

        area1 = TextArea()
        area1.setText("Zakładka 1")

        area2 = TextArea()
        area2.setText("Zakładka 2")

        area3 = TextArea()
        area3.setText("Zakładka 2")

        tabs = TabPanel()
        tabs.add(area2, tabText="Gra nr 1")
        tabs.add(area1, tabText="Pokój gier")
        tabs.add(area3, tabText="Pokój gier")

        self.add(tabs)

        lwindow = LoginWindow(centered=True)
        lwindow.setPopupPosition(100, 100)
        lwindow.show()
Example #54
0
    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)
Example #55
0
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)
Example #56
0
    def onModuleLoad(self):
        loggedInUser = getCookie("LoggedInUser")
        loggedInUserJsonData = json.loads(loggedInUser)

        self.username = loggedInUserJsonData["username"]

        self.remote_py = MyBlogService()

        dockPanel = DockPanel(BorderWidth=0,
                              Padding=0,
                              HorizontalAlignment=HasAlignment.ALIGN_CENTER,
                              VerticalAlignment=HasAlignment.ALIGN_MIDDLE)

        dockPanel.setSize('100%', '100%')

        headerDockPanel = DockPanel(
            BorderWidth=0,
            Padding=0,
            HorizontalAlignment=HasAlignment.ALIGN_LEFT,
            VerticalAlignment=HasAlignment.ALIGN_CENTER)
        headerDockPanel.setStyleName('header')
        headerDockPanel.setWidth('100%')

        dockPanel.add(headerDockPanel, DockPanel.NORTH)
        dockPanel.setCellHeight(headerDockPanel, '60px')

        self.siteImage = Image("/images/Testware_logo.png")
        self.siteImage.setStyleName('logo-image')
        headerDockPanel.add(self.siteImage, DockPanel.WEST)
        headerDockPanel.setCellWidth(self.siteImage, '30%')

        self.pageTitle = Label('New Blog')
        self.pageTitle.setStyleName('center-header')
        headerDockPanel.add(self.pageTitle, DockPanel.CENTER)
        headerDockPanel.setCellWidth(self.pageTitle, '40%')

        rightHeaderPanel = VerticalPanel(StyleName='right-header')
        headerDockPanel.add(rightHeaderPanel, DockPanel.EAST)
        headerDockPanel.setCellWidth(rightHeaderPanel, '30%')

        welcomeNoteLabel = Label('Hi %s %s!' %
                                 (loggedInUserJsonData["first_name"],
                                  loggedInUserJsonData["last_name"]))
        rightHeaderPanel.add(welcomeNoteLabel)

        logoutAnchor = Anchor(Widget=HTML('Logout'), Href='/', Title='Logout')
        logoutAnchor.setStyleName('logout')
        rightHeaderPanel.add(logoutAnchor)

        panel = HorizontalPanel(StyleName="header2")
        dockPanel.add(panel, DockPanel.NORTH)
        dockPanel.setCellHeight(panel, '50px')

        self.blogTitle = TextBox()
        self.blogTitle.setStyleName('blog-title')
        self.blogTitle.setPlaceholder("Blog Title")
        panel.add(self.blogTitle)

        self.blogContent = TextArea()
        self.blogContent.setStyleName('blog-content')

        dockPanel.add(self.blogContent, DockPanel.CENTER)
        createBlogButton = Button("Create Blog", self)
        createBlogButton.setStyleName('btn')
        panel.add(createBlogButton)

        RootPanel().add(dockPanel)
Example #57
0
class EditDialogWindow(DialogWindow):
    def __init__(self, app):
        self.app = app
        DialogWindow.__init__(
            self,
            modal=False,
            minimize=True,
            maximize=True,
            close=True,
        )
        self.closeButton = Button("Close", self)
        self.saveButton = Button("Save", self)
        self.setText("Sample DialogWindow with embedded image")
        self.msg = HTML("", True)

        global _editor_id
        _editor_id += 1
        editor_id = "editor%d" % _editor_id

        #self.ht = HTML("", ID=editor_id)
        self.txt = TextArea(Text="",
                            VisibleLines=30,
                            CharacterWidth=80,
                            ID=editor_id)
        dock = DockPanel()
        dock.setSpacing(4)

        hp = HorizontalPanel(Spacing="5")
        hp.add(self.saveButton)
        hp.add(self.closeButton)

        dock.add(hp, DockPanel.SOUTH)
        dock.add(self.msg, DockPanel.NORTH)
        dock.add(self.txt, DockPanel.CENTER)

        dock.setCellHorizontalAlignment(hp, HasAlignment.ALIGN_RIGHT)
        dock.setCellWidth(self.txt, "100%")
        dock.setWidth("100%")
        self.setWidget(dock)
        self.editor_id = editor_id
        self.editor_created = False

    def add_tinymce(self):

        # for storing the results when available
        iframe = DOM.createElement("iframe")
        DOM.setElemAttribute(iframe, "id", "__edit_%s" % self.editor_id)
        DOM.setElemAttribute(iframe, "style", "display:none")
        doc().body.appendChild(iframe)

        # activate tinymce
        new_script = DOM.createElement("script")
        new_script.innerHTML = """
tinyMCE.init({
        // General options
        mode : "textareas",
        theme : "simple",

        // Theme options
        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,|,table,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,
});
"""

        ih = """
var ed = new tinymce.Editor('%s',{
        mode : "none",
        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()