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()
def __init__(self, parent, settings): """ Constructor """ self.dashboardFrame = None self.parent = None self.treevw = None self.style = None self.ips = None self.ports = None self.tools = None iconPath = Utils.getIconDir() self.icons = {} self.icons["tool"] = ImageTk.PhotoImage( Image.open(iconPath + "tool.png")) self.icons["cross"] = ImageTk.PhotoImage( Image.open(iconPath + "cross.png")) self.icons["running"] = ImageTk.PhotoImage( Image.open(iconPath + "running.png")) self.icons["done"] = ImageTk.PhotoImage( Image.open(iconPath + "done_tool.png")) self.icons["error"] = ImageTk.PhotoImage( Image.open(iconPath + "error_tool.png")) self.icons["ready"] = ImageTk.PhotoImage( Image.open(iconPath + "waiting.png")) self.icons["Not ready"] = ImageTk.PhotoImage( Image.open(iconPath + "cross.png"))
def openModifyWindow(self, addButtons=True): """ Creates a tkinter form using Forms classes. This form aims to update or delete an existing Defect Args: addButtons: boolean value indicating that insertion buttons should be visible. Default to True """ modelData = self.controller.getData() topPanel = self.form.addFormPanel(grid=True) topPanel.addFormSearchBar("Search Remark", APIClient.searchRemark, topPanel, row=0, column=1, autofocus=False) self.imgTypeForm = topPanel.addFormImage( Utils.getIconDir() + RemarkView.getIconName(modelData["type"]), row=1) self.comboTypeForm = topPanel.addFormCombo( "Type", ["Positive", "Neutral", "Negative"], column=1, row=1, default=modelData["type"], binds={"<<ComboboxSelected>>": self.updateImage}) topPanel.addFormStr("Title", r".+", modelData["title"], width=50, row=1, column=2) if addButtons: self.completeModifyWindow() else: self.showForm()
def updateImage(self, _event=None): """Callback when ease or impact is modified. Calculate new resulting risk value Args _event: mandatory but not used """ typeof = self.comboTypeForm.getValue() self.imgTypeForm.setImage(Utils.getIconDir() + RemarkView.getIconName(typeof))
def getIcon(cls, typeOfRemark): """ Load the object icon in cache if it is not yet done, and returns it Return: Returns the icon representing this object. """ cache = cls.cached_icons.get(typeOfRemark, None) if cache is None: from PIL import Image, ImageTk path = Utils.getIconDir() + cls.getIconName(typeOfRemark) cls.cached_icons[typeOfRemark] = ImageTk.PhotoImage( Image.open(path)) return cls.cached_icons[typeOfRemark] return cache
def initUI(self, parent): """ Initialize window and widgets. """ if self.parent is not None: # Already initialized self.reset() self.fillWithFixes() return self.parent = parent ###Fixes TABLE ### self.rowHeight = 20 self.style = ttk.Style() self.style.configure('Report.Treeview', rowheight=self.rowHeight) # FIXES TREEVW fixesLabelFrame = ttk.LabelFrame(parent, text="Fixes table") self.paned = tk.PanedWindow(fixesLabelFrame, orient=tk.VERTICAL, height=400) self.frameTw = ttk.Frame(self.paned) self.treevw = ttk.Treeview(self.frameTw, style='Report.Treeview', height=0) self.treevw['columns'] = ('execution', 'gain') self.treevw.heading("#0", text='Title', anchor=tk.W) self.treevw.column("#0", anchor=tk.W, width=150) self.treevw.heading('execution', text='Execution') self.treevw.column('execution', anchor='center', width=40) self.treevw.heading('gain', text='Gain') self.treevw.column('gain', anchor='center', width=40) self.treevw.bind("<Double-Button-1>", self.OnDoubleClick) self.treevw.bind("<Delete>", self.deleteSelectedItem) self.treevw.bind("<Alt-Down>", self.bDown) self.treevw.bind("<Alt-Up>", self.bUp) self.treevw.bind("<ButtonPress-1>", self.dragStart) self.treevw.bind("<ButtonRelease-1>", self.dragRelease, add='+') self.treevw.bind("<B1-Motion>", self.dragMove, add='+') self.treevw.grid(row=0, column=0, sticky=tk.NSEW) scbVSel = ttk.Scrollbar(self.frameTw, orient=tk.VERTICAL, command=self.treevw.yview) self.treevw.configure(yscrollcommand=scbVSel.set) scbVSel.grid(row=0, column=1, sticky=tk.NS) self.frameTw.pack(side=tk.TOP, fill=tk.BOTH, padx=5, pady=10) self.frameTw.columnconfigure(0, weight=1) self.frameTw.rowconfigure(0, weight=1) ### OFFICE EXPORT FRAME ### belowFrame = ttk.Frame(self.paned) frameBtn = ttk.Frame(belowFrame) 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 btn_down = ttk.Button(frameBtn, image=self.buttonDownImage, command=self.bDown) btn_down.pack(side="left", anchor="center") btn_up = ttk.Button(frameBtn, image=self.buttonUpImage, command=self.bUp) btn_up.pack(side="left", anchor="center") btn_delFix = ttk.Button(frameBtn, text="Remove selection", command=self.deleteSelectedItem) btn_delFix.pack(side=tk.RIGHT, padx=5) btn_addFix = ttk.Button(frameBtn, text="Add a fix", command=self.addFixCallback) btn_addFix.pack(side=tk.RIGHT, padx=5) frameBtn.pack(side=tk.TOP, pady=5) belowFrame.pack(side=tk.TOP, fill=tk.BOTH) self.paned.add(self.frameTw) self.paned.add(belowFrame) self.paned.pack(fill=tk.BOTH, expand=1) fixesLabelFrame.pack(side=tk.TOP, fill=tk.BOTH, pady=10) self.fillWithFixes()