From 456e33187041ad2590209f16ebfc63001bf34a97 Mon Sep 17 00:00:00 2001 From: Huy Pham <42948410+hpham@users.noreply.github.com> Date: Mon, 9 Dec 2019 08:53:54 -0800 Subject: [PATCH] loading xml set canvas state to select mode and display that on toolbar --- coretk/coretk/coreclient.py | 31 +++++++------------------------ coretk/coretk/graph/graph.py | 1 + coretk/coretk/menuaction.py | 7 +++++++ coretk/coretk/menubar.py | 2 +- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/coretk/coretk/coreclient.py b/coretk/coretk/coreclient.py index b7b0a0df..64772b98 100644 --- a/coretk/coretk/coreclient.py +++ b/coretk/coretk/coreclient.py @@ -94,6 +94,7 @@ class CoreClient: self.service_configs = {} self.file_configs = {} self.mobility_players = {} + self.throughput = False def reset(self): # helpers @@ -186,22 +187,11 @@ class CoreClient: canvas_node.move(x, y, update=False) def handle_throughputs(self, event): - # interface_throughputs = event.interface_throughputs - # # print(interface_throughputs) - # # return - # # for i in interface_throughputs: - # # print("") - # # # return - # print(event) - # throughputs_belong_to_session = [] - # print(self.node_ids) - # for throughput in interface_throughputs: - # if throughput.node_id in self.node_ids: - # throughputs_belong_to_session.append(throughput) - # print(throughputs_belong_to_session) - self.app.canvas.throughput_draw.process_grpc_throughput_event( - event.interface_throughputs - ) + # print(event.interface_throughputs) + if self.throughput: + self.app.canvas.throughput_draw.process_grpc_throughput_event( + event.interface_throughputs + ) def join_session(self, session_id, query_location=True): # update session and title @@ -296,6 +286,7 @@ class CoreClient: self.app.toolbar.runtime_frame.tkraise() else: self.app.toolbar.design_frame.tkraise() + self.app.toolbar.select_button.invoke() self.app.statusbar.progress_bar.stop() def is_runtime(self): @@ -432,14 +423,6 @@ class CoreClient: ) process_time = time.perf_counter() - start logging.debug("start session(%s), result: %s", self.session_id, response.result) - # # print(self.client.get_node_service(self.session_id, 1, "DefaultRoute")) - # # print(self.client.set_service_defaults(self.session_id, {"router": ["DefaultRouter"]})) - # print(self.client.set_node_service(self.session_id, 1, "DefaultRoute", ["echo hello"], [], [])) - # - # # print(self.client.get_service_defaults(self.session_id)) - # - # # print(self.client.get_node_service(self.session_id, 1, "DefaultRoute")) - # # print(self.client.get_node_service_file(self.session_id, 1, "DefaultRoute", "defaultroute.sh")) self.app.statusbar.start_session_callback(process_time) # display mobility players diff --git a/coretk/coretk/graph/graph.py b/coretk/coretk/graph/graph.py index f4303713..0b9a20d2 100644 --- a/coretk/coretk/graph/graph.py +++ b/coretk/coretk/graph/graph.py @@ -77,6 +77,7 @@ class CanvasGraph(tk.Canvas): # set the private variables to default value self.mode = GraphMode.SELECT + self.annotation_type = None self.node_draw = None self.selected = None self.nodes.clear() diff --git a/coretk/coretk/menuaction.py b/coretk/coretk/menuaction.py index c4cc27bc..08298727 100644 --- a/coretk/coretk/menuaction.py +++ b/coretk/coretk/menuaction.py @@ -156,3 +156,10 @@ class MenuAction: def show_about(self): dialog = AboutDialog(self.app, self.app) dialog.show() + + def throughput(self): + throughput = self.app.core.throughput + if throughput: + self.app.core.throughput = False + else: + self.app.core.throughput = True diff --git a/coretk/coretk/menubar.py b/coretk/coretk/menubar.py index 288a517f..ed5cb2ca 100644 --- a/coretk/coretk/menubar.py +++ b/coretk/coretk/menubar.py @@ -422,7 +422,7 @@ class Menubar(tk.Menu): menu = tk.Menu(self) self.create_observer_widgets_menu(menu) self.create_adjacency_menu(menu) - menu.add_command(label="Throughput", state=tk.DISABLED) + menu.add_checkbutton(label="Throughput", command=self.menuaction.throughput) menu.add_separator() menu.add_command(label="Configure Adjacency...", state=tk.DISABLED) menu.add_command(label="Configure Throughput...", state=tk.DISABLED)