Re: Trouble calling method from one class to another class
john fabiani <[email protected]> Sat, 24 Apr 2021 15:43:55 -0700
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <[email protected]> |
Take my advise with a smile because I am NOT the best programmer. But, I have to say this is some very confusing code pxCore2.py. I believe you do not have a handle on how OOP works within python. Also you copied code directly out of the wxPython demo but lacked the understanding of what was being presented. And I bet this is causing confusion and is also not allowing you to move forward. When you define a class, you don't normally create an instance of the class within the definition of the class. self._MyTreeCtrl = MyTreeCtrl is in the __init__ method of MyTreeCtrl. so comment out "self._MyTreeCtrl = MyTreeCtrl" I believe with wxPython 4.x the super() is used. so wx.TreeCtrl.__init__(self, parent, id, position, size, style) is now super().__init__(parent, id = id, pos= position, size = size, style=style) You can review the what is needed to init wx.TreeCtrl by looking at the method in the source code. In this case there are two signatures: TreeCtrl() or TreeCtrl(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=TR_DEFAULT_STYLE, validator=DefaultValidator, name=TreeCtrlNameStr) Therefore, depending on your needs you could just use: super().__init__() At this point I stopped because the GUI opened and I'm not sure what you are trying to do. If it is to list a directory there is a widget called 'FileDialog'. Johnf On 4/24/21 10:01 AM, RF wrote: > > I'm attaching my small demo test app. I'm having a heck of a time > figuring out how to call add_tab_page() from the MyTreeCtrl class. > This should happen when I just click on a tree node. While this > doesn't seem to make any sense, what I plan to do with this action is > open a new notebook tab and load in the filename into the new tab. But > I have to get past this first: being able to call the add_tab_page() > from the MyTreeCtrl class. > > I'm fairly sure I'm missing something small here. > > Thank you for any help. > -- > You received this message because you are subscribed to the Google > Groups "wxPython-users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/wxpython-users/d1e36c62-125a-425c-947e-7bb5820e0184n%40googlegroups.com > <https://groups.google.com/d/msgid/wxpython-users/d1e36c62-125a-425c-947e-7bb5820e0184n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "wxPython-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/de54d97a-1794-a4ab-45fd-78c96b356c96%40gmail.com.