differentiate sessions dialog's between start gui vs open from menu, add delete button to sessions dialog, remove fix width in TMenubutton for dark theme

This commit is contained in:
Huy Pham 2020-01-15 15:23:49 -08:00
parent 41bf279f76
commit 084b25779b
7 changed files with 45 additions and 10 deletions

View file

@ -415,9 +415,8 @@ class CoreClient:
if len(sessions) == 0:
self.create_new_session()
else:
dialog = SessionsDialog(self.app, self.app)
dialog = SessionsDialog(self.app, self.app, True)
dialog.show()
response = self.client.get_service_defaults(self.session_id)
self.default_services = {
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

@ -13,8 +13,9 @@ from core.gui.themes import PADX, PADY
class SessionsDialog(Dialog):
def __init__(self, master, app):
def __init__(self, master, app, is_start_app=False):
super().__init__(master, app, "Sessions", modal=True)
self.is_start_app = is_start_app
self.selected = False
self.selected_id = None
self.tree = None
@ -89,7 +90,7 @@ class SessionsDialog(Dialog):
def draw_buttons(self):
frame = ttk.Frame(self.top)
for i in range(4):
for i in range(5):
frame.columnconfigure(i, weight=1)
frame.grid(sticky="ew")
@ -111,7 +112,7 @@ class SessionsDialog(Dialog):
b.image = image
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(
frame,
image=image,
@ -122,8 +123,32 @@ class SessionsDialog(Dialog):
b.image = image
b.grid(row=0, column=2, padx=PADX, sticky="ew")
b = ttk.Button(frame, text="Cancel", command=self.click_new)
b.grid(row=0, column=3, sticky="ew")
image = Images.get(ImageEnum.DELETE, 16)
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):
self.app.core.create_new_session()
@ -177,3 +202,13 @@ class SessionsDialog(Dialog):
self.app.core.stop_session(sid)
self.click_new()
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"
LXC = "lxc"
ALERT = "alert"
DELETE = "delete"
SHUTDOWN = "shutdown"
CANCEL = "cancel"

View file

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