Skip to content

Commit 5aa08f9

Browse files
committed
add a new frame into the main window
1 parent 38bee28 commit 5aa08f9

File tree

8 files changed

+61
-25
lines changed

8 files changed

+61
-25
lines changed

ui/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .frame_device_information import FrameDeviceInformation
55
from .frame_erase_device import FrameEraseDevice
66
from .frame_firmware_flash import FrameFirmwareFlash
7+
from .frame_plugins import FramePlugIns
78
from .frame_search_device import FrameSearchDevice
89

910

@@ -13,5 +14,6 @@
1314
"FrameSearchDevice",
1415
"FrameDeviceInformation",
1516
"FrameEraseDevice",
17+
"FramePlugIns",
1618
"FrameFirmwareFlash"
1719
]

ui/firmware_studio.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ui.frame_firmware_flash import FrameFirmwareFlash
1313
from ui.frame_search_device import FrameSearchDevice
1414
from ui.frame_console import FrameConsole
15+
from ui.frame_plugins import FramePlugIns
1516
from esptool_plugin.esptool_command_runner import CommandRunner
1617
from serial_plugin.serial_command_runner import SerialCommandRunner
1718
from config.device_configuration import BAUDRATE_OPTIONS, DEFAULT_URL, CONFIGURED_DEVICES
@@ -64,12 +65,17 @@ def __init__(self):
6465
self.information.chip_info_btn.configure(command=lambda: self._esptool_command("chip_id"))
6566
self.information.memory_info_btn.configure(command=lambda: self._esptool_command("flash_id"))
6667
self.information.mac_info_btn.configure(command=lambda: self._esptool_command("read_mac"))
68+
self.information.mac_info_btn.pack_forget()
6769
self.information.flash_status_btn.configure(command=lambda: self._esptool_command("read_flash_status"))
6870
self.information.flash_status_btn.pack_forget()
69-
self.information.mp_version_btn.configure(command=self._get_version)
70-
self.information.mp_version_btn.pack_forget()
71-
self.information.mp_structure_btn.configure(command=self._get_structure)
72-
self.information.mp_structure_btn.pack_forget()
71+
72+
# PlugIns
73+
self.plugins = FramePlugIns(self)
74+
self.plugins.label.configure(font=FONT_CATEGORY)
75+
self.plugins.mp_version_btn.configure(command=self._get_version)
76+
self.plugins.mp_version_btn.pack_forget()
77+
self.plugins.mp_structure_btn.configure(command=self._get_structure)
78+
self.plugins.mp_structure_btn.pack_forget()
7379

7480
# Erase Device
7581
self.erase_device = FrameEraseDevice(self)
@@ -148,9 +154,10 @@ def toggle_expert_mode(self) -> None:
148154
if self.flash_firmware.expert_mode.get():
149155
debug('Expert mode enabled')
150156
self.__expert_mode = True
157+
self.information.mac_info_btn.pack(padx=10, pady=5)
151158
self.information.flash_status_btn.pack(padx=10, pady=5)
152-
self.information.mp_version_btn.pack(padx=10, pady=5)
153-
self.information.mp_structure_btn.pack(padx=10, pady=5)
159+
self.plugins.mp_version_btn.pack(padx=10, pady=5)
160+
self.plugins.mp_structure_btn.pack(padx=10, pady=5)
154161
self.flash_firmware.flash_mode_label.grid(row=5, column=0, padx=10, pady=5, sticky="w")
155162
self.flash_firmware.flash_mode_option.grid(row=5, column=1, padx=10, pady=5, sticky="w")
156163
self.flash_firmware.flash_mode_info.grid(row=5, column=3, columnspan=3, padx=10, pady=5, sticky="w")
@@ -166,9 +173,10 @@ def toggle_expert_mode(self) -> None:
166173
else:
167174
debug('Expert mode disabled')
168175
self.__expert_mode = False
176+
self.information.mac_info_btn.pack_forget()
169177
self.information.flash_status_btn.pack_forget()
170-
self.information.mp_version_btn.pack_forget()
171-
self.information.mp_structure_btn.pack_forget()
178+
self.plugins.mp_version_btn.pack_forget()
179+
self.plugins.mp_structure_btn.pack_forget()
172180
self.flash_firmware.flash_mode_label.grid_remove()
173181
self.flash_firmware.flash_mode_option.grid_remove()
174182
self.flash_firmware.flash_mode_info.grid_remove()
@@ -221,8 +229,8 @@ def _disable_buttons(self) -> None:
221229
self.information.memory_info_btn.configure(state='disabled')
222230
self.information.mac_info_btn.configure(state='disabled')
223231
self.information.flash_status_btn.configure(state='disabled')
224-
self.information.mp_version_btn.configure(state='disabled')
225-
self.information.mp_structure_btn.configure(state='disabled')
232+
self.plugins.mp_version_btn.configure(state='disabled')
233+
self.plugins.mp_structure_btn.configure(state='disabled')
226234
self.erase_device.erase_btn.configure(state='disabled')
227235
self.flash_firmware.flash_btn.configure(state='disabled')
228236

@@ -236,8 +244,8 @@ def _enable_buttons(self) -> None:
236244
self.information.memory_info_btn.configure(state='normal')
237245
self.information.mac_info_btn.configure(state='normal')
238246
self.information.flash_status_btn.configure(state='normal')
239-
self.information.mp_version_btn.configure(state='normal')
240-
self.information.mp_structure_btn.configure(state='normal')
247+
self.plugins.mp_version_btn.configure(state='normal')
248+
self.plugins.mp_structure_btn.configure(state='normal')
241249
self.erase_device.erase_btn.configure(state='normal')
242250
self.flash_firmware.flash_btn.configure(state='normal')
243251

ui/frame_console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, master, *args, **kwargs):
1919
super().__init__(master, *args, **kwargs)
2020
debug('Create Console Frame')
2121

22-
self.grid(row=3, column=0, columnspan=2, pady=10, padx=10, sticky="nsew")
22+
self.grid(row=4, column=0, columnspan=2, pady=10, padx=10, sticky="nsew")
2323
self.grid_columnconfigure(0, weight=1)
2424

2525
self.label = CTkLabel(self, text='Console Output')

ui/frame_device_information.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, master, *args, **kwargs):
1717
Label and Button with customizable UI features.
1818
"""
1919
super().__init__(master, *args, **kwargs)
20-
debug('Create DeviceInformation Frame')
20+
debug('Create Device Information Frame')
2121

2222
self.grid(row=1, column=0, padx=10, pady=5, sticky="nsew")
2323
self.grid_columnconfigure(0, weight=1)
@@ -36,9 +36,3 @@ def __init__(self, master, *args, **kwargs):
3636

3737
self.flash_status_btn = CTkButton(self, text='Flash Status')
3838
self.flash_status_btn.pack(padx=10, pady=5)
39-
40-
self.mp_version_btn = CTkButton(self, text='Version', fg_color='green')
41-
self.mp_version_btn.pack(padx=10, pady=5)
42-
43-
self.mp_structure_btn = CTkButton(self, text='File Structure', fg_color='green')
44-
self.mp_structure_btn.pack(padx=10, pady=5)

ui/frame_erase_device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def __init__(self, master, *args, **kwargs):
1717
Label and a Button with customizable UI features.
1818
"""
1919
super().__init__(master, *args, **kwargs)
20-
debug('Create EraseDevice Frame')
20+
debug('Create Erase Device Frame')
2121

22-
self.grid(row=2, column=0, padx=10, pady=5, sticky="nsew")
22+
self.grid(row=3, column=0, padx=10, pady=5, sticky="nsew")
2323
self.grid_columnconfigure(0, weight=1)
2424

2525
self.label = CTkLabel(self, text='Erase')

ui/frame_firmware_flash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def __init__(self, master, *args, **kwargs):
2222
customizable UI features.
2323
"""
2424
super().__init__(master, *args, **kwargs)
25-
debug('Create FirmwareFlash Frame')
25+
debug('Create Firmware Flash Frame')
2626

27-
self.grid(row=1, column=1, rowspan=2, padx=10, pady=5, sticky="nsew")
27+
self.grid(row=1, column=1, rowspan=3, padx=10, pady=5, sticky="nsew")
2828
self.grid_columnconfigure((0, 1, 2, 3, 4), weight=0)
2929
self.grid_columnconfigure(5, weight=1)
3030

ui/frame_plugins.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from logging import getLogger, debug
2+
from customtkinter import CTkFrame, CTkLabel, CTkButton
3+
4+
5+
logger = getLogger(__name__)
6+
7+
8+
class FramePlugIns(CTkFrame):
9+
"""
10+
A specialized class designed to facilitate Serial Plugin operations.
11+
"""
12+
13+
def __init__(self, master, *args, **kwargs):
14+
"""
15+
A custom frame designed with widgets for show plugins. This frame
16+
is a child of the specified parent widget (master) and includes a
17+
Label and Button customizable UI feature.
18+
"""
19+
super().__init__(master, *args, **kwargs)
20+
debug('Create PlugIns Frame')
21+
22+
self.grid(row=2, column=0, padx=10, pady=5, sticky="nsew")
23+
self.grid_columnconfigure(0, weight=1)
24+
25+
self.label = CTkLabel(self, text='PlugIns')
26+
self.label.pack(padx=10, pady=10)
27+
28+
self.mp_version_btn = CTkButton(self, text='Version', fg_color='green')
29+
self.mp_version_btn.pack(padx=10, pady=5)
30+
31+
self.mp_structure_btn = CTkButton(self, text='File Structure', fg_color='green')
32+
self.mp_structure_btn.pack(padx=10, pady=5)

ui/frame_search_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, master, *args, **kwargs):
1919
Image, Button and an OptionMenu with customizable UI features.
2020
"""
2121
super().__init__(master, *args, **kwargs)
22-
debug('Create SearchDevice Frame')
22+
debug('Create Search Device Frame')
2323

2424
self.grid(row=0, column=0, columnspan=2, pady=10, padx=10, sticky="ew")
2525

0 commit comments

Comments
 (0)