By now, my main app file is getting a bit big and I would like to split out some code, such as the event handlers into a separate file, but being new to python, I have no idea how or where I would import the routines.
For instance, I currently have a stub in my main class
which I would like to move to a secondary file called mainHelper.py in a way where it will still be called as a member of my main frame class and show or hide the log window.
Being very new to python, I am not having much luck.
I have tried to import the file at the very top, as well as part of the main frame init but no luck at all. As long as the code is in the helper file, it does not get called.
Thank you both.
Your replies lead me to investigate super() in a bit more detail and now I have another question, or more likely an extension to my first one.
One of the things, I forgot to mention initially, that my main frame is already inheriting from a class created by my wxFormBuilder (wxFB) GUI builder.
And, reading up on super(), has me even more confused, particularly wondering if all of the classes created by wxFB, should include a super() call and since they do not, whether there is a work around or whether it does not matter.
Right now, the start of my main frame looks like:
#import the wxFB created GUI file
import wpBgBase
class MyFrameAui(wpBgBase.MyFrameAui):
def __init__(self,parent):
sys.excepthook = MyExceptionHook
super().__init__(None)
wpBgBase.MyFrameAui.__init__(self,parent)
I have sort of given up for now and keep everything in my main file, just so I can get on with getting the main functionality working and get the job done.
The finer details will, hopefully, become clearer with time and experience and then perhaps I can split things up a bit.
the purpose of super is pretty simple (from the docs):
This is useful for accessing inherited methods that have been overridden in a class.
in your example itâs the method __init__ which is in your class MyFrameAuiand in the base class wpBgBase.MyFrameAui (presumably)
using super avoids using the base class textually which may change
what you have done is using both versions and that is definitely one too much
(in case of multiple base classes, as @RichardT suggested, matters get a bit more intersting )
Yeah, well, that âpresumptionâ does not seem to apply.
I have looked at the base code generated by wxFormBuilder and I cannot find any call to super() in its âinitâ.
I have posted a question regarding this issue on the wxFB GitHub page, but have not had any reply to that.
Seems rather basic to me since , as far as I understand things, the wxFB code typically is intended to be base class for the working code, but then, I am very much a newb as far as Python & wxPython goes.
The site âbotâ told me to come down here and check up on you little hellions⌠Believe that! No shit. Carry on punks. Stay cool. Else the wrath of tomorrow comesâŚ