This is a trivial question but I have tried to answer it by myself and also posted a question at StackOverflow with no results so here it goes. I hope this is the right place to ask this question.
Basically, I want to have a custom ControlBar in the PreviewFrame for printing.
For this, I have to override the method CreateControlBar from the wx.PreviewFrame class, right?.
I guess that CreateControlBar will have a line like controlbar = wx.PreviewControlBar() that I need to modify to controlbar = MyPreviewControlBar().
My problem is that I do not know the variable name used by wx.PreviewFrame so I guess I could override the CreateControlBar method with something like theBestEverControlBar = MyPreviewControlBar() and this will be useless because the class will never find the custom controlbar with this unknown pointer, right?
So my general question is:
How are the wxPython files organized? It would be great to have an explanation for the installed package and the developer project in GitHub.
Where can I find the definition of the classes like wx.PreviewFrame or even something more basic like wx.Frame?
Since these classes come from the main namespace I tried to find them in the wx/core.py file but no luck.
Basically, I want to have a custom ControlBar in the PreviewFrame for printing.
In addition to the standard one, or instead of the standard one?
For this, I have to override the method CreateControlBar from the wx.PreviewFrame class, right?.
I guess that CreateControlBar will have a line like controlbar = wx.PreviewControlBar() that I need to modify to controlbar = MyPreviewControlBar().
My problem is that I do not know the variable name used by wx.PreviewFrame so I guess I could override the CreateControlBar method with something like theBestEverControlBar = MyPreviewControlBar() and this will be useless because the class will never find the custom controlbar with this unknown pointer, right?
No. As with most wx classes, the Python code is just jumping into the C++ wxWidgets implementation where the real work is done, so you couldn’t get to the variable anyway.
However, the variable name is unimportant. You just have to create your own control bar. The object’s location is not important; it’s the window parentage hierarchy that controls the plumbing of messages. As long as your control bar is owned by the PreviewFrame, it should work just fine.
How are the wxPython files organized? It would be great to have an explanation for the installed package and the developer project in GitHub.
Where can I find the definition of the classes like wx.PreviewFrame or even something more basic like wx.Frame?
In most cases, the Python code for the standard wxWidgets classes is all automatically generated from the C++ header files, and contains little more than one or two lines of code to map Python types into C++ types and then call the C++ functions.
···
On Apr 27, 2019, at 2:46 AM, Kenny <kenny.bravo85@gmail.com> wrote:
—
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Basically, I want to have a custom ControlBar in the PreviewFrame for printing.
In addition to the standard one, or instead of the standard one?
I want to remove the zoom function from the ControlBar so, instead of the standard one.
For this, I have to override the method CreateControlBar from the wx.PreviewFrame class, right?.
I guess that CreateControlBar will have a line like controlbar = wx.PreviewControlBar() that I need to modify to controlbar = MyPreviewControlBar().
My problem is that I do not know the variable name used by wx.PreviewFrame so I guess I could override the CreateControlBar method with something like theBestEverControlBar = MyPreviewControlBar() and this will be useless because the class will never find the custom controlbar with this unknown pointer, right?
No. As with most wx classes, the Python code is just jumping into the C++ wxWidgets implementation where the real work is done, so you couldn’t get to the variable anyway.
However, the variable name is unimportant. You just have to create your own control bar. The object’s location is not important; it’s the window parentage hierarchy that controls the plumbing of messages. As long as your control bar is owned by the PreviewFrame, it should work just fine.
Then something like:
theBestEverControlBar = MyPreviewControlBar(self)
in the overriding CreateControlBar method of the custom class MyPreviewFrame(wx.PreviewFrame) should actually work?
How are the wxPython files organized? It would be great to have an explanation for the installed package and the developer project in GitHub.
Where can I find the definition of the classes like wx.PreviewFrame or even something more basic like wx.Frame?
In most cases, the Python code for the standard wxWidgets classes is all automatically generated from the C++ header files, and contains little more than one or two lines of code to map Python types into C++ types and then call the C++ functions.
Ok. I will read about using C++ routines in Python and will come back to the code in GitHub. Any recommended tutorial?
···
On Saturday, April 27, 2019 at 10:12:33 PM UTC+2, Tim Roberts wrote: