# SDXL Prompt Styler - Menu Customization
This document explains how to customize the **menu options** for the SDXL Prompt Styler
using an **external configuration file**. This approach allows you to easily update, add, or modify menu groups without editing the core Python code.
## Overview
The script (`sdxl_prompt_styler.py`) defines several menu groups for styling prompts. Originally, these menus were **hardcoded** within the Python script. Now, the menu definitions can be configured externally using a JSON file named styler_config.json
. This makes customization straightforward for anyone without coding experience.
## File Structure
Here is an example folder structure that shows how the script points to different data folders, each corresponding to a menu item defined in styler_config.json
:
```
project_directory/
|— sdxl_prompt_styler.py # Main Python script for styling prompts
|— styler_config.json # External configuration file for menu customization
|— data/ # Folder containing all the style categories
|— camera/ # Folder for 'camera' styles
|— composition/ # Folder for 'composition' styles
|— depth/ # Folder for 'depth' styles
|— environment/ # Folder for 'environment' styles
|— filter/ # Folder for 'filter' styles
|— focus/ # Folder for 'focus' styles
|— lighting/ # Folder for 'lighting' styles
|— mood/ # Folder for 'mood' styles
|— subject/ # Folder for 'subject' styles
|— theme/ # Folder for 'theme' styles
|— timeofday/ # Folder for 'timeofday' styles
```
Each folder in the data
directory matches an item listed under the menus in styler_config.json
. This structure ensures that each menu item in the JSON file links directly to a corresponding folder containing the relevant style data.
The relevant files for this functionality are:
```
project_directory/
|— sdxl_prompt_styler.py # Main Python script for styling prompts
|— styler_config.json # External configuration file for menu customization
|— other_files/ # Other related files and directories
```
## External Configuration File (`styler_config.json`)
The values for each menu item in the JSON correspond to the matching folder names in the data
directories. Each item must match an existing folder name for the script to correctly link to the corresponding styles.
The styler_config.json
file contains the menu definitions. This file must be placed in the **same directory** as the main Python script (`sdxl_prompt_styler.py`).
### Example styler_config.json
Below is an example of how the styler_config.json
file should look:
```json
{
"Perfection Styler": [
"camera", "composition", "depth", "environment", "filter",
"focus", "lighting", "mood", "subject", "theme", "timeofday"
],
"Enhanced Styler": [
"camera", "composition", "depth", "environment", "filter",
"focus", "lighting", "mood", "subject", "theme", "timeofday"
]
}
```
- Each **menu name** is a key (e.g., "Perfection Styler"), and the **items** listed under each menu are defined as an array.
- Each item in the list must match the name of a corresponding folder within the data
directory to function properly.
- Users can **add new menus**, **edit existing ones**, or **remove menus** as required.
## How to Customize Menus
1. **Open styler_config.json
in a Text Editor**: Use any text editor of your choice (e.g., Notepad, VSCode, Sublime Text).
2. **Modify the Menus**:
- **Add a New Menu**: Simply add a new key-value pair to the JSON file.
- **Edit an Existing Menu**: Modify the list of items under an existing key.
- **Remove a Menu**: Delete the corresponding key-value pair.
### Adding a New Menu
To add a new menu called **"Creative Styler"**, modify the JSON as follows:
```json
{
"Perfection Styler": [
"camera", "composition", "depth", "environment", "filter",
"focus", "lighting", "mood", "subject", "theme", "timeofday"
],
"Enhanced Styler": [
"camera", "composition", "depth", "environment", "filter",
"focus", "lighting", "mood", "subject", "theme", "timeofday"
],
"Creative Styler": [
"abstract", "vivid colors", "dynamic", "motion", "unique perspective"
]
}
```
### Editing an Existing Menu
To edit an existing menu, such as **"Enhanced Styler"**, you can change the list of items to suit your needs. For example, you can modify the Enhanced Styler
to include a new element called mystical
:
```json
{
"Perfection Styler": [
"camera", "composition", "depth", "environment", "filter",
"focus", "lighting", "mood", "subject", "theme", "timeofday"
],
"Enhanced Styler": [
"camera", "composition", "depth", "environment", "filter",
"focus", "lighting", "mood", "subject", "theme", "timeofday", "mystical"
]
}
```
### Removing a Menu
If you no longer need a specific menu, such as **"Perfection Styler"**, simply delete its key-value pair from the JSON:
```json
{
"Enhanced Styler": [
"camera", "composition", "depth", "environment", "filter",
"focus", "lighting", "mood", "subject", "theme", "timeofday"
],
"Creative Styler": [
"abstract", "vivid colors", "dynamic", "motion", "unique perspective"
]
}
```
## Running the Script
After modifying the configuration file, simply **run the Python script** as usual:
```sh
python sdxl_prompt_styler.py
```
The script will automatically load the menu definitions from styler_config.json
. If the configuration file is **missing or malformed**, the script will fall back to using a **default hardcoded version** to ensure functionality.
## Troubleshooting
- **Configuration File Not Found**: If the script cannot find styler_config.json
, it will print an error message and fall back to default settings.
- **Invalid JSON Format**: Make sure that styler_config.json
is properly formatted JSON. You can use an online JSON validator (like [jsonlint.com](https://jsonlint.com/)) to verify correctness.
## Summary
The new configuration feature makes it easy to manage and customize the menus for the SDXL Prompt Styler:
- **No need to edit Python code**.
- **Flexible configuration** using a simple JSON file.
Feel free to add or modify menus to suit your needs, allowing for a more personalized prompt styling experience!