Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stginga to handle changes to the Ginga help system in release v5.0 #234

Merged
merged 5 commits into from
Feb 15, 2024

Conversation

ejeschke
Copy link
Collaborator

@ejeschke ejeschke commented Jan 25, 2024

Description

This pull request fixes stginga plugin help so that it works with changes to the help system to be made in ginga release v5.0. Both help for stginga and ginga plugins is supported.

@ejeschke
Copy link
Collaborator Author

@pllim, this is for the PR to remove WBrowser upstream.
I've tested it with stginga and the 4 local plugins that are typically used in stginga. Can you try it? Note that you will need to install the PR for ginga referred to above. In my testing, I typically installed stginga, and then installed the ginga PR afterwards.

This makes it behave similarly to the way help will work for other ginga plugins.

@pllim pllim added this to the 1.5.0 milestone Jan 31, 2024
@pllim
Copy link
Contributor

pllim commented Jan 31, 2024

Thanks! I'll have a look soon.

@pllim
Copy link
Contributor

pllim commented Feb 2, 2024

It seems like this patch is not compatible with Ginga 4.1.1 because I see the following traceback:

Error making callback 'activated': 'GingaShell' object has no attribute 'help_plugin'
Traceback:
  File "C:\...\ginga\misc\Callback.py", line 154, in _do_callbacks
    res = method(*cb_args, **cb_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\...\stginga\plugins\DQInspect.py", line 225, in <lambda>
    btn.add_callback('activated', lambda w: self.help())
                                            ^^^^^^^^^^^

  File "C:\...\stginga\plugins\local_plugin_mixin.py", line 36, in help
    self.fv.help_plugin(self, url=url)
    ^^^^^^^^^^^^^^^^^^^

What would be the best way to make this work for both Ginga 4.x and 5.x? 🤔

@ejeschke
Copy link
Collaborator Author

ejeschke commented Feb 3, 2024

@pllim, try this update. I think this will fix the issue if you have updated stginga with ginga v4.x. Although one solution is to simply specify ginga>=5.0 in your setup.cfg. The version in there now (2.7) is terribly old. Maybe at least update to ginga>=4.1.1?

Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are almost there but I encountered some weird behaviors. Are these intentional? Please see comments. Thanks!

I also pushed a commit to bump minversions, as you requested.

if not self.fv.gpmon.has_plugin('WBrowser'):
self._help_docstring()
return
if self.fv.gpmon.has_plugin('WBrowser') and Widgets.has_webkit:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My clean installation didn't pick up webkit. I cannot find any python-webkit on PyPI. How do I install it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In conda it can be installed by pyqtwebengine. It looks like PyPI has PyQtWebEngine, but I would install it via the same package manager as you installed pyqt otherwise you are likely to run into problems. This is one reason I want to get rid of it--it doesn't seem to be installed by default when one installs pyqt.


obj = self.fv.gpmon.get_plugin('WBrowser')
if not hasattr(self.fv, 'help_plugin'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Ginga 4, because I don't have python-webkit, I hit this line but only if I do not have docutils installed. I noticed it because the terminal complains about 'publish_string' is not defined.

However, when I install docutils, I do not hit this, instead Ginga now tries to fire up WBrowser and complains that I do not have webkit. 🤯

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the web browser widget does not seem to be installed by default when you install qt, and unfortunately, in Ginga 4 this does not disable WBrowser. Instead, when you start WBrowser, it tells you to install webkit to get things working. (Qt has changed the name of their version of webkit and in Qt 5 it's name is qtwebengine AFAIK).

Without a working WBrowser, in Ginga 4 it will attempt to fall back to _help_docstring() which in Ginga 4 will attempt to use docutils (another thing I am getting rid of). I've updated this PR so that it will use an stginga version of _help_docstring, which will punt directly to showing the RST text. Give it a try and LMK how it goes.

@pllim
Copy link
Contributor

pllim commented Feb 6, 2024

ginga>=5.0

I think it is too early to require ginga>=5, especially since it is not even released yet. Also, usually users are slow to upgrade, especially for major releases with breaking changes.

@ejeschke
Copy link
Collaborator Author

ejeschke commented Feb 7, 2024

Another possibility with this PR is to just do similar to what Ginga is doing with v5 and just punt directly to python standard library webrowser to open the link externally. That would make things work so long as they have an online connection.

@pllim
Copy link
Contributor

pllim commented Feb 7, 2024

That would make things work so long as they have an online connection.

That would be acceptable if it is much simpler to implement. STScI never imposed the rule of offline docs via stginga interface. Usually if they need the software for offline use, they clone the whole repo anyway, so documentation is available one way or another. Thanks!

@ejeschke
Copy link
Collaborator Author

ejeschke commented Feb 7, 2024

Ok, sounds good. I'll update this PR today.

@ejeschke
Copy link
Collaborator Author

ejeschke commented Feb 7, 2024

This latest fix should remove any problems with the WBrowser being present or working. It just opens the help in an external browser if working with a ginga < v5.

Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works now. Thanks!

@pllim pllim merged commit 01e377c into spacetelescope:master Feb 15, 2024
10 checks passed
@ejeschke ejeschke deleted the fix-help branch February 25, 2024 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants