コード例 #1
0
ファイル: messagecust.py プロジェクト: mightymau/hubspace
    def onRemoteResponse(self, response, request_info):
        mname = request_info.method
        if mname == "customize_message":
            showCustomizationResult(self, response, request_info)
            return

        if mname == "get_messagesdata_for_cust":
            locations_data = response["locations"]
            selectionbox = VerticalPanel(Padding=3)
            locations = ListBox()
            for (loc_name, loc_id) in locations_data:
                locations.addItem(loc_id, loc_name)
            messages = ListBox()
            messages.setName("locations")
            messages.addItem(location_select_label)
            for (name, d) in response["messages"].items():
                messages.addItem(d['label'], name)

            locations.addChangeListener(self)
            messages.addChangeListener(self)
            self.locations = locations
            self.messages = messages

            locationbox = HorizontalPanel()
            locationbox.add(Label("Location: ", StyleName="text", Width=80))
            locationbox.add(locations)

            msgnamebox = HorizontalPanel()
            msgnamebox.add(Label("Message: ", StyleName="text", Width=80))
            msgnamebox.add(messages)

            selectionbox.add(locationbox)
            selectionbox.add(msgnamebox)

            mainpanel = VerticalPanel(StyleName="dataBoxContent")
            mainpanel.add(selectionbox)
            self.mainpanel = mainpanel
            root = RootPanel()
            root.add(mainpanel)

        if mname == "get_messagecustdata":
            self.messages_data = response
            buttonspanel = FlowPanel(Spacing=1, Padding=1, Width=600)
            #buttonspanel.add(Label("Macros:", StyleName="text"))
            for macro_d in self.messages_data['macros']:
                macrobutton = Button(macro_d['label'], self, StyleName="buttonlikelink")#"nicebutton small")
                macrobutton.name = macro_d['name']
                buttonspanel.add(macrobutton)

            msgpanel = VerticalPanel(Padding=1, Spacing=1)
            messagebox = TextArea()
            messagebox.setCharacterWidth(70)
            height = len(self.messages_data["text"].split('\n')) + 1
            messagebox.setVisibleLines(height)
            messagebox.setText(self.messages_data["text"])
            messagebox.setName("textBoxFormElement")
            self.messagebox = messagebox
            msgpanel.add(messagebox)
            self.statusbar = Label(StyleName="errorMessage")
            msgpanel.add(self.statusbar)
            actionbuttons = HorizontalPanel(Spacing=2)
            updatebutton = Button("Update", self, StyleName="nicebutton small yellow")
            updatebutton.name = "update"
            actionbuttons.add(updatebutton)
            #actionbuttons.add(Button("Send me a preview mail"))
            msgpanel.add(actionbuttons)

            editorbox = VerticalPanel(Padding=1)
            editorbox.add(buttonspanel)
            editorbox.add(msgpanel)
            editorpanel = CaptionPanel("Message editor", editorbox, Padding=1, StyleName="text")
            editorpanel.name = "editorpanel"
            self.editorpanel = editorpanel

            self.mainpanel.add(editorpanel)
コード例 #2
0
ファイル: main.py プロジェクト: antialize/djudge
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