Removed All Folder Dependencies
This commit is contained in:
parent
323ca4def6
commit
6e0d551970
File diff suppressed because one or more lines are too long
2
main.py
2
main.py
|
@ -18,8 +18,8 @@ SELECTION_TEXT = "Select your Directory and your Export Directory"
|
|||
class App(Ctk.CTk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.icons = Icons()
|
||||
system_code.load_json_file()
|
||||
self.icons = Icons(path=system_code.data_path)
|
||||
system_code.set_theme()
|
||||
self.my_font = Ctk.CTkFont(family="Berlin Sans FB", size=22)
|
||||
self.font_entry = Ctk.CTkFont(family="Berlin Sans FB", size=18)
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import customtkinter as Ctk
|
||||
import scripts.get_sys_info as system_code
|
||||
from icons.icons import Icons
|
||||
|
||||
|
||||
class ClosePopup(Ctk.CTkToplevel):
|
||||
def __init__(self,master, callback, **kwargs, ):
|
||||
super().__init__(master, **kwargs)
|
||||
self.icons = Icons()
|
||||
system_code.load_json_file()
|
||||
self.icons = Icons(path=system_code.data_path)
|
||||
self.my_font = Ctk.CTkFont(family="Berlin Sans FB", size=22)
|
||||
self.geometry("400x300")
|
||||
self.resizable(False, False)
|
||||
|
|
|
@ -9,6 +9,7 @@ Original: https://github.com/Akascape/CTkColorPicker/tree/main
|
|||
import customtkinter as Ctk
|
||||
from PIL import Image, ImageTk
|
||||
from icons.icons import Icons
|
||||
import scripts.get_sys_info as system_code
|
||||
import math
|
||||
|
||||
|
||||
|
@ -25,7 +26,8 @@ class AskColor(Ctk.CTkToplevel):
|
|||
slider_border: int = 1,
|
||||
**button_kwargs):
|
||||
super().__init__(master, **button_kwargs)
|
||||
self.icons = Icons()
|
||||
system_code.load_json_file()
|
||||
self.icons = Icons(path=system_code.data_path)
|
||||
self.selected_color = None
|
||||
self.title(title)
|
||||
WIDTH = width if width >= 250 else 250
|
||||
|
|
|
@ -10,8 +10,8 @@ import scripts.get_sys_info as system_code
|
|||
class Labeling(Ctk.CTkFrame):
|
||||
def __init__(self,master,img_paths, output_path, callback, window_information, **kwargs):
|
||||
super().__init__(master, **kwargs)
|
||||
self.icons = Icons()
|
||||
system_code.load_json_file()
|
||||
self.icons = Icons(path=system_code.data_path)
|
||||
self.data_saver = SaveData()
|
||||
self.my_font = Ctk.CTkFont(family="Berlin Sans FB", size=22)
|
||||
self.image_btn_size = system_code.btn_img_size
|
||||
|
@ -56,7 +56,6 @@ class Labeling(Ctk.CTkFrame):
|
|||
s: Switch Folder
|
||||
Return: Save Image
|
||||
"""
|
||||
print("gettriggered")
|
||||
self.master.bind("<r>", self.delete_current_rectangle, add="+")
|
||||
self.master.bind("<j>", self.skip_time, add="+")
|
||||
self.master.bind("<l>", self.set_data_mode_binding, add="+")
|
||||
|
@ -169,7 +168,6 @@ class Labeling(Ctk.CTkFrame):
|
|||
self.data_mode_index = 1 - self.data_mode_index
|
||||
system_code.data_mode = system_code.data_modes[self.data_mode_index]
|
||||
self.choose_mode.set(system_code.data_mode)
|
||||
print("also triggered")
|
||||
|
||||
def reset_image(self):
|
||||
self.reset_canvas()
|
||||
|
|
|
@ -10,16 +10,16 @@ FONT = "Berlin Sans FB"
|
|||
class OpenFolder(Ctk.CTkScrollableFrame):
|
||||
def __init__(self,master,output_path, callback, **kwargs, ):
|
||||
super().__init__(master, **kwargs)
|
||||
self.icons = Icons()
|
||||
self.my_font = Ctk.CTkFont(family=FONT, size=16)
|
||||
self.warning_font = Ctk.CTkFont(family=FONT, size=20)
|
||||
# the variables needed to get from the upper class
|
||||
|
||||
system_code.load_json_file()
|
||||
self.icons = Icons(path=system_code.data_path)
|
||||
self.data_saver = SaveData()
|
||||
self.button_image = Ctk.CTkImage(self.icons.get_image("Folder"), size=(63, 63))
|
||||
self.output_path = output_path
|
||||
self.callback = callback # Store the callback function
|
||||
system_code.load_json_file()
|
||||
self.data_saver = SaveData()
|
||||
|
||||
self.folders = self.get_all_folders()
|
||||
self.button_size = (50, 50) # Size width and height
|
||||
self.padding = 10 # Padding around each button
|
||||
|
|
|
@ -2,24 +2,30 @@ import os
|
|||
import re
|
||||
import customtkinter
|
||||
import json
|
||||
from scripts.theme import Theme
|
||||
|
||||
json_file_path = "./data/program.json"
|
||||
window_width = None
|
||||
window_height = None
|
||||
window_state = None
|
||||
btn_img_size = None
|
||||
skipable_frames = None
|
||||
img_format = None
|
||||
img_format_options = (".gif", ".jpg", ".png", ".tif")
|
||||
data_modes = ("Resize", "Labeling")
|
||||
thread_switcher = ("automatic", "manual")
|
||||
used_threads = None
|
||||
thread_detection_mode = None
|
||||
thread_options = []
|
||||
data = {}
|
||||
data_mode = None
|
||||
color = None
|
||||
thickness = None
|
||||
|
||||
def create_folder(folder_name):
|
||||
"""
|
||||
Creates a folder in the current directory with the specified folder name.
|
||||
|
||||
Parameters:
|
||||
folder_name (str): The name of the folder to create.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
try:
|
||||
# Construct the path where to create the new folder
|
||||
new_folder_path = os.path.join(os.getcwd(), folder_name)
|
||||
|
||||
# Create the folder
|
||||
os.makedirs(new_folder_path, exist_ok=True)
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred while creating the folder: {e}")
|
||||
|
||||
return new_folder_path
|
||||
|
||||
def load_json_file():
|
||||
global data, window_width, window_height, window_state, skipable_frames ,img_format, used_threads, thread_detection_mode, thread_options, btn_img_size, data_mode, color, thickness
|
||||
|
@ -143,8 +149,30 @@ def save_img_btn_size(btn_size):
|
|||
|
||||
def set_theme():
|
||||
# Get the current working directory
|
||||
current_dir = os.getcwd()
|
||||
# Create the path to the Json file
|
||||
theme_path = os.path.join(current_dir, 'data', 'MPENN_theme.json')
|
||||
customtkinter.set_appearance_mode("System") # Modes: system (default), light, dark
|
||||
customtkinter.set_default_color_theme(theme_path)
|
||||
customtkinter.set_default_color_theme(theme.get_theme())
|
||||
|
||||
|
||||
|
||||
data_path = create_folder("MPENNconfigs")
|
||||
json_file_path = data_path + "./program.json"
|
||||
theme = Theme(path=data_path)
|
||||
|
||||
|
||||
window_width = None
|
||||
window_height = None
|
||||
window_state = None
|
||||
btn_img_size = None
|
||||
skipable_frames = None
|
||||
img_format = None
|
||||
img_format_options = (".gif", ".jpg", ".png", ".tif")
|
||||
data_modes = ("Resize", "Labeling")
|
||||
thread_switcher = ("automatic", "manual")
|
||||
used_threads = None
|
||||
thread_detection_mode = None
|
||||
thread_options = []
|
||||
data = {}
|
||||
data_mode = None
|
||||
color = None
|
||||
thickness = None
|
|
@ -0,0 +1,369 @@
|
|||
import json
|
||||
|
||||
|
||||
class Theme:
|
||||
def __init__(self, path) -> None:
|
||||
self.path = path
|
||||
self.theme_json = {
|
||||
"CTk": {
|
||||
"fg_color": [
|
||||
"#ebebeb",
|
||||
"#1d1d1d"
|
||||
]
|
||||
},
|
||||
"CTkToplevel": {
|
||||
"fg_color": [
|
||||
"gray92",
|
||||
"#1d1d1d"
|
||||
]
|
||||
},
|
||||
"CTkFrame": {
|
||||
"corner_radius": 6,
|
||||
"border_width": 0,
|
||||
"fg_color": [
|
||||
"gray86",
|
||||
"#292929"
|
||||
],
|
||||
"top_fg_color": [
|
||||
"gray81",
|
||||
"gray20"
|
||||
],
|
||||
"border_color": [
|
||||
"gray65",
|
||||
"gray28"
|
||||
]
|
||||
},
|
||||
"CTkButton": {
|
||||
"corner_radius": 6,
|
||||
"border_width": 0,
|
||||
"fg_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"border_color": [
|
||||
"#3E454A",
|
||||
"#949A9F"
|
||||
],
|
||||
"text_color": [
|
||||
"#f7f7f7",
|
||||
"#f7f7f7"
|
||||
],
|
||||
"text_color_disabled": [
|
||||
"gray74",
|
||||
"gray60"
|
||||
]
|
||||
},
|
||||
"CTkLabel": {
|
||||
"corner_radius": 0,
|
||||
"fg_color": "transparent",
|
||||
"text_color": [
|
||||
"#313131",
|
||||
"#f7f7f7"
|
||||
]
|
||||
},
|
||||
"CTkEntry": {
|
||||
"corner_radius": 6,
|
||||
"border_width": 2,
|
||||
"fg_color": [
|
||||
"#cfcfcf",
|
||||
"#323232"
|
||||
],
|
||||
"border_color": [
|
||||
"#cfcfcf",
|
||||
"#323232"
|
||||
],
|
||||
"text_color": [
|
||||
"#2a2a2a",
|
||||
"#f7f7f7"
|
||||
],
|
||||
"placeholder_text_color": [
|
||||
"gray52",
|
||||
"gray62"
|
||||
]
|
||||
},
|
||||
"CTkCheckBox": {
|
||||
"corner_radius": 6,
|
||||
"border_width": 3,
|
||||
"fg_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"border_color": [
|
||||
"#313131",
|
||||
"#949A9F"
|
||||
],
|
||||
"hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"checkmark_color": [
|
||||
"#DCE4EE",
|
||||
"gray90"
|
||||
],
|
||||
"text_color": [
|
||||
"gray10",
|
||||
"#DCE4EE"
|
||||
],
|
||||
"text_color_disabled": [
|
||||
"gray60",
|
||||
"gray45"
|
||||
]
|
||||
},
|
||||
"CTkSwitch": {
|
||||
"corner_radius": 1000,
|
||||
"border_width": 3,
|
||||
"button_length": 0,
|
||||
"fg_color": [
|
||||
"#939BA2",
|
||||
"#4A4D50"
|
||||
],
|
||||
"progress_color": [
|
||||
"#ab5cff",
|
||||
"#35006f"
|
||||
],
|
||||
"button_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"button_hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"text_color": [
|
||||
"gray10",
|
||||
"#DCE4EE"
|
||||
],
|
||||
"text_color_disabled": [
|
||||
"gray60",
|
||||
"gray45"
|
||||
]
|
||||
},
|
||||
"CTkRadioButton": {
|
||||
"corner_radius": 1000,
|
||||
"border_width_checked": 6,
|
||||
"border_width_unchecked": 3,
|
||||
"fg_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"border_color": [
|
||||
"#313131",
|
||||
"#3f3f3f"
|
||||
],
|
||||
"hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"text_color": [
|
||||
"gray10",
|
||||
"#DCE4EE"
|
||||
],
|
||||
"text_color_disabled": [
|
||||
"gray60",
|
||||
"gray45"
|
||||
]
|
||||
},
|
||||
"CTkProgressBar": {
|
||||
"corner_radius": 1000,
|
||||
"border_width": 0,
|
||||
"fg_color": [
|
||||
"#ab5cff",
|
||||
"#35006f"
|
||||
],
|
||||
"progress_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"border_color": [
|
||||
"gray",
|
||||
"gray"
|
||||
]
|
||||
},
|
||||
"CTkSlider": {
|
||||
"corner_radius": 1000,
|
||||
"button_corner_radius": 1000,
|
||||
"border_width": 6,
|
||||
"button_length": 0,
|
||||
"fg_color": [
|
||||
"#ab5cff",
|
||||
"#35006f"
|
||||
],
|
||||
"progress_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"button_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"button_hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
]
|
||||
},
|
||||
"CTkOptionMenu": {
|
||||
"corner_radius": 6,
|
||||
"fg_color": [
|
||||
"#ab5cff",
|
||||
"#35006f"
|
||||
],
|
||||
"button_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"button_hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"text_color": [
|
||||
"#DCE4EE",
|
||||
"#DCE4EE"
|
||||
],
|
||||
"text_color_disabled": [
|
||||
"gray74",
|
||||
"gray60"
|
||||
]
|
||||
},
|
||||
"CTkComboBox": {
|
||||
"corner_radius": 6,
|
||||
"border_width": 2,
|
||||
"fg_color": [
|
||||
"#ab5cff",
|
||||
"#35006f"
|
||||
],
|
||||
"border_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"button_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"button_hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"text_color": [
|
||||
"#f7f7f7",
|
||||
"#DCE4EE"
|
||||
],
|
||||
"text_color_disabled": [
|
||||
"gray50",
|
||||
"gray45"
|
||||
]
|
||||
},
|
||||
"CTkScrollbar": {
|
||||
"corner_radius": 1000,
|
||||
"border_spacing": 4,
|
||||
"fg_color": "transparent",
|
||||
"button_color": [
|
||||
"#cecece",
|
||||
"#636363"
|
||||
],
|
||||
"button_hover_color": [
|
||||
"gray40",
|
||||
"gray53"
|
||||
]
|
||||
},
|
||||
"CTkSegmentedButton": {
|
||||
"corner_radius": 6,
|
||||
"border_width": 2,
|
||||
"fg_color": [
|
||||
"#ab5cff",
|
||||
"#35006f"
|
||||
],
|
||||
"selected_color": [
|
||||
"#5f00c7",
|
||||
"#5f00c7"
|
||||
],
|
||||
"selected_hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"unselected_color": [
|
||||
"#ab5cff",
|
||||
"#35006f"
|
||||
],
|
||||
"unselected_hover_color": [
|
||||
"#7d03ff",
|
||||
"#7d03ff"
|
||||
],
|
||||
"text_color": [
|
||||
"#DCE4EE",
|
||||
"#DCE4EE"
|
||||
],
|
||||
"text_color_disabled": [
|
||||
"gray74",
|
||||
"gray60"
|
||||
]
|
||||
},
|
||||
"CTkTextbox": {
|
||||
"corner_radius": 6,
|
||||
"border_width": 0,
|
||||
"fg_color": [
|
||||
"#dbdbdb",
|
||||
"#2a2a2a"
|
||||
],
|
||||
"border_color": [
|
||||
"#979DA2",
|
||||
"#565B5E"
|
||||
],
|
||||
"text_color": [
|
||||
"gray10",
|
||||
"#DCE4EE"
|
||||
],
|
||||
"scrollbar_button_color": [
|
||||
"gray55",
|
||||
"gray41"
|
||||
],
|
||||
"scrollbar_button_hover_color": [
|
||||
"gray40",
|
||||
"gray53"
|
||||
]
|
||||
},
|
||||
"CTkScrollableFrame": {
|
||||
"label_fg_color": [
|
||||
"gray78",
|
||||
"gray23"
|
||||
]
|
||||
},
|
||||
"DropdownMenu": {
|
||||
"fg_color": [
|
||||
"gray90",
|
||||
"gray20"
|
||||
],
|
||||
"hover_color": [
|
||||
"gray75",
|
||||
"gray28"
|
||||
],
|
||||
"text_color": [
|
||||
"gray10",
|
||||
"gray90"
|
||||
]
|
||||
},
|
||||
"CTkFont": {
|
||||
"macOS": {
|
||||
"family": "SF Display",
|
||||
"size": 13,
|
||||
"weight": "normal"
|
||||
},
|
||||
"Windows": {
|
||||
"family": "Roboto",
|
||||
"size": 13,
|
||||
"weight": "normal"
|
||||
},
|
||||
"Linux": {
|
||||
"family": "Roboto",
|
||||
"size": 13,
|
||||
"weight": "normal"
|
||||
}
|
||||
}
|
||||
}
|
||||
def get_theme(self):
|
||||
with open(self.path + "/theme.json", "w") as file:
|
||||
json.dump(self.theme_json, file, indent=4)
|
||||
return self.path + "/theme.json"
|
Loading…
Reference in New Issue