Nov-01-2019, 07:46 PM
I wanted to get back to you on this.
1st, I appreciate your response. It did help me better understand what I might want to do.
I may still go this route since I would like to divide my code into smaller, more manageable pieces (whatever that may mean :( However, I came across a "solution" that may be better, for the moment. I installed an outliner add on into SublimeText3. That offers me visibility (and easier access) to the classes and methods/functions I create. How that may work as my code continues to grow remains to be seen. Maybe that's when I come back to a more modular approach and figure out how to deal with objects.
What I can do now is put variables and other definitions into modules since most of those are accessed by most, or many, of my routines.
Thanks again for the help. I'll mark this thread solved for now.
1st, I appreciate your response. It did help me better understand what I might want to do.
I may still go this route since I would like to divide my code into smaller, more manageable pieces (whatever that may mean :( However, I came across a "solution" that may be better, for the moment. I installed an outliner add on into SublimeText3. That offers me visibility (and easier access) to the classes and methods/functions I create. How that may work as my code continues to grow remains to be seen. Maybe that's when I come back to a more modular approach and figure out how to deal with objects.
What I can do now is put variables and other definitions into modules since most of those are accessed by most, or many, of my routines.
Thanks again for the help. I'll mark this thread solved for now.
(Oct-20-2019, 05:36 PM)ichabod801 Wrote:(Oct-20-2019, 04:25 PM)profconn1 Wrote: It seems "self" isn't being passed to def PWRToggle(self, event):
That's because when you moved it out of the class and into another module, it stopped being a bound method. Now it's just a function. You could take that function and bind it to the class when it instantiates, but that gets rather deep into the Python internals. When I find myself doing that, I ask myself if there is another way around the problem.
If you need that function to be available to other classes, it would probably be best to make a class with that function as a method, and then subclass from that. So you would have the modularized form be:
class FunctionFrame(wx.Frame): def self.PWRToggle(event): if self.pwr_btn.GetValue() == True: ...And then your main class would inherit from that:
from other_module import FunctionFrame class MainClassWindow(FunctionFrame): def __init__(self): ...If you have some other reason to be modularizing that function, the solution would depend on that reason.