def insertIp(self, ip): """Insert a new IP in the summary. Also insert its port Args: ip: an IP object to be inserted """ treevw = ttk.Treeview(self.frameTw) treevw.heading("#0", text=ip, anchor='w') treevw.column("#0", anchor='w') tags = Settings.getTags() for tag, color in tags.items(): treevw.tag_configure(tag, background=color) treevw.bind("<Double-Button-1>", self.OnDoubleClick) count = 0 self.treeviews[ip] = treevw ports = Port.fetchObjects({"ip": ip}) for port in ports: if port.proto.strip() != "" and str(port.port).strip() != "": port_text = port.port if port.proto == "udp": port_text = "udp/" + port_text treevw.insert('', 'end', str(port.getId()), text=port_text, tags=list(port.getTags())) count += 1 treevw.configure(height=count) treevw.update_idletasks()
def completeModifyWindow(self): """ Add the buttons for an update window. -Submit button that validates the form with the update function. -Delete button that asks the user to delete the object with the delete function. """ pan = self.form.addFormPanel() pan.addFormButton("Submit", self.update) pan.addFormButton("Delete", self.delete) registeredTags = Settings.getTags() keys = list(registeredTags.keys()) column = 0 item_no = 0 listOfLambdas = [self.tagClicked(keys[i]) for i in range(len(keys))] for registeredTag, color in registeredTags.items(): if not hasattr(self.mainApp, "parent"): break if column == 0: panTags = self.form.addFormPanel(pady=0) s = ttk.Style(self.mainApp.parent) s.configure(""+color+".TButton", background=color, foreground="black") s.map(""+color+".TButton", foreground=[('active', "dark gray")], background=[('active', color)]) btn_tag = panTags.addFormButton(registeredTag, listOfLambdas[item_no], side="left", padx=0, pady=0) btn_tag.configure(style=""+color+".TButton") column += 1 item_no += 1 if column == 4: column = 0 self.showForm()
def getTagsGroups(self): """Returns groups of tags that may not be applied at the same time Returns: List of list of strings """ tags = Settings.getTags() return [tags, ["hidden"]]
def openModifyWindow(self): """ Creates a tkinter form using Forms classes. This form aims to update or perform actions on multiple different objects common properties like tags. """ top_panel = self.form.addFormPanel() top_panel.addFormButton("Export", self.appliTw.exportSelection) top_panel.addFormButton("Hide", self.appliTw.hideSelection) top_panel.addFormButton("Custom Command", self.appliTw.customCommand) top_panel.addFormButton("Delete", self.appliTw.deleteSelected) panTags = self.form.addFormPanel(grid=True) registeredTags = Settings.getTags() keys = list(registeredTags.keys()) column = 0 listOfLambdas = [self.tagClicked(keys[i]) for i in range(len(keys))] for registeredTag, color in registeredTags.items(): s = ttk.Style(self.mainApp.parent) s.configure("" + color + ".TButton", background=color, foreground="black") s.map("" + color + ".TButton", foreground=[('active', "dark gray")], background=[('active', color)]) btn_tag = panTags.addFormButton(registeredTag, listOfLambdas[column], column=column) btn_tag.configure(style="" + color + ".TButton") column += 1 self.showForm()
def _initContextualsMenus(self): """ Create the contextual menu """ self.contextualMenu = tk.Menu(self.parentFrame, tearoff=0, background='#A8CF4D', foreground='white', activebackground='#A8CF4D', activeforeground='white') self.contextualMenu.add_command( label="Custom command", command=self.customCommand) self.contextualMenu.add_command( label="Export selection", command=self.exportSelection) self.tagsMenu = tk.Menu(self.parentFrame, tearoff=0, background='#A8CF4D', foreground='white', activebackground='#A8CF4D', activeforeground='white') tags = Settings.getTags() listOfLambdas = [self.tagClicked(tag) for tag in list(tags.keys())] for i,val in enumerate(tags): self.tagsMenu.add_command( label=val, command=listOfLambdas[i]) self.contextualMenu.add_command( label="Sort children", command=self.sort) self.contextualMenu.add_command( label="Expand", command=self.expand) self.contextualMenu.add_command( label="Collapse", command=self.collapse) self.contextualMenu.add_command( label="Hide", command=self.hideAndUpdate) self.contextualMenu.add_command( label="Unhide children", command=self.unhide) self.contextualMenu.add_command( label="Close", command=self.closeMenu)
def initUI(self): """ initialize all the main windows objects. (Bar Menu, contextual menu, treeview, editing pane) """ self.nbk = ttk.Notebook(self.parent) self.statusbar = StatusBar(self.parent, Settings.getTags(), self) self.statusbar.pack(fill=tk.X) self.nbk.enable_traversal() self.initMainView() self.initCommandsView() self.initScanView() self.initSettingsView() for module in self.modules: module["view"] = ttk.Frame(self.nbk) self.nbk.add(module["view"], text=module["name"],image=module["img"],compound=tk.TOP) self._initMenuBar() self.nbk.pack(fill=tk.BOTH, expand=1)
def __init__(self, appli, parentFrame): """ Args: appli: a reference to the main Application object. parentFrame: the parent tkinter window object. """ ttk.Treeview.__init__(self, parentFrame) self.appli = appli self.parentFrame = parentFrame self._detached = [] # Temporary detached objects (filtered objects) self._moved = [] # Objects that were moved to be repositioned later self._hidden = [] # Hidden objects reference self.views = {} # Dict of views stored in this treeview. self.contextualMenu = None self.tag_configure('OOS', background="grey") tags = Settings.getTags() for tag, color in tags.items(): self.tag_configure(tag, background=color)