Skip to content

Commit

Permalink
Moved variables to separate menu. Checking admin access and reporting…
Browse files Browse the repository at this point in the history
… in status canvas. Added seperators to menu to group items so commands that are linked are more clearly visible.
  • Loading branch information
apop5 authored and kanechen66 committed Oct 28, 2024
1 parent 061439b commit 0a1ef0a
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions SetupDataPkg/Tools/ConfigEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sys
import base64
import datetime
import ctypes
from pathlib import Path

sys.dont_write_bytecode = True
Expand Down Expand Up @@ -487,6 +488,7 @@ def __init__(self, master=None):
file_menu.add_command(
label="Open Config file and Clear Old Config", command=self.load_from_ml_and_clear
)
file_menu.add_separator()
file_menu.add_command(
label=self.menu_string[0], command=self.save_to_bin, state="disabled"
)
Expand All @@ -496,6 +498,7 @@ def __init__(self, master=None):
file_menu.add_command(
label=self.menu_string[2], command=self.load_from_bin, state="disabled"
)
file_menu.add_separator()
file_menu.add_command(
label=self.menu_string[3], command=self.save_full_to_svd, state="disabled"
)
Expand All @@ -505,6 +508,7 @@ def __init__(self, master=None):
file_menu.add_command(
label=self.menu_string[5], command=self.load_from_svd, state="disabled"
)
file_menu.add_separator()
file_menu.add_command(
label=self.menu_string[6], command=self.save_full_to_delta, state="disabled"
)
Expand All @@ -514,19 +518,33 @@ def __init__(self, master=None):
file_menu.add_command(
label=self.menu_string[8], command=self.load_from_delta, state="disabled"
)
file_menu.add_command(
label=self.menu_string[9], command=self.load_variable_runtime, state="disabled"
)
file_menu.add_command(
label=self.menu_string[10], command=self.set_variable_runtime, state="disabled"
)
file_menu.add_command(
label=self.menu_string[11], command=self.del_all_variable_runtime, state="disabled"
)

file_menu.add_separator()
file_menu.add_command(label="About", command=self.about)
menubar.add_cascade(label="File", menu=file_menu)
self.file_menu = file_menu

self.admin_mode = False
if os.name == 'nt' and ctypes.windll.shell32.IsUserAnAdmin():
self.admin_mode = True
elif os.name == 'posix' and os.getuid() == 0:
self.admin_mode = True

if self.admin_mode:
# Variable Menu
variable_menu = tkinter.Menu(menubar, tearoff=0)
variable_menu.add_command(
label=self.menu_string[9], command=self.load_variable_runtime, state="disabled"
)
variable_menu.add_command(
label=self.menu_string[10], command=self.set_variable_runtime, state="disabled"
)
variable_menu.add_command(
label=self.menu_string[11], command=self.del_all_variable_runtime, state="disabled"
)
menubar.add_cascade(label="Variables", menu=variable_menu)
self.variable_menu = variable_menu

root.config(menu=menubar)

# Checking if we are in Manufacturing mode
Expand All @@ -544,7 +562,7 @@ def __init__(self, master=None):
self.canvas.place(relx=1.0, rely=1.0, x=0, y=0, anchor='se')
self.canvas.create_text(
120, 25,
text=f"Manufacturing Mode: {Manufacturing_enabled}\nMfci Policy: {mfci_policy_result}",
text=f"AdminMode: {self.admin_mode}\nManufacturing Mode: {Manufacturing_enabled}\nMfci Policy: {mfci_policy_result}",
fill="black",
font=("Helvetica", 10, "bold")
)
Expand Down

0 comments on commit 0a1ef0a

Please sign in to comment.