예제 #1
0
    def openMultiInsertWindow(self, addButtons=True):
        """
        Creates a tkinter form using Forms classes. This form aims to insert many Defects
        Args:
            addButtons: boolean value indicating that insertion buttons should be visible. Default to True
        """
        settings = self.mainApp.settings
        settings.reloadSettings()
        results, msg = APIClient.searchDefect("")
        default_values = {}

        if results is not None:
            for result in results:
                if result is not None:
                    default_values[result["title"]] = result["risk"]
            self.browse_top_treevw = self.form.addFormTreevw(
                "Defects", ("Title", "Risk"),
                default_values,
                side="top",
                fill="both",
                width=400,
                height=8,
                status="readonly",
                binds={
                    "<Double-Button-1>": self.doubleClickDefectView,
                    "<Delete>": self.deleteDefectTemplate
                })
        self.buttonUpImage = ImageTk.PhotoImage(
            Image.open(Utils.getIconDir() + 'up-arrow.png'))
        self.buttonDownImage = ImageTk.PhotoImage(
            Image.open(Utils.getIconDir() + 'down-arrow.png'))
        # use self.buttonPhoto
        buttonPan = self.form.addFormPanel(side="top",
                                           anchor="center",
                                           fill="none")
        btn_down = buttonPan.addFormButton("V",
                                           self.moveDownMultiTreeview,
                                           side="left",
                                           anchor="center",
                                           image=self.buttonDownImage)
        btn_down = buttonPan.addFormButton("Î",
                                           self.moveUpMultiTreeview,
                                           side="right",
                                           anchor="center",
                                           image=self.buttonUpImage)
        default_values = {}
        self.browse_down_treevw = self.form.addFormTreevw("Defects",
                                                          ("Title", "Risk"),
                                                          default_values,
                                                          side="bottom",
                                                          fill="both",
                                                          width=400,
                                                          height=8,
                                                          status="readonly")
        if addButtons:
            self.completeInsertWindow()
        else:
            self.showForm()
예제 #2
0
 def multi_insert(self):
     values = self.browse_down_treevw.getValue()
     for title in values:
         results, msg = APIClient.searchDefect(title)
         if results is not None:
             result = results[0]
             d_o = Defect()
             types = result["type"].split(",")
             d_o.initialize("", "", "", result["title"],
                            result["synthesis"], result["description"],
                            result["ease"], result["impact"],
                            result["risk"], "N/A", types,
                            result["language"], "", result["fixes"])
             d_o.addInDb()
         else:
             tk.messagebox.showerror("Could not saerch defect", msg)
     return True