I have a setup where I have 3 different files (for a mud client
lyntin) where the user interface is in wxpython. So the overarching
module is lyntin which in turn inherits the GUI/other files. Without
going into extreme detail, my question in essence is how can I control
a wxPython frame/etc. from another inherited file? A way to think
about this is there are 3 files, A, B, and C. B and C are both
inheritted by A, so I can retrieve pointers/frames/etc from C. I have
this code in file "C" that is called by A.
def AddRemoteFrame(self, framename, **keywords):
"""
Adds frame from module using the master frame, parent is our
Toplevelwindow
"""
self.windows[framename] = wx.Frame(self.parent,
-1,title=keywords['title'], name=framename)
self.parent._mgr.AddPane(self.windows[framename],
wx.aui.AuiPaneInfo().Float().Dockable())
self.parent._mgr.Update()
It works and adds the frame, but it freezes upon Update(). Is there a
guide/resource I can go to for this type of activity? I don't want to
cram everything in one file.
I think you are confusing the concepts of file, module and class. A .py file contains the source code that creates a Python module object when it is imported. For example, this will execute the code in foo.py (if it hasn't been already) and will create a module object:
import foo
After this statement then the foo variable is a reference to a module object that contains the items that were created by the source code in the foo.py file.
You can use the things in the foo module from the module that did the import statement by using the dot notation. For example:
import foo
x = foo.Thing()
The items contained in the module can be things like functions, classes, values, etc.
So back to your question, to use classes defined in other modules you just have to import that module and then use the dot notation to get access to the other class. Whether is is for subclassing another class from it, or for creating instances of it or whatever you use the same dot notation. If you need to call methods of an instance of that class then you handle that the same way as you would if they were all in one file, you just save a reference to the instance (probably in self) and then use the dot notation to make the call to the method when you need it.
If I misunderstood and this doesn't answer your question then please ask again and include a small runnable sample so we can better see and understand what you are trying to do. MakingSampleApps - wxPyWiki
···
On 2/2/11 2:54 PM, Chris Mitchell wrote:
I have a setup where I have 3 different files (for a mud client
lyntin) where the user interface is in wxpython. So the overarching
module is lyntin which in turn inherits the GUI/other files. Without
going into extreme detail, my question in essence is how can I control
a wxPython frame/etc. from another inherited file? A way to think
about this is there are 3 files, A, B, and C. B and C are both
inheritted by A, so I can retrieve pointers/frames/etc from C. I have
this code in file "C" that is called by A.
def AddRemoteFrame(self, framename, **keywords):
"""
Adds frame from module using the master frame, parent is our
Toplevelwindow
"""
self.windows[framename] = wx.Frame(self.parent,
-1,title=keywords['title'], name=framename)
self.parent._mgr.AddPane(self.windows[framename],
wx.aui.AuiPaneInfo().Float().Dockable())
self.parent._mgr.Update()
It works and adds the frame, but it freezes upon Update(). Is there a
guide/resource I can go to for this type of activity? I don't want to
cram everything in one file.