Skip to content

Commit

Permalink
Delayed initialization (accelerate startup)
Browse files Browse the repository at this point in the history
  • Loading branch information
howetuft committed Jul 23, 2024
1 parent 96fc9db commit 5860b28
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,29 @@
import FreeCAD as App
import FreeCADGui as Gui

# Caveat: do not import Render here (too early, will slow down global startup)


class RenderWorkbench(Gui.Workbench):
"""The Render Workbench."""

def __init__(self):
"""Initialize object."""
# pylint: disable=import-outside-toplevel
from Render.constants import TRANSDIR
# Caveat: do not import Render here
# (too early, will slow down global startup)

from FreeCADGui import addLanguagePath, updateLocale
# pylint: disable=import-outside-toplevel
import FreeCAD

translate = App.Qt.translate
addLanguagePath(TRANSDIR)
updateLocale()
try:
translate = FreeCAD.Qt.translate
except AttributeError:
translate = lambda _, x: x

self.__class__.MenuText = "Render"
self.__class__.ToolTip = translate(
"Workbench",
"The Render workbench is a "
"modern replacement for "
"The Render workbench is a modern replacement for "
"the Raytracing workbench",
)
self.__class__.Icon = """
Expand Down Expand Up @@ -111,9 +114,20 @@ def Initialize(self):
from PySide.QtCore import QT_TRANSLATE_NOOP
from Render.utils import translate
from FreeCAD import Console
from FreeCADGui import addIconPath, addPreferencePage
from Render import RENDER_COMMANDS, ICONDIR, PreferencesPage
from FreeCADGui import (
addIconPath,
addPreferencePage,
addLanguagePath,
updateLocale,
)

from Render import RENDER_COMMANDS, ICONDIR, TRANSDIR, PreferencesPage

# Translations
addLanguagePath(TRANSDIR)
updateLocale()

# GUI
self.appendToolbar(
QT_TRANSLATE_NOOP("Workbench", "Render"), RENDER_COMMANDS
)
Expand Down

0 comments on commit 5860b28

Please sign in to comment.