Skip to content

Commit

Permalink
aba zonas
Browse files Browse the repository at this point in the history
  • Loading branch information
DankoCaboski committed Jul 2, 2024
1 parent 59f1d3e commit 43ea857
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 42 deletions.
Binary file added src/view/assets/Plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 42 additions & 42 deletions src/view/components/ProjConfigFrame.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from CustomTkinter import customtkinter

from view.components.TabviewSoftware import TabviewSoftware
from view.functions.PlusIcon import PlusIcon
from view.components.FakeTab import FakeTab


Expand All @@ -17,17 +18,9 @@ def __init__(self, frame):

self.hw_frame = customtkinter.CTkScrollableFrame(self.tabview.tab("Hardware"))

self.sw_frame = customtkinter.CTkFrame(self.tabview.tab("Software"))
self.sw_frame.grid_columnconfigure(0, weight=0)
self.sw_frame.grid_columnconfigure(1, weight=1)

self.sw_options = ["Robôs", "Mesa", "Grampos"]
self.sw_tabs = []


self.sw_content = TabviewSoftware(self.sw_frame)
self.content: customtkinter.CTkFrame = None

self.zonas: list[customtkinter.CTkButton] = []

self.opcoes_Hardware = ["PLC", "IHM", "IO Node"]

Expand All @@ -41,7 +34,6 @@ def __init__(self, frame):

self.add_hw()
self.configure_sw()
self.change_sw_frame(0)

################### Hardware tab ###################

Expand Down Expand Up @@ -128,24 +120,27 @@ def update_firmware_combobox(*args):
################### Software tab ###################

def configure_sw(self):
self.sw_frame.pack(fill='both', expand=True)
self.sw_frame.configure(fg_color="transparent")

sw_tabs_frame = customtkinter.CTkFrame(self.sw_frame, fg_color="#4A4A4A", )
sw_tabs_frame.grid(row=0, column=0, pady=10, sticky='nw')

for name in self.sw_options:
index = self.sw_options.index(name)
button = FakeTab(sw_tabs_frame, name).get_button()
button.grid(row=index, column=0, padx=7, pady=5)
button.configure(command=lambda i=index: set_current_option(i))
self.sw_tabs.append(button)

def set_current_option(index):
self.change_sw_frame(index)

self.color_sw_tab(0)


zonas_frame = customtkinter.CTkFrame(self.tabview.tab("Software"), fg_color="#4A4A4A")
zonas_frame.grid(row=0, column=0, sticky="e")

plus_icon = PlusIcon().load_image()

global add_zona
add_zona = customtkinter.CTkButton(
zonas_frame,
text="",
image=plus_icon,
width=24,
height=24,
command=lambda: self.add_zona(zonas_frame)
)

add_zona.grid(row=0, column=0, padx=10, pady=10)

if self.zonas.__len__() == 0:
self.add_zona(zonas_frame)


################### Utils ###################

Expand Down Expand Up @@ -177,19 +172,24 @@ def get_hardware_values(self):
return result

def get_blocks_to_import(self):
return self.sw_content.get_blocks_to_import()
raise NotImplementedError("'get_blocks_to_import' method not implemented yet.")
# return self.sw_content.get_blocks_to_import()

def add_zona(self, frame):
n = self.zonas.__len__()
if n >= 5:
return
fake_tab = FakeTab(frame, f"Zona {n + 1}", None)
zona = fake_tab.get_button()
zona.grid(row=0, column=n, padx=10, pady=10)
self.zonas.append(zona)
add_zona.grid_forget()
add_zona.grid(row=0, column=n+1, padx=10, pady=10)
self.color_sw_tab(n)

def change_sw_frame(self, index):
if self.content != None:
self.content.grid_forget()
self.content = self.sw_content.sw_content(index)
self.content.grid(row=0, column=1, columnspan=3, pady=10, sticky='nsew')
self.color_sw_tab(index)

def color_sw_tab(self, index):
for i in range(len(self.sw_tabs)):
self.sw_tabs[i].configure(fg_color="transparent")
def color_sw_tab(self, index: int):
for i in range(len(self.zonas)):
self.zonas[i].configure(fg_color="transparent")

self.zonas[index].configure(fg_color="#1F6AA5")

self.sw_tabs[index].configure(fg_color="#1F6AA5")


17 changes: 17 additions & 0 deletions src/view/functions/PlusIcon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from CustomTkinter import customtkinter
import os

from PIL import Image

class PlusIcon:
def load_image(self):

home_ico_path = "view/assets/Plus.png"
if not os.path.exists(home_ico_path):
home_ico_path = "Plus.png"

image = customtkinter.CTkImage(light_image=Image.open(home_ico_path),
dark_image=Image.open(home_ico_path),
size=(18, 18))

return image

0 comments on commit 43ea857

Please sign in to comment.