예제 #1
0
    def __init__(self,sandbox,assignmentId,hitId,workerId):
       

        self.mturk_form = FormPanel()
        # change this to sandbox url once ready for testing                           
        self.write_data = write_data

        if sandbox:
            self.mturk_form.setAction("https://workersandbox.mturk.com/mturk/externalSubmit")                                                                                   
        else:
            self.mturk_form.setAction("http://www.mturk.com/mturk/externalSubmit")
        

        self.mturk_form.setMethod(FormPanel.METHOD_POST)
        self.assignmentId = Hidden("assignmentId")
        self.hitId = Hidden("hitId")
        self.workerId = Hidden("workerId")
        self.assignmentId.setValue(assignmentId)
        self.hitId.setValue(hitId)
        self.workerId.setValue(workerId)
        self.vp = VerticalPanel()
        self.vp.add(self.assignmentId)
        self.vp.add(self.hitId)
        self.vp.add(self.workerId)

        self.mturk_form.add(self.vp)
예제 #2
0
 def add_data(self, data):
     """                                                                           
     Adds data -- takes as argument a list of pairs                                
     """
     for k, v in data:
         tmp = Hidden(k)
         tmp.setValue(v)
         self.vp.add(tmp)
예제 #3
0
 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()
예제 #4
0
파일: main.py 프로젝트: antialize/djudge
    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)
예제 #5
0
파일: main.py 프로젝트: antialize/djudge
class UploadProblemTab(EntityTab):
    def __init__(self,app):
        EntityTab.__init__(self, app)
        self.form = FormPanel()
        self.form.setEncoding("multipart/form-data")
        self.form.setMethod("post")
        self.table = FlexTable()
        self.table.setText(0,0,"Problem archive")
        self.file = FileUpload()
        self.file.setName("file");
        self.table.setWidget(0,1,self.file)
        self.form.setWidget(self.table)
        self.button = Button("Submit",self)
        self.table.setWidget(1,1, self.button)
        self.msg = HTML("<b>Uploading</b>")
        self.msg.setVisible(False)
        self.cookie = Hidden()
        self.cookie.setName("cookie")
        self.table.setWidget(2,0, self.cookie)
        self.table.setWidget(2,1, self.msg)
        self.form.setWidget(self.table)
        self.form.setAction("../upload.py/problem")
        self.add("Upload new problem")

    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
예제 #6
0
    def __init__(self):
        SimplePanel.__init__(self)

        self.form = FormPanel()
        self.form.setAction("http://google.com/search")
        self.form.setTarget("results")

        panel = VerticalPanel()
        panel.add(Hidden("q", "python pyjamas"))
        panel.add(Button("Search", getattr(self, "onBtnClick")))

        results = NamedFrame("results")
        panel.add(results)

        self.form.add(panel)
        self.add(self.form)
예제 #7
0
파일: main.py 프로젝트: antialize/djudge
 def __init__(self,app):
     EntityTab.__init__(self, app)
     self.form = FormPanel()
     self.form.setEncoding("multipart/form-data")
     self.form.setMethod("post")
     self.table = FlexTable()
     self.table.setText(0,0,"Problem archive")
     self.file = FileUpload()
     self.file.setName("file");
     self.table.setWidget(0,1,self.file)
     self.form.setWidget(self.table)
     self.button = Button("Submit",self)
     self.table.setWidget(1,1, self.button)
     self.msg = HTML("<b>Uploading</b>")
     self.msg.setVisible(False)
     self.cookie = Hidden()
     self.cookie.setName("cookie")
     self.table.setWidget(2,0, self.cookie)
     self.table.setWidget(2,1, self.msg)
     self.form.setWidget(self.table)
     self.form.setAction("../upload.py/problem")
     self.add("Upload new problem")
예제 #8
0
class MTurkOutput:
    """                                                                               
    This class encapsulated all that is germane to sending the results to MTurk       
    thus enabling the separating of the logic from the gui                            
    """
    def __init__(self,sandbox,assignmentId,hitId,workerId):
       

        self.mturk_form = FormPanel()
        # change this to sandbox url once ready for testing                           
        self.write_data = write_data

        if sandbox:
            self.mturk_form.setAction("https://workersandbox.mturk.com/mturk/externalSubmit")                                                                                   
        else:
            self.mturk_form.setAction("http://www.mturk.com/mturk/externalSubmit")
        

        self.mturk_form.setMethod(FormPanel.METHOD_POST)
        self.assignmentId = Hidden("assignmentId")
        self.hitId = Hidden("hitId")
        self.workerId = Hidden("workerId")
        self.assignmentId.setValue(assignmentId)
        self.hitId.setValue(hitId)
        self.workerId.setValue(workerId)
        self.vp = VerticalPanel()
        self.vp.add(self.assignmentId)
        self.vp.add(self.hitId)
        self.vp.add(self.workerId)

        self.mturk_form.add(self.vp)


    def add_data(self,data):
        """                                                                           
        Adds data -- takes as argument a list of pairs                                
        """
        for k,v in data:
            tmp = Hidden(k)
            tmp.setValue(v)
            self.vp.add(tmp)