Prompt engineer.py
Shadow Agency ∞
Theory of a Personal KOS ☀
Structured-Key DataShadow ☀
Shadow Agency Code ☀
AI Agency Workflow Schemes ☀
The Cognitive Mesh ☀
Interlocution Protocol
import tkinter as tk
from config_master import ConfigMaster
class PromptEngineerApp:
def __init__(self, root, configINI):
self.root = root
self.root.protocol("WM_DELETE_WINDOW", self.on_closing)
self.root.bind("<Configure>", self.handle_configure)
self.pathName = "our-future-brain-storm"
# Initialize the ConfigMaster object
self.config = ConfigMaster(configINI)
# Create a new section in the config file if it doesn't exist
if not self.config.has_section("APP"):
self.config.add_section("APP")
# Load the root window metrics and configuration
self.load_root_metrics()
# Create a label widget with the text "Hello World"
self.label = tk.Label(root, text="Hello World")
self.label.pack()
def load_root_metrics(self):
# Read the configuration file, if it exists, or fallback to default app properties
try:
self.config.load()
# Update the application properties with the values from the INI file, if they exist, or fallback to defaults
self.db_name = self.config.get("APP", "db_name", fallback="PromptEngineer.db")
self.engineer_name = self.config.get("APP", "engineer_name", fallback="Human")
# Load the window metrics from the configuration file, or fallback to defaults
self.window_width = self.config.getint("APP", "root_width", fallback=800)
self.window_height = self.config.getint("APP", "root_height", fallback=600)
self.window_x = self.config.getint("APP", "root_x", fallback=100)
self.window_y = self.config.getint("APP", "root_y", fallback=100)
except FileNotFoundError:
# If the configuration file doesn't exist, set fallback values
self.db_name = "PromptEngineer.db"
self.engineer_name = "Human"
self.window_width = 800
self.window_height = 600
self.window_x = 100
self.window_y = 100
# Save the fallback values to the configuration file
self.config.set("APP", "db_name", self.db_name)
self.config.set("APP", "engineer_name", self.engineer_name)
self.config.set("APP", "root_width", str(self.window_width))
self.config.set("APP", "root_height", str(self.window_height))
self.config.set("APP", "root_x", str(self.window_x))
self.config.set("APP", "root_y", str(self.window_y))
self.config.save()
# Set the window title
self.root.title(f"{self.engineer_name}'s PromptEngineer App - Database: {self.db_name}")
# Set the window size and position
self.root.geometry(f"{self.window_width}x{self.window_height}+{self.window_x}+{self.window_y}")
def run(self):
self.root.mainloop()
def on_closing(self):
self.root.quit()
def handle_configure(self, event):
# Update the root window metrics in the configuration
if event.widget == self.root:
self.config.set("APP", "root_width", str(event.width))
self.config.set("APP", "root_height", str(event.height))
self.config.set("APP", "root_x", str(event.x))
self.config.set("APP", "root_y", str(event.y))
self.config.save()
if __name__ == "__main__":
# Create the root window
root = tk.Tk()
# Create an App instance of the PromptEngineer class, and pass the root window as an argument
app = PromptEngineerApp(root, "app.ini")
# Start the main event loop
root.mainloop()