Hi
As you know In Photoshop we can record work on one file and play it on other files.
Photoshop tracks every move, filter, export, and anything
Did glyphs track changes? can we have Something Like Photoshop Action?
maybe like this (Not working now)
import GlyphsApp
from vanilla import Window, Button, List
import json
import os
# Define the path for saved files
saved_files_path = os.path.join(GlyphsApp.GSGlyphsInfo.applicationSupportPath(), "Recordings")
if not os.path.exists(saved_files_path):
os.makedirs(saved_files_path)
class GlyphRecorder:
def __init__(self):
# Define UI Window
self.w = Window((400, 300), "Glyphs Recorder")
# Buttons
self.w.record_button = Button((10, 10, -10, 20), "Record", callback=self.start_recording)
self.w.stop_button = Button((10, 40, -10, 20), "Stop", callback=self.stop_recording)
self.w.save_button = Button((10, 70, -10, 20), "Save", callback=self.save_recording)
# Saved recordings list with Run and Delete buttons
self.w.saved_files = List((10, 100, -10, -40), [], selectionCallback=self.load_files)
self.w.run_button = Button((10, -30, 180, 20), "Run", callback=self.run_recording)
self.w.delete_button = Button((200, -30, -10, 20), "Delete", callback=self.delete_recording)
# Initialize variables
self.recording = []
self.is_recording = False
self.update_file_list()
# Open window
self.w.open()
def start_recording(self, sender):
self.is_recording = True
self.recording = []
def stop_recording(self, sender):
self.is_recording = False
def save_recording(self, sender):
if not self.recording:
print("No actions recorded.")
return
# Get the save file name from the user
save_name = GlyphsApp.GetSaveFile("Save Recording", saved_files_path, ["json"])
if save_name:
with open(save_name, "w") as file:
json.dump(self.recording, file)
print(f"Recording saved as {save_name}.")
self.update_file_list()
def load_files(self, sender):
print(f"File selected: {sender.getSelection()}")
def run_recording(self, sender):
# Get selected file and run actions
selected_file = self.w.saved_files.getSelection()
if selected_file:
file_path = os.path.join(saved_files_path, selected_file[0])
with open(file_path, "r") as file:
actions = json.load(file)
# Replay actions in Glyphs App
print(f"Replaying actions from {selected_file[0]}...")
def delete_recording(self, sender):
# Delete the selected recording
selected_file = self.w.saved_files.getSelection()
if selected_file:
file_path = os.path.join(saved_files_path, selected_file[0])
os.remove(file_path)
print(f"{selected_file[0]} deleted.")
self.update_file_list()
def update_file_list(self):
# Load saved files but do NOT call selection callback when updating
saved_files = [f for f in os.listdir(saved_files_path) if f.endswith(".json")]
self.w.saved_files.set(saved_files)
GlyphRecorder()