wxresource xrc

Dear Everyone :slight_smile:

How’s your day?

hehe, i’m james here from malaysia,

I’ve been trying a few tricks with rad tools to generate xrc

but i’m not quite sure how really things should be in the python language.

I’ve went through some samples. but the samples is just ain’t enough.

it only shows poping out a window and that’s it…

but how do i return the button from the xrc file?

i’ll need to run some function when someone click on the button which resides in the wxboxsizer that comes from xrc file.

and i’ve found out there is a problem with the way the xrc is arranged.

eg: wxframe (name: myframe) -> wxpanel(name:mypanel) -> …

when i tried to loadpanel(“mypanel”)

wx runtime will gives out mypanel not found

if the root itself starts with wxpanel without the frame

eg: wxpanel(name:mypanel) -> …

it runs just fine :slight_smile:

y is it this way? is there some kind of loadpanel(“myframe.mypanel”)?

------next-------<>

i’ve another issue, :stuck_out_tongue:

in wxwindows (cpp) version, casting a wxpanel to wxwindow or wxframe to wxwindow is an easy job: xyz = (wxWindow *)(abc)

but how do i cast it in python?

please advise, thank you.

best regards,

James

James Tan wrote:

I've been trying a few tricks with rad tools to generate xrc
but i'm not quite sure how really things should be in the python language.
I've went through some samples. but the samples is just ain't enough.
it only shows poping out a window and that's it...
but how do i return the button from the xrc file?
i'll need to run some function when someone click on the button which resides in the wxboxsizer that comes from xrc file.

  button = XRCCTRL(parent_window, "button_name")

and i've found out there is a problem with the way the xrc is arranged.
eg: wxframe (name: myframe) -> wxpanel(name:mypanel) -> ...
when i tried to loadpanel("mypanel")
wx runtime will gives out mypanel not found
if the root itself starts with wxpanel without the frame
eg: wxpanel(name:mypanel) -> ...
it runs just fine :slight_smile:
y is it this way? is there some kind of loadpanel("myframe.mypanel")?

I don't know, Vaclav?

------next-------<>
i've another issue, :stuck_out_tongue:
in wxwindows (cpp) version, casting a wxpanel to wxwindow or wxframe to wxwindow is an easy job: xyz = (wxWindow *)(abc)
but how do i cast it in python?

There's wxPyTypeCast that was created as a downcast hack to work around a problem. But why would you need to upcast? wxPanel and wxFrame inherit everything from wxWindow already...

···

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

Hi,

James Tan wrote:

when i tried to loadpanel("mypanel")
wx runtime will gives out mypanel not found

That's a feature -- only top-level resources can be loaded.

y is it this way? is there some kind of
loadpanel("myframe.mypanel")?

No, but you can use a trick and use <object_ref> instead of <object>
(it behaves like Unix symlinks):

<object class="wxFrame" name="myframe">
  ...
  <object class="wxPanel" name="mypanel">
      ...
  </object>
  ...
</object>
...
<object_ref name="myframe.mypanel" ref="mypanel"/>
    <!-- note that "myframe.mypanel" can be replaced with
         arbitrary string here -->

This will make the panel loadable as "myframe.mypanel".

HTH,
Vaclav

- --
PGP key ID: 0x465264C9 (get it from wwwkeys.pgp.net)