-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""Eval debug UI frame""" | ||
|
||
from customtkinter import CTk, CTkFont, CTkLabel, CTkEntry, CTkButton, CTkTextbox | ||
|
||
from embark.domain.execution.playbook import Playbook | ||
from embark.localization.i18n import L | ||
from embark.resources import get_resource | ||
from embark.ui import utils | ||
|
||
|
||
class DebugExecFrame(CTk): | ||
"""Main UI frame""" | ||
|
||
def __init__(self, playbook: Playbook): | ||
super().__init__() | ||
self._playbook = playbook | ||
self.title(L("UI.debug_exec")) | ||
self.geometry("500x600") | ||
self.resizable(False, False) | ||
self.iconbitmap(get_resource("icon.ico")) | ||
utils.center(self) | ||
self._font = CTkFont("Consolas", 14, "normal") | ||
self._setup_ui() | ||
|
||
def _setup_ui(self): | ||
"""Create and place UI components""" | ||
self._cmd = CTkTextbox(self, font=self._font) | ||
self._execute_btn = CTkButton( | ||
self, | ||
text=L("UI.execute_expression"), | ||
command=self._exec | ||
) | ||
self._result_box = CTkTextbox(self, font=self._font) | ||
self._cmd.pack(anchor="nw", padx=4, pady=4, fill="both", expand=True) | ||
self._execute_btn.pack(anchor="nw", padx=4, pady=4, fill="x") | ||
self._result_box.pack(anchor="nw", padx=4, pady=4, fill="both", expand=True) | ||
|
||
def _log(self, *args): | ||
self._result_box.insert("end", " ".join(map(str, args)) + "\n") | ||
|
||
def _exec(self): | ||
exec( | ||
self._cmd.get("0.0", "end"), | ||
{ | ||
"playbook": self._playbook, | ||
"print": self._log | ||
} | ||
) | ||
|
||
|
||
def show(playbook): | ||
win = DebugExecFrame(playbook) | ||
win.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Variables debug UI frame""" | ||
|
||
from customtkinter import CTk, CTkFont, CTkLabel, CTkScrollableFrame | ||
|
||
from embark.domain.execution.playbook import Playbook | ||
from embark.localization.i18n import L | ||
from embark.resources import get_resource | ||
from embark.ui import utils | ||
|
||
|
||
class DebugVariablesFrame(CTk): | ||
"""Main UI frame""" | ||
|
||
def __init__(self, playbook: Playbook): | ||
super().__init__() | ||
self._playbook = playbook | ||
self.title(L("UI.debug_vars")) | ||
self.geometry("500x600") | ||
self.resizable(False, False) | ||
self.iconbitmap(get_resource("icon.ico")) | ||
utils.center(self) | ||
self._font = CTkFont("Consolas", 14, "normal") | ||
self._setup_ui() | ||
|
||
def _setup_ui(self): | ||
"""Create and place UI components""" | ||
variables = self._playbook.variables.vars.items() | ||
envs = self._playbook.variables.envs.items() | ||
self._scrollable1 = CTkScrollableFrame(self) | ||
self._scrollable = CTkScrollableFrame(self._scrollable1, orientation="horizontal") | ||
for i in range(len(variables) + len(envs) + 2): | ||
self._scrollable.rowconfigure(index=i, weight=1) | ||
self._scrollable.columnconfigure(index=0, weight=1) | ||
self._scrollable.columnconfigure(index=1, weight=1) | ||
self._vars_title = CTkLabel(self._scrollable, text=L("UI.debug_vars_section")) | ||
self._envs_title = CTkLabel(self._scrollable, text=L("UI.debug_envs_section")) | ||
self._vars_title.grid(row=0, column=0, columnspan=2, sticky="nw") | ||
row = 1 | ||
for var, val in variables: | ||
var_label = CTkLabel(self._scrollable, text=var, font=self._font) | ||
val_label = CTkLabel(self._scrollable, text=val, font=self._font) | ||
var_label.grid(row=row, column=0, sticky="nw") | ||
val_label.grid(row=row, column=1, sticky="nw", padx=4) | ||
row += 1 | ||
self._scrollable.pack(fill="both", expand=True) | ||
self._scrollable1.pack(fill="both", expand=True) | ||
|
||
|
||
def show(playbook): | ||
win = DebugVariablesFrame(playbook) | ||
win.mainloop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters