def show_context(self, event: tk.Event) -> None: # clear existing menu self.context.delete(0, tk.END) is_wlan = self.core_node.type == NodeType.WIRELESS_LAN is_emane = self.core_node.type == NodeType.EMANE if self.app.core.is_runtime(): self.context.add_command(label="Configure", command=self.show_config) if is_emane: self.context.add_command( label="EMANE Config", command=self.show_emane_config ) if is_wlan: self.context.add_command( label="WLAN Config", command=self.show_wlan_config ) if is_wlan and self.core_node.id in self.app.core.mobility_players: self.context.add_command( label="Mobility Player", command=self.show_mobility_player ) else: self.context.add_command(label="Configure", command=self.show_config) if NodeUtils.is_container_node(self.core_node.type): self.context.add_command(label="Services", command=self.show_services) self.context.add_command( label="Config Services", command=self.show_config_services ) if is_emane: self.context.add_command( label="EMANE Config", command=self.show_emane_config ) if is_wlan: self.context.add_command( label="WLAN Config", command=self.show_wlan_config ) self.context.add_command( label="Mobility Config", command=self.show_mobility_config ) if NodeUtils.is_wireless_node(self.core_node.type): self.context.add_command( label="Link To Selected", command=self.wireless_link_selected ) unlink_menu = tk.Menu(self.context) for edge in self.edges: other_id = edge.src if self.id == other_id: other_id = edge.dst other_node = self.canvas.nodes[other_id] func_unlink = functools.partial(self.click_unlink, edge) unlink_menu.add_command( label=other_node.core_node.name, command=func_unlink ) themes.style_menu(unlink_menu) self.context.add_cascade(label="Unlink", menu=unlink_menu) edit_menu = tk.Menu(self.context) themes.style_menu(edit_menu) edit_menu.add_command(label="Cut", command=self.click_cut) edit_menu.add_command(label="Copy", command=self.canvas_copy) edit_menu.add_command(label="Delete", command=self.canvas_delete) self.context.add_cascade(label="Edit", menu=edit_menu) self.context.tk_popup(event.x_root, event.y_root)
def __init__(self, app: "Application", x: float, y: float, core_node: Node, image: PhotoImage): self.app: "Application" = app self.canvas: "CanvasGraph" = app.canvas self.image: PhotoImage = image self.core_node: Node = core_node self.id: int = self.canvas.create_image(x, y, anchor=tk.CENTER, image=self.image, tags=tags.NODE) label_y = self._get_label_y() label = self.get_label() self.text_id: int = self.canvas.create_text( x, label_y, text=label, tags=tags.NODE_LABEL, font=self.app.icon_text_font, fill="#0000CD", state=self.canvas.show_node_labels.state(), ) self.tooltip: CanvasTooltip = CanvasTooltip(self.canvas) self.edges: Set[CanvasEdge] = set() self.ifaces: Dict[int, Interface] = {} self.wireless_edges: Set[CanvasWirelessEdge] = set() self.antennas: List[int] = [] self.antenna_images: Dict[int, PhotoImage] = {} self.setup_bindings() self.context: tk.Menu = tk.Menu(self.canvas) themes.style_menu(self.context)
def show_context(self, canvas: "CanvasGraph", event: tk.Event) -> None: context: tk.Menu = tk.Menu(canvas) themes.style_menu(context) context.add_command(label="Configure", command=self.click_configure) context.add_command(label="Delete", command=self.click_delete) state = tk.DISABLED if self.app.core.is_runtime() else tk.NORMAL context.entryconfigure(1, state=state) context.tk_popup(event.x_root, event.y_root)
def create_context(self) -> tk.Menu: is_wlan = self.core_node.type == NodeType.WIRELESS_LAN is_emane = self.core_node.type == NodeType.EMANE context = tk.Menu(self.canvas) themes.style_menu(context) if self.app.core.is_runtime(): context.add_command(label="Configure", command=self.show_config) if NodeUtils.is_container_node(self.core_node.type): context.add_command(label="Services", state=tk.DISABLED) context.add_command(label="Config Services", state=tk.DISABLED) if is_wlan: context.add_command(label="WLAN Config", command=self.show_wlan_config) if is_wlan and self.core_node.id in self.app.core.mobility_players: context.add_command( label="Mobility Player", command=self.show_mobility_player ) context.add_command(label="Select Adjacent", state=tk.DISABLED) context.add_command(label="Hide", state=tk.DISABLED) if NodeUtils.is_container_node(self.core_node.type): context.add_command(label="Shell Window", state=tk.DISABLED) context.add_command(label="Tcpdump", state=tk.DISABLED) context.add_command(label="Tshark", state=tk.DISABLED) context.add_command(label="Wireshark", state=tk.DISABLED) context.add_command(label="View Log", state=tk.DISABLED) else: context.add_command(label="Configure", command=self.show_config) if NodeUtils.is_container_node(self.core_node.type): context.add_command(label="Services", command=self.show_services) context.add_command( label="Config Services", command=self.show_config_services ) if is_emane: context.add_command( label="EMANE Config", command=self.show_emane_config ) if is_wlan: context.add_command(label="WLAN Config", command=self.show_wlan_config) context.add_command( label="Mobility Config", command=self.show_mobility_config ) if NodeUtils.is_wireless_node(self.core_node.type): context.add_command( label="Link To Selected", command=self.wireless_link_selected ) context.add_command(label="Select Members", state=tk.DISABLED) context.add_command(label="Select Adjacent", state=tk.DISABLED) context.add_command(label="Create Link To", state=tk.DISABLED) context.add_command(label="Assign To", state=tk.DISABLED) context.add_command(label="Move To", state=tk.DISABLED) context.add_command(label="Cut", state=tk.DISABLED) context.add_command(label="Copy", state=tk.DISABLED) context.add_command(label="Paste", state=tk.DISABLED) context.add_command(label="Delete", state=tk.DISABLED) context.add_command(label="Hide", state=tk.DISABLED) return context
def create_context(self, event: tk.Event): context = tk.Menu(self.canvas) themes.style_menu(context) context.add_command(label="Configure", command=self.configure) context.add_command(label="Delete") context.add_command(label="Split") context.add_command(label="Merge") if self.canvas.app.core.is_runtime(): context.entryconfigure(1, state="disabled") context.entryconfigure(2, state="disabled") context.entryconfigure(3, state="disabled") context.post(event.x_root, event.y_root)
def __init__( self, app: "Application", x: float, y: float, core_node: core_pb2.Node, image: "PhotoImage", ): self.app = app self.canvas = app.canvas self.image = image self.core_node = core_node self.id = self.canvas.create_image(x, y, anchor=tk.CENTER, image=self.image, tags=tags.NODE) label_y = self._get_label_y() self.text_id = self.canvas.create_text( x, label_y, text=self.core_node.name, tags=tags.NODE_LABEL, font=self.app.icon_text_font, fill="#0000CD", state=self.canvas.show_node_labels.state(), ) self.tooltip = CanvasTooltip(self.canvas) self.edges = set() self.interfaces = [] self.wireless_edges = set() self.antennas = [] self.antenna_images = {} # possible configurations self.emane_model_configs = {} self.wlan_config = {} self.mobility_config = {} self.service_configs = {} self.service_file_configs = {} self.config_service_configs = {} self.setup_bindings() self.context = tk.Menu(self.canvas) themes.style_menu(self.context)
def __init__( self, app: "Application", x: float, y: float, core_node: Node, image: PhotoImage ): self.app: "Application" = app self.canvas: "CanvasGraph" = app.canvas self.image: PhotoImage = image self.core_node: Node = core_node self.id: int = self.canvas.create_image( x, y, anchor=tk.CENTER, image=self.image, tags=tags.NODE ) label_y = self._get_label_y() label = self.get_label() self.text_id: int = self.canvas.create_text( x, label_y, text=label, tags=tags.NODE_LABEL, font=self.app.icon_text_font, fill="#0000CD", state=self.canvas.show_node_labels.state(), ) self.tooltip: CanvasTooltip = CanvasTooltip(self.canvas) self.edges: Set[CanvasEdge] = set() self.ifaces: Dict[int, Interface] = {} self.wireless_edges: Set[CanvasWirelessEdge] = set() self.antennas: List[int] = [] self.antenna_images: Dict[int, PhotoImage] = {} # possible configurations self.emane_model_configs: Dict[ Tuple[str, Optional[int]], Dict[str, ConfigOption] ] = {} self.wlan_config: Dict[str, ConfigOption] = {} self.mobility_config: Dict[str, ConfigOption] = {} self.service_configs: Dict[str, NodeServiceData] = {} self.service_file_configs: Dict[str, Dict[str, str]] = {} self.config_service_configs: Dict[str, Any] = {} self.setup_bindings() self.context: tk.Menu = tk.Menu(self.canvas) themes.style_menu(self.context)
def create_context(self): themes.style_menu(self.context) self.context.add_command(label="Configure", command=self.click_configure) self.context.add_command(label="Delete", command=self.click_delete)
def show_context(self, event: tk.Event) -> None: # clear existing menu self.context.delete(0, tk.END) is_wlan = self.core_node.type == NodeType.WIRELESS_LAN is_emane = self.core_node.type == NodeType.EMANE is_mobility = is_wlan or is_emane if self.app.core.is_runtime(): self.context.add_command(label="Configure", command=self.show_config) if is_emane: self.context.add_command( label="EMANE Config", command=self.show_emane_config ) if is_wlan: self.context.add_command( label="WLAN Config", command=self.show_wlan_config ) if is_mobility and self.core_node.id in self.app.core.mobility_players: self.context.add_command( label="Mobility Player", command=self.show_mobility_player ) if nutils.is_container(self.core_node): services_menu = tk.Menu(self.context) for service in sorted(self.core_node.config_services): service_menu = tk.Menu(services_menu) themes.style_menu(service_menu) start_func = functools.partial(self.start_service, service) service_menu.add_command(label="Start", command=start_func) stop_func = functools.partial(self.stop_service, service) service_menu.add_command(label="Stop", command=stop_func) restart_func = functools.partial(self.restart_service, service) service_menu.add_command(label="Restart", command=restart_func) validate_func = functools.partial(self.validate_service, service) service_menu.add_command(label="Validate", command=validate_func) services_menu.add_cascade(label=service, menu=service_menu) themes.style_menu(services_menu) self.context.add_cascade(label="Services", menu=services_menu) else: self.context.add_command(label="Configure", command=self.show_config) if nutils.is_container(self.core_node): self.context.add_command( label="Config Services", command=self.show_config_services ) self.context.add_command( label="Services (Deprecated)", command=self.show_services ) if is_emane: self.context.add_command( label="EMANE Config", command=self.show_emane_config ) if is_wlan: self.context.add_command( label="WLAN Config", command=self.show_wlan_config ) if is_mobility: self.context.add_command( label="Mobility Config", command=self.show_mobility_config ) if nutils.is_wireless(self.core_node): self.context.add_command( label="Link To Selected", command=self.wireless_link_selected ) link_menu = tk.Menu(self.context) for canvas in self.app.manager.all(): canvas_menu = tk.Menu(link_menu) themes.style_menu(canvas_menu) for node in canvas.nodes.values(): if not self.is_linkable(node): continue func_link = functools.partial(self.click_link, node) canvas_menu.add_command( label=node.core_node.name, command=func_link ) link_menu.add_cascade(label=f"Canvas {canvas.id}", menu=canvas_menu) themes.style_menu(link_menu) self.context.add_cascade(label="Link", menu=link_menu) unlink_menu = tk.Menu(self.context) for edge in self.edges: other_node = edge.other_node(self) other_iface = edge.other_iface(self) label = other_node.core_node.name if other_iface: label = f"{label}:{other_iface.name}" func_unlink = functools.partial(self.click_unlink, edge) unlink_menu.add_command(label=label, command=func_unlink) themes.style_menu(unlink_menu) self.context.add_cascade(label="Unlink", menu=unlink_menu) edit_menu = tk.Menu(self.context) themes.style_menu(edit_menu) edit_menu.add_command(label="Cut", command=self.click_cut) edit_menu.add_command(label="Copy", command=self.canvas_copy) edit_menu.add_command(label="Delete", command=self.canvas_delete) edit_menu.add_command(label="Hide", command=self.click_hide) self.context.add_cascade(label="Edit", menu=edit_menu) self.context.tk_popup(event.x_root, event.y_root)