- handling newparset, newjob
- .gitignore cfg files
This commit is contained in:
Eduard Gerlitz 2025-03-13 10:40:56 +01:00
parent b09208ee6b
commit ccfbac1768
11 changed files with 32 additions and 73 deletions

3
.gitignore vendored
View File

@ -4,4 +4,5 @@
*BACKUP*
out
cfg_inlay_PUTx.xlsx
/cfg_parsets/*
_cfg_parsets
_out

View File

@ -1,47 +0,0 @@
general:
yolovar: int
initpic_name: puppy.png
groups:
inlay:
parameter:
x_num: int
x_offset: double
y_num: int
y_offset: double
kos: str
cfg:
picture_name: img_inlay.png
wp_raw:
parameter:
x_wpraw: double
y_wpraw: double
z_wpraw: double
h_grp_wpraw: double
cfg:
picture_name: img_wpraw.png
wp_fin:
parameter:
x_wpfin: double
y_wpfin: double
z_wpfin: double
l_wpfin: double
h_grp_wpfin: double
cfg:
picture_name: img_wpfin.png
clp:
parameter:
clp_offset: double
y_prb_floor1: double
z_prb_floor1: double
y_prb_floor2: double
z_prb_floor2: double
x_prb_backen: double
z_prb_backen: double
l_prb_backen: double
y_prb_seite: double
z_prb_seite: double
cfg:
picture_name: img_clp.png

20
MAIN.py
View File

@ -11,9 +11,9 @@ from tkinter import ttk
import yaml
import shutil
folder_parsets = "cfg_parsets"
folder_parsets = "_cfg_parsets"
folder_pictures = "cfg_picture"
folder_output = "out"
folder_output = "_out"
file_def = "def.yml"
file_jobs = "jobs.yml"
name_newparset = "<<new par set>>"
@ -24,7 +24,7 @@ pic_sizelimit = 200
def setup_group(frame, group_name, data, input_vars, selected_params, group_widgets):
group_data = data['groups'][group_name]
picture_name = group_data['cfg']['picture_name'] # Picture name defined in def.yml
picture_path = os.path.join(folder_pictures, picture_name) # Full path to the picture
picture_path = os.path.join(folder_parsets, picture_name) # Full path to the picture
# Dropdown for parameter sets
@ -36,8 +36,8 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
source_path = f"{folder_pictures}/{data['general']['notavailablepic_name']}"
# Handle missing picture case
if not os.path.exists(picture_path):
shutil.copy(source_path, picture_path)
# if not os.path.exists(picture_path):
# shutil.copy(source_path, picture_path)
# Function to update the picture based on inputs or use the init picture
@ -47,7 +47,7 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
input_vars.items()}
# Use the source_path if the selected parameter set is the new parameter set placeholder
# print(param_dropdown.get())
# print(param_dropdown.get()) #DEBUG
if param_dropdown.get() == name_newparset:
picture_to_use = source_path
else:
@ -78,6 +78,7 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
# Function to save the current parameter set
def save_current_param():
param_name = param_dropdown.get()
if not param_name == name_newparset:
if param_name not in param_values and param_name.strip():
param_values.insert(-1, param_name) # Insert before '<<new parameter set>>'
param_dropdown['values'] = param_values
@ -113,6 +114,10 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
for key in input_vars[group_name]:
input_vars[group_name][key].set('')
# Show original picture
update_inlay_picture()
# Detect and save a new parameter set if entered via dropdown (press Enter)
def on_enter_new_param(event):
selected_param = param_dropdown.get()
@ -165,7 +170,6 @@ def setup_group(frame, group_name, data, input_vars, selected_params, group_widg
# Bind the dropdown selection event
param_dropdown.bind("<<ComboboxSelected>>", lambda event: load_selected_param())
# param_dropdown.event_generate("<<ComboboxSelected>>") # Trigger the ComboboxSelected
# Bind the Enter key to detect when a new parameter set is typed and saved
param_dropdown.bind("<Return>", on_enter_new_param)
@ -223,12 +227,12 @@ def setup_jobs(frame, data, selected_job, selected_params, input_vars, group_wid
# Function to save the current job
def save_current_job():
job_name = selected_job.get()
if not job_name == name_newjob:
if job_name not in job_values and job_name.strip():
job_values.insert(-1, job_name) # Insert before '<<new job>>'
selected_job.set(job_name)
job_data = {group_name: selected_params[group_name].get() for group_name in data['groups']}
save_yaml("jobs", job_name, job_data, folder_parsets)
# Update job dropdown after saving a new job
job_dropdown['values'] = job_values
job_dropdown.set(job_name)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

View File

@ -25,6 +25,7 @@ def save_yaml(group_name, param_name, param_data, folder_parsets):
yml_file = os.path.join(folder_parsets, f"{group_name}.yml")
all_data = load_existing_data(yml_file)
all_data[param_name] = param_data
os.makedirs(folder_parsets, exist_ok=True)
with open(yml_file, 'w') as file:
yaml.dump(all_data, file)
# messagebox.showinfo("Success", f"Parameter set '{param_name}' saved to {group_name}.yml")