why specify parent when using xrc?

When using a resource from an xrc file, why should the parent have to be specified since the xml format contains parent-child relationships?

Example: EVT_MENU(self.menu,XRCID("Exit"), self.Exit)

In the xrc file, the menu item is a child of the menu. So why do I have to specify it here? I'm new to wxpython, so I may be missing something obvious.

Randall

Maybe Robin is more competent to answer this, but I'm trying anyways:
you are using a generic wxPython Macro (EVT_MENU) which is not specifically
designed for xrc. One uses the same macro if you don't use xrc at all,
therefor you have to specify the parent.
Even in conjunction with xrc it makes sense. Your xrc-file can contain 100
dialogs and each of them might have an ID called "Close" or "Exit".
Which one should be used then if you don't specify the environment ?
As you can see, the macro has no context (ala self.EVT_MENU), so asigning the
request to a specific object makes a lot of sense :slight_smile:

Hope that explains it.

When using a resource from an xrc file, why should the parent have to be
specified since the xml format contains parent-child relationships?

Example: EVT_MENU(self.menu,XRCID("Exit"), self.Exit)

In the xrc file, the menu item is a child of the menu. So why do I have
to specify it here? I'm new to wxpython, so I may be missing something
obvious.

Randall

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

- --
  UC

- --
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417

···

On Tuesday 07 October 2003 10:56 pm, Randall Smith wrote:

Randall Smith wrote:

When using a resource from an xrc file, why should the parent have
to be specified since the xml format contains parent-child
relationships?

Example: EVT_MENU(self.menu,XRCID("Exit"), self.Exit)

There is no parent being specified here. You are binding even with ID
XRCID("Exit") that is fired in object self.menu to function
self.Exit.

VS

···

--
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x465264C9

Randall Smith wrote:

When using a resource from an xrc file, why should the parent have to be specified since the xml format contains parent-child relationships?

Example: EVT_MENU(self.menu,XRCID("Exit"), self.Exit)

In the xrc file, the menu item is a child of the menu. So why do I have to specify it here? I'm new to wxpython, so I may be missing something obvious.

wxMenuItem does not derive from wxEvtHandler so events can not be delivered to it. The first parameter to the EVT_ functions is the wxEvtHandler where you expect the event to be delivered to, and is used as the point to Connect() the handler function.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Randall Smith wrote:

When using a resource from an xrc file, why should the parent have to be specified since the xml format contains parent-child relationships?

Example: EVT_MENU(self.menu,XRCID("Exit"), self.Exit)

In the xrc file, the menu item is a child of the menu. So why do I have to specify it here? I'm new to wxpython, so I may be missing something obvious.

wxMenuItem does not derive from wxEvtHandler so events can not be delivered to it. The first parameter to the EVT_ functions is the wxEvtHandler where you expect the event to be delivered to, and is used as the point to Connect() the handler function.

Thanks,

It's all clear now.

Randall