5from __future__
import print_function
13 if pykrita.qt_major_version() == 5:
14 from PyQt5
import QtCore
16 from PyQt6
import QtCore
18 print(
"Python cannot find the Qt%d bindings." % pykrita.qt_major_version(), file=sys.stderr)
19 print(
"Please make sure that the needed packages are installed.", file=sys.stderr)
26pyqt_wrong =
"PyQt" + (
"6" if pykrita.qt_major_version() == 5
else "5")
27pyqt_wrong_casefolded = pyqt_wrong.casefold()
28import_real = builtins.__import__
30 name_casefolded = name.casefold()
31 if name_casefolded == pyqt_wrong_casefolded
or \
32 name_casefolded.startswith(pyqt_wrong_casefolded+
"."):
34 raise(ModuleNotFoundError(
35 f
"This version of Krita is not compatible with {pyqt_wrong}!",
38 return import_real(name, globals, locals, fromlist, level)
39builtins.__import__ = importAvoidWrongPyQtHack
42from .decorators
import *
43from .dockwidgetfactory
import *
44from PyKrita
import krita
47signal.signal(signal.SIGINT, signal.SIG_DFL)
49krita_path = os.path.dirname(os.path.abspath(__file__))
50sys.path.insert(0, krita_path)
51print(
"%s added to PYTHONPATH" % krita_path, file=sys.stderr)
57builtins.i18n = Krita.krita_i18n
58builtins.i18nc = Krita.krita_i18nc
65 '''Use KDE way to show debug info
67 TODO Add a way to control debug output from partucular plugins (?)
69 plugin = sys._getframe(1).f_globals[
'__name__']
70 pykrita.qDebug(
'{}: {}'.format(plugin, text))
73@pykritaEventHandler('_pluginLoaded')
75 if plugin
in init.functions:
77 init.fire(plugin=plugin)
78 del init.functions[plugin]
82@pykritaEventHandler('_pluginUnloading')
84 if plugin
in unload.functions:
86 unload.fire(plugin=plugin)
87 del unload.functions[plugin]
91@pykritaEventHandler('_pykritaLoaded')
93 qDebug(
'PYKRITA LOADED')
97@pykritaEventHandler('_pykritaUnloading')
99 qDebug(
'UNLOADING PYKRITA')
static Krita * instance()
instance retrieve the singleton instance of the Application object.
importAvoidWrongPyQtHack(name, globals=None, locals=None, fromlist=(), level=0)