Oxoria API Reference
10 modules · Complete method reference
Modules
opencv_convert
cv_img, and writes the processed result back to the canvas.| Step | Description |
|---|---|
| 1 | Retrieves all selected items via CanvasAPI().get_selected() |
| 2 | Converts each item's base_pixmap to QImage.Format_RGBA8888 |
| 3 | Casts the image data to a np.ndarray of shape (H, W, 4) |
| 4 | Injects it into the decorated function as the cv_img keyword argument |
| 5 | Converts the returned np.ndarray back to QPixmap |
| 6 | Writes the result back via CanvasAPI().set_pixmap() |
cv_img: np.ndarray = None and must return a np.ndarray of shape (H, W, 4) in RGBA format. The decorator iterates over all selected items independently. No value is returned from the wrapper.CvProcessAPI
@opencv_convert and @classmethod.Converts the selected image(s) to grayscale (black & white).
| Argument | Description |
|---|---|
| cv_img | Injected automatically by @opencv_convert; do not pass manually |
| Returns | |
|---|---|
| np.ndarray | RGBA image converted from grayscale |
cv2.COLOR_BGRA2GRAY then cv2.COLOR_GRAY2RGBA for round-trip conversion.Returns the image unchanged. Intended to restore a previously processed image to its original state.
| Returns | |
|---|---|
| np.ndarray | Original RGBA image as-is |
base_pixmap holding the original data.Applies colored non-local means denoising to the selected image(s).
| Returns | |
|---|---|
| np.ndarray | Denoised RGBA image |
cv2.fastNlMeansDenoisingColored with fixed parameters (h=10, hColor=10, templateWindowSize=7, searchWindowSize=21). These are not currently configurable.Executes an arbitrary OpenCV expression string and applies the result to the selected image(s).
| Argument | Description |
|---|---|
| cv2_cmd | A Python expression string; has access to cv2, np, and cv_img in its execution context |
| cv_img | Injected automatically by @opencv_convert |
| Returns | |
|---|---|
| np.ndarray | Result of the evaluated expression |
eval() to execute the expression. Only pass trusted, validated strings. Never expose this to untrusted user input, as it can execute arbitrary code.CanvasAPI
.oxoria file save/load has moved to IoAPI.Serializes the current canvas scene into a dictionary suitable for JSON export.
| Returns | |
|---|---|
| dict | Keys are item pointers; values contain size_h, size_w, pos_x, pos_y |
ImageItem instances are included. Returns early if UI_Var.MAIN_CANVAS is None.Opens an image file and places it onto the canvas.
| Argument | Description |
|---|---|
| img_path | Path to the image file |
Removes all items from the canvas scene and resets GBVar.OPENED_FILE.
save_file() before invoking if preservation is needed.Packages the current canvas and its associated image resources into an .oxoarchive file.
| Argument | Description |
|---|---|
| archive_path | Destination path for the archive |
temp_export/ under GBVar.DATA_DIR, builds a zip archive, then renames it to .oxoarchive. The temp directory is removed after archiving. Only resources referenced by the current canvas are included.Removes a list of ImageItem instances from the canvas scene.
| Argument | Description |
|---|---|
| items_to_delete | List of items to remove |
Returns a list of currently selected items on the canvas.
| Returns | |
|---|---|
| list[ImageItem] | Currently selected scene items |
Groups all currently selected items into a single QGraphicsItemGroup.
Returns whether any item is currently selected on the canvas.
| Returns | |
|---|---|
| bool | True if at least one item is selected |
Resets the canvas view transform, centers on the origin, and applies a default zoom scale of 0.15.
Replaces the pixmap of an ImageItem on the canvas, updating both base_pixmap and the displayed scaled version.
| Argument | Description |
|---|---|
| pixmap | New QPixmap to assign |
| image_item | The target canvas item |
IoAPI
.oxoria file format using QDataStream. Both methods are @staticmethod. Previously part of CanvasAPI.Serializes every QGraphicsPixmapItem on the current canvas into a binary .oxoria file.
| Argument | Description |
|---|---|
| saving_path | Absolute or relative path to write the file |
| Step | Description |
|---|---|
| 1 | Writes a 4-byte magic number (0x4F584F52) and format version (1) |
| 2 | Writes the item count as Int32 |
| 3 | For each item: type tag "pixmap", position, scale, rotation, and z-value as Double |
| 4 | Converts the pixmap to a PNG byte buffer and writes its length + raw bytes |
IOError if the target path cannot be opened for writing.Reads a binary .oxoria file and rebuilds every pixmap item onto the current canvas.
| Argument | Description |
|---|---|
| opening_path | Path to the .oxoria file |
| Step | Description |
|---|---|
| 1 | Validates the magic number; raises ValueError if it doesn't match 0x4F584F52 |
| 2 | Calls CanvasAPI().clear_canvas() to wipe the current scene |
| 3 | Reads the item count, then reconstructs each ImageItem from its stored position, scale, rotation, z-value, and embedded PNG bytes |
| 4 | Adds each reconstructed item to main_canvas.scene() |
IOError if the file can't be opened for reading, and ValueError on an invalid/corrupt header. Unlike the old CanvasAPI-based loader, this always clears the canvas first via CanvasAPI().clear_canvas(), regardless of the current resource profile.PackageAPI
Resolves the plugin root directory to <GBVar.DATA_DIR>/plugins.
Dynamically imports and executes a plugin's __oxoplugin__.py entry point from the plugin directory.
| Argument | Description |
|---|---|
| plugin_name | Folder name of the plugin under plugins/ |
importlib.util.spec_from_file_location to load __oxoplugin__.py and registers it in sys.modules. Writes an error to the console (via OxoriaConsole) instead of raising if the plugin folder or entry point is missing.Copies or moves a plugin folder into the app's plugin directory.
| Argument | Description |
|---|---|
| plugin_folder | Source folder containing the plugin |
| plugin_name | Destination folder name under plugins/ |
| make_copy | If True, copies the folder (shutil.copytree); if False, moves it (shutil.move) (default: True) |
| force | If True, overwrites an existing plugin folder with the same name (default: False) |
force is False.Opens a folder picker dialog so the user can select a plugin folder to install, then delegates to install_plugin().
make_copy=True, force=False. Does nothing if the dialog is cancelled.AppAPI
Launches the screen capture monitor as a background process, if not already running.
psutil before launching to prevent duplicate instances. The monitor script path is resolved relative to the module's location.Opens a new Oxoria application window as an independent subprocess.
__main__.py in the application root directory. Prints an error to stdout if the entry script is not found.Quits the main Qt application.
GBVar.MAIN_APP.quit(). Does nothing if MAIN_APP is None.Retrieves a slice of the global command execution history stack.
| Argument | Description |
|---|---|
| output_length | Number of commands to return from the end of the stack. Pass -1 (default) to return the entire stack; pass a positive integer to return only the last N commands |
| Returns | |
|---|---|
| list[str] | List of command strings; empty list if the command stack is empty or output_length is invalid |
output_length exceeds the actual stack size, the entire stack is returned. The stack is accessed via GBVar.COMMAND_STACK.Registers a custom shortcut by storing a command string mapped to a shortcut alphabet key.
| Argument | Description |
|---|---|
| cmd | The command string to execute when the shortcut is triggered |
| shortcut_alphabet | A single character or key name to use as the shortcut trigger |
config/app_config.json, updates the "mycommand" section with the new shortcut mapping, and writes the updated config back to disk. Creates the "mycommand" dictionary if it does not exist.Retrieves the command string associated with a registered custom shortcut.
| Argument | Description |
|---|---|
| shortcut_alphabet | The shortcut key to look up |
| Returns | |
|---|---|
| str | The command string for the given shortcut; empty string "" if the shortcut does not exist or the "mycommand" section is not found |
config/app_config.json. Returns an empty string rather than raising an error if the shortcut is not found.Returns the absolute path to the application data directory.
| Returns | |
|---|---|
| str | Path to the data directory, typically containing resources_lib/, profiles/, and other application data |
GBVar.DATA_DIR. This is a convenience accessor for the global data directory.Returns the absolute path to the parent directory of the data directory (the root application folder).
| Returns | |
|---|---|
| str | Path to the application root folder, one level above the data directory |
Path.resolve().parent. Useful for locating configuration files and other app-level resources.Returns a reference to the global GBVar class object.
| Returns | |
|---|---|
| GBVar | The GBVar class itself, providing access to all global application variables |
MAIN_APP, COMMAND_STACK, DATA_DIR, etc.Registers new entries into the application's menu bar configuration, merging them into editor_config.json.
| Argument | Description |
|---|---|
| new_items | Nested dict of the form {menu_key: {item_key: item_value, ...}, ...} to merge into the existing "menu_bar" section |
config/editor_config.json, merges new_items two levels deep into the existing "menu_bar" dict (creating menu keys that don't already exist), and writes the file back. Existing item keys under a matching menu key are overwritten.Writes a message to the in-app Oxoria console.
| Argument | Description |
|---|---|
| msg | Text to display in the console |
OxoriaConsole.write_console(). Useful for plugins and custom commands to surface output to the user.Config (AppConfigAPI / EditorConfigAPI / UseConfigData)
AppConfigAPI, EditorConfigAPI) backed by JSON files under config/, plus UseConfigData, a cached accessor layer, and the ConfigType enum used to select which config to target.String enum identifying which configuration sector to read/write.
| Member | Value | Description |
|---|---|---|
| APP | "app" | Targets AppConfigAPI / app_config.json |
| EDITOR | "editor" | Targets EditorConfigAPI / editor_config.json |
Dataclass holding application-level settings, persisted to config/app_config.json under the "app" key.
| Field | Type | Default | Description |
|---|---|---|---|
| semantic_search_length | int | 2 | Default number of results for semantic search |
| semantic_search_cutoff | float | 0.65 | Default similarity cutoff for semantic search |
| distance_search_length | int | 1 | Default number of results for fuzzy/distance search |
| distance_search_cutoff | float | 0.5 | Default similarity cutoff for fuzzy/distance search |
| command_stack_length | int | 15 | Maximum size of the command history stack |
| ide_executable_path | str | "" | Path to an external IDE executable, if configured |
| Method | Description |
|---|---|
init_config() classmethod | Loads config/app_config.json, extracts the "app" key, and returns a new AppConfigAPI instance built from it |
set_config(attr, new_value) classmethod | Sets attr on the class, then updates and rewrites the "app" section of app_config.json with the new value |
SearchAPI; note that SearchAPI's methods do not currently read from this config automatically — the values must be passed in explicitly.Dataclass holding canvas/editor appearance and behavior settings, persisted to config/editor_config.json under the "editor" key.
| Field | Type | Default | Description |
|---|---|---|---|
| handle_size | int | 40 | Size of item resize/rotate handles |
| handle_color | str | "#4A90D9" | Fill color of item handles |
| handle_outline_thickness | float | 1.5 | Outline stroke width of item handles |
| handle_outline_color | str | "#FFFFFF" | Outline color of item handles |
| min_item_size | int | 40 | Minimum allowed size (px) for a resizable item |
| canvas_height | int | 800 | Default canvas height |
| sidebar_default | int | 200 | Default sidebar width |
| sidebar_min | int | 200 | Minimum sidebar width |
| sidebar_standby | int | 300 | Sidebar width in standby/collapsed-adjacent state |
| sidebar_max | int | 700 | Maximum sidebar width |
| is_draw_ruled_lines | bool | True | Whether ruled grid lines are drawn on the canvas |
| ruled_line_interval | int | 100 | Spacing (px) between ruled lines |
| ruled_line_thin_thickness | float | 1.0 | Stroke width of minor ruled lines |
| ruled_line_thick_thickness | float | 1.5 | Stroke width of major ruled lines |
| ruled_line_thich_color | str | "#505050" | Color of major ruled lines (note: field name is spelled "thich", not "thick") |
| ruled_line_thin_color | str | "#3C3C3C" | Color of minor ruled lines |
| scaling_step | float | 0.1 | Increment used when scaling items via keyboard/shortcut |
| canvas_bg_color | str | "#1E1E1E" | Canvas background color |
| image_item_frame_color | str | "#4A90D9" | Border color drawn around selected image items |
| image_item_frame_thickness | float | 4.0 | Border stroke width around selected image items |
| memo_paper_color | str | "#FFFDF0" | Background color of memo notes |
| memo_text_color | str | "#333333" | Text color of memo notes |
| memo_text_font_size | int | 180 | Font size of memo note text |
| memo_text_font | str | "Yu Gothic" | Font family of memo note text |
| memo_text_margin | int | 20 | Inner padding of memo notes |
| command_line_text_color | str | "#FFFFFF" | Text color of the command line widget |
| command_line_bg_color | str | "#303030" | Background color of the command line widget |
| splitter_handle_width | int | 10 | Width of draggable splitter handles |
| Method | Description |
|---|---|
init_config() classmethod | Loads config/editor_config.json, extracts the "editor" key, and returns a new EditorConfigAPI instance built from it |
set_config(attr, new_value) classmethod | Sets attr on the class, then updates and rewrites the "editor" section of editor_config.json with the new value |
Cached accessor layer sitting in front of AppConfigAPI / EditorConfigAPI, so config files are only read from disk once per session.
| Method | Description |
|---|---|
app_config() classmethod | Returns the cached AppConfigAPI instance, lazily calling AppConfigAPI.init_config() on first access |
editor_config() classmethod | Returns the cached EditorConfigAPI instance, lazily calling EditorConfigAPI.init_config() on first access |
set_config(sector, attr_name, new_value) classmethod | Dispatches to AppConfigAPI.set_config() or EditorConfigAPI.set_config() based on sector (a ConfigType); does nothing (returns None) for an unrecognized sector |
_app_config_instance / _editor_config_instance is cached, subsequent calls to app_config() / editor_config() do not re-read the JSON file — only set_config() writes changes back to disk.ResourcesAPI
| Argument | Description |
|---|---|
| data_path | Override for the data directory; defaults to GBVar.DATA_DIR |
Darwin), sets OMP_NUM_THREADS=1 to avoid OpenMP conflicts.Copies an image file into the local resource library directory.
| Argument | Description |
|---|---|
| original_path | Source file path |
| new_path | Destination filename (relative to resources_lib/) |
Checks whether an image (by hash or path) already exists in the resource library.
| Argument | Description |
|---|---|
| img_hash | Precomputed hash; if None, computed from img_path |
| img_path | Image file path; used to compute hash if img_hash is None |
| tolerance | Similarity tolerance for fuzzy matching; 0 = exact match (default: 0) |
| Returns | |
|---|---|
| tuple | (hash_value, exists_flag); both None if neither argument is provided |
Returns the full resource profile dictionary from resources_profile.json.
| Returns | |
|---|---|
| dict | All resource entries; empty dict if the profile file does not exist |
Constructs a profile dictionary for a new resource (does not write to disk).
| Argument | Description |
|---|---|
| img_path | Path to the image |
| name | Display name; defaults to the filename stem |
| memo | Free-text memo; defaults to "" |
| tags | List of tag strings; defaults to [] |
| make_clone_path | If True, stores only the filename (not the full path) in the profile (default: True) |
| Returns | |
|---|---|
| dict | Profile with keys path, name, memo, tags |
Writes or updates a single resource entry in resources_profile.json.
| Argument | Description |
|---|---|
| pointer | Unique hash identifier for the resource |
| profile | Profile data; must contain a "path" key |
| merge | If True, merges with the existing profile instead of replacing (default: False) |
| Returns | |
|---|---|
| bool | True on success; False if "path" is missing from profile |
Imports an image into the resource library: adds its hash, writes its profile, and optionally copies the file.
| Argument | Description |
|---|---|
| img_hash | Precomputed hash; computed from img_path if None |
| img_path | Source image path |
| profile | Resource profile dictionary |
| skip_existencce_check | If True, skips duplicate detection (default: True) |
| tolerance | Hash similarity tolerance for duplicate check (default: 0) |
| make_clone | If True, copies the file into the repository (default: True) |
| Returns | |
|---|---|
| bool | True on success; False if the resource already exists (when check is enabled) or if both hash and path are None |
skip_existencce_check contains a typo (existencce). Use it as-is in your code.Resolves a resource pointer (hash) to its absolute file path.
| Returns | |
|---|---|
| str | None | Absolute path string, or None if not found |
Finds the resource pointer associated with a stored relative path.
| Returns | |
|---|---|
| str | None | Pointer string, or None if not found |
Looks up the relative path for a resource by its display name.
| Returns | |
|---|---|
| str | None | Relative path string, or None if not found |
Returns all resource pointers that have the specified tag.
| Returns | |
|---|---|
| list[str] | List of matching pointer strings |
Returns all resource pointers matching the specified category.
| Returns | |
|---|---|
| list[str] | List of matching pointer strings |
pass. Not yet available.Updates the memo field of a resource profile in place.
| Argument | Description |
|---|---|
| pointer | Resource hash |
| memo_text | New memo content |
Appends or removes tags from a resource's profile.
| Argument | Description |
|---|---|
| pointer | Resource hash |
| tags | Tags to add or remove |
| mode | "append" adds new tags (deduplicates); "remove" removes specified tags (default: "append") |
pointer is not in the current profile or if mode is unrecognized.SearchAPI
Initializes UseVector, SearchBase, and FaissIndexBase internally.
Adds a keyword to the FAISS vector index and the in-memory search base.
| Argument | Description |
|---|---|
| kw | Keyword string to index |
Searches for the most semantically similar keywords to the query using the FAISS index.
| Argument | Description |
|---|---|
| kw | Query keyword |
| return_num | Maximum number of results to return (default: 3) |
| cutoff | Minimum similarity score required for a result to be included (default: 0.65) — newly exposed as an argument; previously hardcoded |
| Returns | |
|---|---|
| list[str] | List of matching keyword strings; may be shorter than return_num if the search base is small or the cutoff excludes matches |
cutoff are excluded.Performs semantic search and maps the results back to resource pointers.
| Argument | Description |
|---|---|
| kw | Query keyword |
| return_num | Number of results to return (default: 3) |
| cutoff | Minimum similarity score passed through to semantic_search_kw() (default: 0.65) |
| Returns | |
|---|---|
| list[str | None] | List of length return_num; positions without a matching pointer contain None |
"memo" field of each resource profile.Searches for resources by fuzzy string matching on display names using difflib.
| Argument | Description |
|---|---|
| kw | Query string |
| return_num | Maximum number of results (default: 3) |
| cutoff | Minimum similarity score [0.0, 1.0]; results below this are discarded (default: 0.5) |
| Returns | |
|---|---|
| list[str] | List of resource pointer strings matching the name query |
cutoff argument is now correctly forwarded to difflib.get_close_matches(). (Previously this was hardcoded to 0.5 internally and the passed value was ignored — that bug has been resolved.)