0

I have a class A (wx.Panel) which I believe is its parent class and this panel has been created using automatically generated wxGlade code and it has the init as

wx.Panel.__init__(self, *args, **kwds)

now Class B inherits class A. Class B(class A) and the init for class B is

def __init__(self, *args, **kw):
    A.__init__(self, *args, **kw)

When I try to create an object of class B, how should i instantiate it?

obj = B(). I know I cannot have a None because a parent is definitely needed. Why do I land in the error "in method 'new_panel' expected argument 1 of type wxWindow*"

-B

Avi Turner
  • 10,234
  • 7
  • 48
  • 75
user2939055
  • 157
  • 1
  • 3
  • 14

1 Answers1

1

just like you would instantiate a wxPanel

f=wx.Frame(None,-1,"Some Frame")
b = B(f,-1) 
f.Show()
Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
  • I am still not very sure if I get that. I changed a few things around.I have a "class A(wx.ScrolledWindow)" and "class B" is the child inherited from "Class A". "Class B" has init -> "def __init__(self, parent, *args, **kw):" and " A.__init__(self, parent, *args, **kw)". If I want to instantiate "Class B" inside a global function, like obj = class B() -- what parameters would i pass to it? – user2939055 Nov 01 '13 at 23:15
  • you just need to pass it a parent window as the first argument ... in my example the frame is the parent window (`-1` just means auto-assign the window ID which is what you almost always want to do) ... a panel must be attached to another panel or a frame (or some other wxWidget) – Joran Beasley Nov 01 '13 at 23:18
  • Do you mean obj = wx.ScrolledWindow(-1)?. I thought the parent class name was needed for instantiation ..Also this is a global function inside which I am instantiating. Could you please explain it to me exactly what it would look like based on my first comment for your answer? – user2939055 Nov 01 '13 at 23:21
  • no ... parent is a parent window ... not a parent class ... just run my example solution... the frame,f is the parent window, that B is attached to ... but B inherits its class from its class parent(wx.ScrolledPanel) ... they are different types of parents – Joran Beasley Nov 01 '13 at 23:23
  • I really dont follow- How would I instantiate class B? – user2939055 Nov 01 '13 at 23:28