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

Add wxHelpController to wxPython #1536

Closed
ricpol opened this issue Mar 2, 2020 · 12 comments · Fixed by #1538 or #1550
Closed

Add wxHelpController to wxPython #1536

ricpol opened this issue Mar 2, 2020 · 12 comments · Fixed by #1538 or #1550

Comments

@ricpol
Copy link
Contributor

ricpol commented Mar 2, 2020

Can we have wxHelpController please? It's quite a hole now, because wx.HelpControllerBase can't be istantiated/subclassed and therefore also wx.HelpControllerHelpProvider cannot be used... I know, I know... who needs those anyways? But still...
Thanks a lot!

@RobinD42
Copy link
Member

RobinD42 commented Mar 2, 2020

wxHelpController is really just an alias to whatever controller is best for the platform. See https://github.com/wxWidgets/wxWidgets/blob/master/include/wx/help.h for details. We already have wrappers for wxHtmlHelpController and wxExtHelpController available, (in wx.html and wx.adv respectively) so you can always instantiate one of those directly and use it with HelpControllerHelpProvider.

That said, it's high time I add wrappers for wxCHMHelpController too. I originally back-burnered it until I had the module for msw-only items, and then forgot about it when wx.msw did get added. I've now got a branch underway for adding it, and I'll also add a factory function for wx.HelpController that works at runtime the same way that is done at compile-time for the C++ implementation.

@ricpol
Copy link
Contributor Author

ricpol commented Mar 3, 2020

Thanks a lot! And yes, I was hoping for CHMHelpController too...

Note however that you cannot really use ExtHelpController with HelpControllerHelpProvider because this works by calling HelpController.DisplayContentPopup which does nothing useful there. I think that HtmlHelpController could work this way though...

@ricpol
Copy link
Contributor Author

ricpol commented Mar 3, 2020

Uhm... on a second thought, this is not exactly what I was looking for... I didn't realize that wxHelpController was just an alias...
From the point of view of a wxPython user, the problem is that wx.HelpControllerBase is not subclassable. So I hoped that wx.HelpController was a simple generic implementation which in turn could be subclassed, just the way wx.SimpleHelpProvider is to wx.HelpProvider.
What I'm looking for, is a way to make my own help controller featuring a different behaviour than CHMHelp, ExtHelp or HtmlHelp...
Oh well, I think I will just forget about if entirely and start over with a pure-Python implementation of the whole thing...

Thank you anyways!

@RobinD42
Copy link
Member

What problems did you have trying to subclass HelpControllerBase? If you provide implementations for all the C++ pure virtual methods then it should work. The pure virtuals (at least in 4.1) are:

  • DisplayBlock
  • DisplayContents
  • DisplaySection
  • KeywordSearch
  • LoadFile
  • Quit

@ricpol
Copy link
Contributor Author

ricpol commented Mar 14, 2020

Yes but...

>>> wx.version()
'4.1.0a1.dev4596+adaaf766 msw (phoenix) wxWidgets 3.1.4'
>>> class MyHC(wx.HelpControllerBase):
...   def DisplayBlock(self, n): pass
...   def DisplayContents(self): pass
...   def DisplaySection(self, *a, **k): pass
...   def KeywordSearch(self, key, mode): pass
...   def LoadFile(self, f): pass
...   def Quit(self): pass
... 
>>> c = MyHC()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: wx._core.HelpControllerBase cannot be instantiated or sub-classed

@RobinD42
Copy link
Member

wxHelpControllerBase was explicitly tagged as abstract and it doesn't need to be. Fix on the way.

@ricpol
Copy link
Contributor Author

ricpol commented Mar 17, 2020

I knew it! Thanks again!

Uhm, now I know this rabbit hole keeps getting deeper and deeper, but while you're at it could you please look at yet another small detail?
The thing is that wx.HelpControllerHelpProvider is supposed to make use of wx.HelpControllerBase.DisplayContextPopup. But this method is not really implemented in the concrete controllers (HtmlHelpController, ExtHelpController, CHMHelpController), am I right?

@RobinD42
Copy link
Member

@RobinD42
Copy link
Member

Oops, you asked about DisplayContextPopup... There is an implementation for that in helpchm.cpp a few lines further down. I'll take a look at the others...

@RobinD42
Copy link
Member

Yeah, it looks like CHMHelpController is the only one that has a non-default implementation of DisplayContextPopup

@ricpol
Copy link
Contributor Author

ricpol commented Mar 18, 2020

That's what I thought... thanks for confirming, sometimes I get lost in wxWidgets code...
Well, in order to have HelpControllerHelpProvider working as expected, I suppose one could subclass the controllers and implement the missing method. However, this way you couldn't use the generic cross-platform HelpController any more, since of course it doesn't know about your own subclasses... So, turns out that adding HelpController to wxPython is not enough...

...unless... well I guess a real Python programmer would solve the problem in no time by monkey-patching the missing methods right into the original classes... ;-)
Anyways, I think this closes the issue for real... Thanks again for all the help!

@RobinD42
Copy link
Member

This issue has been mentioned on Discuss wxPython. There might be relevant details there:

https://discuss.wxpython.org/t/wxpython-4-1-0-released/34564/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants