Merge branch 'coretk' of https://github.com/coreemu/core into coretk

This commit is contained in:
Huy Pham 2019-12-16 14:58:03 -08:00
commit 6799b537de
4 changed files with 16 additions and 14 deletions

View file

@ -5,7 +5,6 @@ from tkinter import ttk
from coretk import nodeutils from coretk import nodeutils
from coretk.dialogs.dialog import Dialog from coretk.dialogs.dialog import Dialog
from coretk.dialogs.nodeservice import NodeService
from coretk.images import Images from coretk.images import Images
from coretk.nodeutils import NodeUtils from coretk.nodeutils import NodeUtils
from coretk.themes import FRAME_PAD, PADX, PADY from coretk.themes import FRAME_PAD, PADX, PADY
@ -130,10 +129,6 @@ class NodeConfigDialog(Dialog):
combobox.grid(row=row, column=1, sticky="ew") combobox.grid(row=row, column=1, sticky="ew")
row += 1 row += 1
# services
button = ttk.Button(self.top, text="Services", command=self.click_services)
button.grid(sticky="ew", pady=PADY)
# interfaces # interfaces
if self.canvas_node.interfaces: if self.canvas_node.interfaces:
self.draw_interfaces() self.draw_interfaces()
@ -193,10 +188,6 @@ class NodeConfigDialog(Dialog):
button = ttk.Button(frame, text="Cancel", command=self.destroy) button = ttk.Button(frame, text="Cancel", command=self.destroy)
button.grid(row=0, column=1, sticky="ew") button.grid(row=0, column=1, sticky="ew")
def click_services(self):
dialog = NodeService(self, self.app, self.canvas_node)
dialog.show()
def click_icon(self): def click_icon(self):
file_path = image_chooser(self) file_path = image_chooser(self)
if file_path: if file_path:

View file

@ -58,6 +58,9 @@ class WlanConfigDialog(Dialog):
:return: nothing :return: nothing
""" """
self.config_frame.parse_config() config = self.config_frame.parse_config()
self.app.core.wlan_configs[self.node.id] = self.config self.app.core.wlan_configs[self.node.id] = self.config
if self.app.core.is_runtime():
session_id = self.app.core.session_id
self.app.core.client.set_wlan_config(session_id, self.node.id, config)
self.destroy() self.destroy()

View file

@ -87,6 +87,9 @@ class CanvasGraph(tk.Canvas):
:param core.api.grpc.core_pb2.Session session: session to draw :param core.api.grpc.core_pb2.Session session: session to draw
:return: nothing :return: nothing
""" """
# hide context
self.hide_context()
# delete any existing drawn items # delete any existing drawn items
for tag in tags.COMPONENT_TAGS: for tag in tags.COMPONENT_TAGS:
self.delete(tag) self.delete(tag)
@ -122,6 +125,11 @@ class CanvasGraph(tk.Canvas):
self.bind("<ButtonPress-3>", lambda e: self.scan_mark(e.x, e.y)) self.bind("<ButtonPress-3>", lambda e: self.scan_mark(e.x, e.y))
self.bind("<B3-Motion>", lambda e: self.scan_dragto(e.x, e.y, gain=1)) self.bind("<B3-Motion>", lambda e: self.scan_dragto(e.x, e.y, gain=1))
def hide_context(self):
if self.context:
self.context.unpost()
self.context = None
def get_actual_coords(self, x, y): def get_actual_coords(self, x, y):
actual_x = (x - self.offset[0]) / self.ratio actual_x = (x - self.offset[0]) / self.ratio
actual_y = (y - self.offset[1]) / self.ratio actual_y = (y - self.offset[1]) / self.ratio
@ -294,8 +302,7 @@ class CanvasGraph(tk.Canvas):
return return
if self.context: if self.context:
self.context.unpost() self.hide_context()
self.context = None
else: else:
if self.mode == GraphMode.ANNOTATION: if self.mode == GraphMode.ANNOTATION:
self.focus_set() self.focus_set()
@ -594,8 +601,7 @@ class CanvasGraph(tk.Canvas):
self.context = canvas_node.create_context() self.context = canvas_node.create_context()
self.context.post(event.x_root, event.y_root) self.context.post(event.x_root, event.y_root)
else: else:
self.context.unpost() self.hide_context()
self.context = None
def press_delete(self, event): def press_delete(self, event):
""" """

View file

@ -222,6 +222,7 @@ class Toolbar(ttk.Frame):
:return: nothing :return: nothing
""" """
self.app.canvas.hide_context()
self.app.statusbar.core_alarms.clear() self.app.statusbar.core_alarms.clear()
self.app.statusbar.progress_bar.start(5) self.app.statusbar.progress_bar.start(5)
self.app.canvas.mode = GraphMode.SELECT self.app.canvas.mode = GraphMode.SELECT
@ -385,6 +386,7 @@ class Toolbar(ttk.Frame):
:return: nothing :return: nothing
""" """
self.app.canvas.hide_context()
self.app.statusbar.progress_bar.start(5) self.app.statusbar.progress_bar.start(5)
thread = threading.Thread(target=self.app.core.stop_session) thread = threading.Thread(target=self.app.core.stop_session)
thread.start() thread.start()