small changes to guide lines

This commit is contained in:
Looki2000 2024-03-16 22:00:41 +01:00
parent d74a5e1ae4
commit a39851bb61
2 changed files with 12 additions and 12 deletions

2
.gitignore vendored
View File

@ -2,6 +2,6 @@ __pycache__/
.vscode/
last_path_cache.txt
grid_values.txt
guide_values.txt
*.fontproj

22
main.py
View File

@ -279,10 +279,10 @@ entry_3.pack(side="top", pady=2)
## load last values
cwd = os.path.dirname(os.path.realpath(__file__))
grid_vals_path = os.path.join(cwd, "grid_values.txt")
guide_vals_path = os.path.join(cwd, "guide_values.txt")
def get_grid_entries():
def get_guide_entries():
return (
int(entry_1.get()),
int(entry_2.get()),
@ -296,31 +296,31 @@ def update_guide_pos(pos, dont_save=False):
if dont_save:
return
with open(grid_vals_path, "w") as f:
with open(guide_vals_path, "w") as f:
f.write(f"{entry_1.get()}\n{entry_2.get()}\n{entry_3.get()}")
if os.path.exists(grid_vals_path):
with open(grid_vals_path, "r") as f:
if os.path.exists(guide_vals_path):
with open(guide_vals_path, "r") as f:
lines = f.readlines()
entry_1.insert(0, lines[0].strip())
entry_2.insert(0, lines[1].strip())
entry_3.insert(0, lines[2].strip())
update_guide_pos(get_grid_entries(), dont_save=True)
update_guide_pos(get_guide_entries(), dont_save=True)
else:
entry_1.insert(0, "2")
entry_2.insert(0, "4")
entry_3.insert(0, "10")
entry_1.insert(0, str(3))
entry_2.insert(0, str(5))
entry_3.insert(0, str(10))
update_guide_pos(get_grid_entries())
update_guide_pos(get_guide_entries())
set_button = tkinter.Button(
frame_label_guide_pos,
text="Set",
command=lambda: update_guide_pos(get_grid_entries())
command=lambda: update_guide_pos(get_guide_entries())
).pack(side="top", pady=[5, 30])