Skip to content

Commit

Permalink
FIX: Closer
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Feb 11, 2025
1 parent aebbffa commit 27c1eda
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 42 deletions.
8 changes: 1 addition & 7 deletions spyder/app/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
# Avoid a "Cannot mix incompatible Qt library" error on Windows platforms
from qtpy import QtSvg # analysis:ignore

# Avoid a bug in Qt: https://bugreports.qt.io/browse/QTBUG-46720
try:
from qtpy.QtWebEngineWidgets import WEBENGINE
except ImportError:
WEBENGINE = False

from qtawesome.iconic_font import FontError

#==============================================================================
Expand Down Expand Up @@ -88,7 +82,7 @@
from spyder.utils.icon_manager import ima
from spyder.utils.misc import select_port, getcwd_or_home
from spyder.utils.palette import SpyderPalette
from spyder.utils.qthelpers import file_uri, qapplication, start_file
from spyder.utils.qthelpers import file_uri, qapplication, start_file, WEBENGINE
from spyder.utils.stylesheet import APP_STYLESHEET

# Spyder API Imports
Expand Down
18 changes: 10 additions & 8 deletions spyder/plugins/application/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from spyder.plugins.application.widgets import AboutDialog, InAppAppealStatus
from spyder.plugins.console.api import ConsoleActions
from spyder.utils.environ import UserEnvDialog
from spyder.utils.qthelpers import start_file, DialogManager
from spyder.utils.qthelpers import start_file, DialogManager, WEBENGINE
from spyder.widgets.dependencies import DependenciesDialog
from spyder.widgets.helperwidgets import MessageCheckBox

Expand Down Expand Up @@ -97,7 +97,8 @@ def setup(self):

# Attributes
self.dialog_manager = DialogManager()
self.inapp_appeal_status = InAppAppealStatus(self)
if WEBENGINE:
self.inapp_appeal_status = InAppAppealStatus(self)

# Actions
# Documentation actions
Expand Down Expand Up @@ -138,12 +139,13 @@ def setup(self):
_("Spyder support..."),
triggered=lambda: start_file(__forum_url__))

self.create_action(
ApplicationActions.HelpSpyderAction,
_("Help Spyder..."),
icon=self.create_icon("inapp_appeal"),
triggered=self.inapp_appeal_status.show_appeal
)
if WEBENGINE:
self.create_action(
ApplicationActions.HelpSpyderAction,
_("Help Spyder..."),
icon=self.create_icon("inapp_appeal"),
triggered=self.inapp_appeal_status.show_appeal
)

# About action
self.about_action = self.create_action(
Expand Down
16 changes: 10 additions & 6 deletions spyder/plugins/application/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from spyder.plugins.console.api import ConsoleActions
from spyder.plugins.mainmenu.api import (
ApplicationMenus, FileMenuSections, HelpMenuSections, ToolsMenuSections)
from spyder.utils.qthelpers import add_actions
from spyder.utils.qthelpers import add_actions, WEBENGINE


class Application(SpyderPluginV2):
Expand Down Expand Up @@ -101,8 +101,9 @@ def on_editor_available(self):
@on_plugin_available(plugin=Plugins.StatusBar)
def on_statusbar_available(self):
statusbar = self.get_plugin(Plugins.StatusBar)
inapp_appeal_status = self.get_container().inapp_appeal_status
statusbar.add_status_widget(inapp_appeal_status)
if WEBENGINE:
inapp_appeal_status = self.get_container().inapp_appeal_status
statusbar.add_status_widget(inapp_appeal_status)

# -------------------------- PLUGIN TEARDOWN ------------------------------
@on_plugin_teardown(plugin=Plugins.Preferences)
Expand Down Expand Up @@ -130,8 +131,9 @@ def on_main_menu_teardown(self):
@on_plugin_teardown(plugin=Plugins.StatusBar)
def on_statusbar_teardown(self):
statusbar = self.get_plugin(Plugins.StatusBar)
inapp_appeal_status = self.get_container().inapp_appeal_status
statusbar.remove_status_widget(inapp_appeal_status.ID)
if WEBENGINE:
inapp_appeal_status = self.get_container().inapp_appeal_status
statusbar.remove_status_widget(inapp_appeal_status.ID)

def on_close(self, _unused=True):
self.get_container().on_close()
Expand All @@ -158,7 +160,9 @@ def on_mainwindow_visible(self):

# Show appeal the fifth and 25th time Spyder starts
spyder_runs = self.get_conf("spyder_runs_for_appeal", default=1)
if spyder_runs in [5, 25]:
if not WEBENGINE:
pass
elif spyder_runs in [5, 25]:
container.inapp_appeal_status.show_appeal()

# Increase counting in one to not get stuck at this point.
Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/application/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"""Widgets for the Application plugin."""

from .about import AboutDialog # noqa
from .status import InAppAppealStatus # noqa
#from .status import InAppAppealStatus # noqa
3 changes: 2 additions & 1 deletion spyder/plugins/application/widgets/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from spyder.utils.icon_manager import ima
from spyder.utils.qthelpers import start_file
from spyder.utils.stylesheet import WIN
from spyder.widgets.browser import WebView


class InAppAppealDialog(QDialog, SpyderFontsMixin):
Expand Down Expand Up @@ -53,6 +52,8 @@ def __init__(self, parent=None):
)

# Create webview to render the appeal message
from spyder.widgets.browser import WebView

webview = WebView(self, handle_links=True)

# Set font used in the view
Expand Down
8 changes: 1 addition & 7 deletions spyder/plugins/help/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,11 @@
from spyder.utils import programs
from spyder.utils.image_path_manager import get_image_path
from spyder.utils.palette import SpyderPalette
from spyder.utils.qthelpers import start_file
from spyder.utils.qthelpers import start_file, WEBENGINE
from spyder.widgets.comboboxes import EditableComboBox
from spyder.widgets.findreplace import FindReplace
from spyder.widgets.simplecodeeditor import SimpleCodeEditor

# In case WebEngine is not available (e.g. in Conda-forge)
try:
from qtpy.QtWebEngineWidgets import WEBENGINE
except ImportError:
WEBENGINE = False


# --- Constants
# ----------------------------------------------------------------------------
Expand Down
7 changes: 1 addition & 6 deletions spyder/plugins/ipythonconsole/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,12 @@
from spyder.utils import encoding, sourcecode
from spyder.utils.misc import get_error_match, remove_backslashes
from spyder.utils.palette import SpyderPalette
from spyder.utils.qthelpers import WEBENGINE
from spyder.utils.stylesheet import AppStyle
from spyder.widgets.findreplace import FindReplace
from spyder.widgets.tabs import Tabs
from spyder.widgets.printer import SpyderPrinter

# In case WebEngine is not available (e.g. in Conda-forge)
try:
from qtpy.QtWebEngineWidgets import WEBENGINE
except ImportError:
WEBENGINE = False


# Logging
logger = logging.getLogger(__name__)
Expand Down
7 changes: 1 addition & 6 deletions spyder/plugins/onlinehelp/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@
from spyder.api.translations import _
from spyder.api.widgets.main_widget import PluginMainWidget
from spyder.plugins.onlinehelp.pydoc_patch import _start_server, _url_handler
from spyder.utils.qthelpers import WEBENGINE
from spyder.widgets.comboboxes import UrlComboBox
from spyder.widgets.findreplace import FindReplace

# In case WebEngine is not available (e.g. in Conda-forge)
try:
from qtpy.QtWebEngineWidgets import WEBENGINE
except ImportError:
WEBENGINE = False


# --- Constants
# ----------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions spyder/utils/qthelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
QWidget,
)

# Avoid a bug in Qt: https://bugreports.qt.io/browse/QTBUG-46720
# And in case WebEngine is not available (e.g. in Conda-forge)
try:
from qtpy.QtWebEngineWidgets import WEBENGINE
except ImportError:
WEBENGINE = False

# Local imports
from spyder.api.config.mixins import SpyderConfigurationAccessor
from spyder.api.fonts import SpyderFontsMixin, SpyderFontType
Expand Down

0 comments on commit 27c1eda

Please sign in to comment.