Merge pull request #347 from coreemu/coretk-fix

Coretk fix
This commit is contained in:
bharnden 2020-01-16 11:08:39 -08:00 committed by GitHub
commit ea47217e94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 10 deletions

View file

@ -417,9 +417,8 @@ class CoreClient:
if len(sessions) == 0: if len(sessions) == 0:
self.create_new_session() self.create_new_session()
else: else:
dialog = SessionsDialog(self.app, self.app) dialog = SessionsDialog(self.app, self.app, True)
dialog.show() dialog.show()
response = self.client.get_service_defaults(self.session_id) response = self.client.get_service_defaults(self.session_id)
self.default_services = { self.default_services = {
x.node_type: set(x.services) for x in response.defaults x.node_type: set(x.services) for x in response.defaults

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -17,8 +17,11 @@ if TYPE_CHECKING:
class SessionsDialog(Dialog): class SessionsDialog(Dialog):
def __init__(self, master: "Application", app: "Application"): def __init__(
self, master: "Application", app: "Application", is_start_app: bool = False
):
super().__init__(master, app, "Sessions", modal=True) super().__init__(master, app, "Sessions", modal=True)
self.is_start_app = is_start_app
self.selected = False self.selected = False
self.selected_id = None self.selected_id = None
self.tree = None self.tree = None
@ -92,7 +95,7 @@ class SessionsDialog(Dialog):
def draw_buttons(self): def draw_buttons(self):
frame = ttk.Frame(self.top) frame = ttk.Frame(self.top)
for i in range(4): for i in range(5):
frame.columnconfigure(i, weight=1) frame.columnconfigure(i, weight=1)
frame.grid(sticky="ew") frame.grid(sticky="ew")
@ -114,7 +117,7 @@ class SessionsDialog(Dialog):
b.image = image b.image = image
b.grid(row=0, column=1, padx=PADX, sticky="ew") b.grid(row=0, column=1, padx=PADX, sticky="ew")
image = Images.get(ImageEnum.EDITDELETE, 16) image = Images.get(ImageEnum.SHUTDOWN, 16)
b = ttk.Button( b = ttk.Button(
frame, frame,
image=image, image=image,
@ -125,8 +128,32 @@ class SessionsDialog(Dialog):
b.image = image b.image = image
b.grid(row=0, column=2, padx=PADX, sticky="ew") b.grid(row=0, column=2, padx=PADX, sticky="ew")
b = ttk.Button(frame, text="Cancel", command=self.click_new) image = Images.get(ImageEnum.DELETE, 16)
b.grid(row=0, column=3, sticky="ew") b = ttk.Button(
frame,
image=image,
text="Delete",
compound=tk.LEFT,
command=self.click_delete,
)
b.image = image
b.grid(row=0, column=3, padx=PADX, sticky="ew")
image = Images.get(ImageEnum.CANCEL, 16)
if self.is_start_app:
b = ttk.Button(
frame, image=image, text="Exit", compound=tk.LEFT, command=self.destroy
)
else:
b = ttk.Button(
frame,
image=image,
text="Cancel",
compound=tk.LEFT,
command=self.destroy,
)
b.image = image
b.grid(row=0, column=4, sticky="ew")
def click_new(self): def click_new(self):
self.app.core.create_new_session() self.app.core.create_new_session()
@ -176,3 +203,13 @@ class SessionsDialog(Dialog):
self.app.core.stop_session(sid) self.app.core.stop_session(sid)
self.click_new() self.click_new()
self.destroy() self.destroy()
def click_delete(self):
logging.debug("Click delete")
item = self.tree.selection()
if item:
sid = int(self.tree.item(item, "text"))
self.app.core.delete_session(sid)
self.tree.delete(item[0])
if sid == self.app.core.session_id:
self.click_new()

View file

@ -68,3 +68,6 @@ class ImageEnum(Enum):
DOCKER = "docker" DOCKER = "docker"
LXC = "lxc" LXC = "lxc"
ALERT = "alert" ALERT = "alert"
DELETE = "delete"
SHUTDOWN = "shutdown"
CANCEL = "cancel"

View file

@ -73,9 +73,7 @@ def load(style: ttk.Style):
"shiftrelief": [("pressed", 1)], "shiftrelief": [("pressed", 1)],
}, },
}, },
"TMenubutton": { "TMenubutton": {"configure": {"padding": (5, 1), "relief": tk.RAISED}},
"configure": {"width": 11, "padding": (5, 1), "relief": tk.RAISED}
},
"TCheckbutton": { "TCheckbutton": {
"configure": { "configure": {
"indicatorbackground": Colors.white, "indicatorbackground": Colors.white,