Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions sample_plugins/materialxjson/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import logging
import os

logger = logging.getLogger(__name__)

# Optional syntax highlighting if pygments is installed
have_highliting = True
try:
Expand All @@ -14,21 +16,27 @@

from typing import TYPE_CHECKING

from qtpy import QtCore # type: ignore
from qtpy.QtWidgets import ( # type: ignore
QAction,
QTextEdit,
)

def load_qt_modules():
global QtCore, QAction, QTextEdit
try:
from qtpy import QtCore # type: ignore
from qtpy.QtWidgets import QAction, QTextEdit # type: ignore
logger.info("qtpy modules loaded successfully")
except ImportError as e:
logger.error(f"Failed to import qtpy modules: {e}")
raise

from QuiltiX import constants, qx_plugin

logger = logging.getLogger(__name__)
has_materialxjsoncore = True

try:
import materialxjson.core as jsoncore
logger.info("materialxjson.core module loaded successfully")
except ImportError:
has_materialxjsoncore = False
logger.error("materialxjson.core module not found")
logger.error("materialxjson.core module failed to load.")

if TYPE_CHECKING:
from QuiltiX import quiltix
Expand Down Expand Up @@ -194,6 +202,7 @@ def show_text_box(self, text, title=""):

@qx_plugin.hookimpl
def after_ui_init(editor: "quiltix.QuiltiXWindow"):
load_qt_modules()
editor.json_serializer = QuiltiX_JSON_serializer(editor, constants.ROOT)


Expand Down