wxp tags, now to get a handle?

Jorgen Bodde wrote:

Hi All,

I am investigating a way to embed some controls in wxHtmlWindow. I
have experimented briefly with the 'wxp' tags to embed an object class
in HTML like;

    <tr>
        <td>&nbsp;</td>
        <td width="50%">
            The name of the author of the code
        </td>
        <td>
            <wxp module="wx" class="TextCtrl" width="200">
            </wxp>
        </td>
    </tr>

The question is how can I get to the dynamic ID or pointer to this
control? I know I can give it an ID by specifying an ID string, but
how is that translated or accessible?

Use theHtmlWindow.FindWindowById(theID)

···

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

Jorgen Bodde wrote:

Hi Johnatan,

This was ofcourse (with the ID_OK) just an example! :wink:

"""If the value of id can be converted to an integer, it will
    be. Otherwise it is assumed to be the name of an integer variable in
    the module.""" - from the API docs.

Hmmm ok that brings possibilities. So when I derive my control and
make it a module, I can set for example;

import SomeControl

SomeControl.ID_SOMETHING = wx.NewId()

And then;

<wxp module="wx" class="SomeControl" width="50%">
    <param name="label" value="It works!">
    <param name="id" value="ID_SOMETHING">
</wxp>

Is this going to work?

It should, although you probably need to change the module to your module's name (unless you are putting the SomeControl class into the wx module.) You can also use specific numbers if you don't want to deal with ID variables.

Finally you can also try setting the name parameter and using FindWindowByName to fetch it later.

  <param name="name" value="MyWidgetName">

So all I need to do for all ID's that I want to create, is make a
module property with that integer value. It has to be done dynamically
though, so do I need something like __setattr__ to set an attribute
dynamically in the module?

I don't understand what you mean. Do you need different IDs for the same widget at different times? Can't you precreate the IDs you'll need for the different instances of the widget? If there's too many then using the name would probably make more sense as then you can easily make it related to the context where it is used.

···

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

Hi Robin and Johnhattan,

Thank you for elaborating it. I think I found a way. I will reserve
new ID's by calling wx.NewID() for all my controls that I want to
create, and generate the HTML code and paste the control integer
inside the wxp syntax like

text1 = wx.NewId() # e.g. 11335

<wxp module="wx" class="TextCtrl" width="50%">
     <param name="label" value="It works!">
     <param name="id" value="11335">
</wxp>

That way I can find back my control after it is created I assume.

What I want to make is a kind of wizard form which is generated from
XML to HTML for configuration purposes. Using HTML is very flexible
and can look very nice.

Thanks for your support guys,
- Jorgen

···

On 10/30/07, Robin Dunn <robin@alldunn.com> wrote:

Jorgen Bodde wrote:
> Hi Johnatan,
>
> This was ofcourse (with the ID_OK) just an example! :wink:
>
>> """If the value of id can be converted to an integer, it will
>> be. Otherwise it is assumed to be the name of an integer variable in
>> the module.""" - from the API docs.
>
> Hmmm ok that brings possibilities. So when I derive my control and
> make it a module, I can set for example;
>
> import SomeControl
>
> SomeControl.ID_SOMETHING = wx.NewId()
>
> And then;
>
> <wxp module="wx" class="SomeControl" width="50%">
> <param name="label" value="It works!">
> <param name="id" value="ID_SOMETHING">
> </wxp>
>
> Is this going to work?

It should, although you probably need to change the module to your
module's name (unless you are putting the SomeControl class into the wx
module.) You can also use specific numbers if you don't want to deal
with ID variables.

Finally you can also try setting the name parameter and using
FindWindowByName to fetch it later.

        <param name="name" value="MyWidgetName">

>
> So all I need to do for all ID's that I want to create, is make a
> module property with that integer value. It has to be done dynamically
> though, so do I need something like __setattr__ to set an attribute
> dynamically in the module?

I don't understand what you mean. Do you need different IDs for the
same widget at different times? Can't you precreate the IDs you'll need
for the different instances of the widget? If there's too many then
using the name would probably make more sense as then you can easily
make it related to the context where it is used.

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

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