[wxPython] GetLabel in WXP created buttons

How do I retrieve the label from a button created using the WXP elements
within a wxHTML window? I've tried using GetLabel(), but am not sure what
the attribute should attach to. Below are applicable HTML and code
snippets.

Eric Freese

<wxp class='wxButton' width='100%'>
  <param name='label' value='test'>
  <param name='id' value='200'>
</wxp>

    EVT_BUTTON(self, 200, self.OnOk)

    def OnOk(self, event):
        self.log.WriteText("Button Label: %s\n" % event.GetId())

How do I retrieve the label from a button created using the WXP elements
within a wxHTML window? I've tried using GetLabel(), but am not sure what
the attribute should attach to. Below are applicable HTML and code
snippets.

Eric Freese

<wxp class='wxButton' width='100%'>
  <param name='label' value='test'>
  <param name='id' value='200'>
</wxp>

    EVT_BUTTON(self, 200, self.OnOk)

    def OnOk(self, event):
        self.log.WriteText("Button Label: %s\n" % event.GetId())

Try making the first line of that HTML something like

<wxp module="mybutton" class='my_wxButton' width='100%'>

And do something in mybutton.py like

class my_wxButton(wxGenButton):
    def __init__(self,**kw):
        apply(wxGenButton.__init__,(self,),kw)
        self.label = kw['label']

    def Notify(self):
        self.log.WriteText("Button Label: %s\n" % self.label)
        # pot any extra label-dependent code that you wish here...
        pass
        wxGenButton.Notify(self) # to perform the usual processing...

That should work, I think. I've done quite a bit of code involving
the <WXP> tag recently, so I guess I've got no excuse if not...

Cheerio, Chris

Whoops, I'm sorry, I forgot that before that class definition you'll need to

from wxPython.wx import *
#from wxPython.html import *
from wxPython.lib.buttons import wxGenButton
#import wxPython.lib.wxpTag

The commented out lines are ones which I don't THINK will be necessary in
your case.

Cheerio, Chris

···

-----Original Message-----
From: wxpython-users-admin@wxwindows.org
[mailto:wxpython-users-admin@wxwindows.org]On Behalf Of Chris Fama
Sent: Saturday, 19 August 2000 10:15 PM
To: wxpython-users@wxwindows.org
Subject: RE: [wxPython] GetLabel in WXP created buttons

> How do I retrieve the label from a button created using the WXP elements
> within a wxHTML window? I've tried using GetLabel(), but am
not sure what
> the attribute should attach to. Below are applicable HTML and code
> snippets.
>
> Eric Freese
>
>
> <wxp class='wxButton' width='100%'>
> <param name='label' value='test'>
> <param name='id' value='200'>
> </wxp>
>
>
> EVT_BUTTON(self, 200, self.OnOk)
>
> def OnOk(self, event):
> self.log.WriteText("Button Label: %s\n" % event.GetId())

Try making the first line of that HTML something like

<wxp module="mybutton" class='my_wxButton' width='100%'>

And do something in mybutton.py like

class my_wxButton(wxGenButton):
    def __init__(self,**kw):
        apply(wxGenButton.__init__,(self,),kw)
        self.label = kw['label']

    def Notify(self):
        self.log.WriteText("Button Label: %s\n" % self.label)
        # pot any extra label-dependent code that you wish here...
        pass
        wxGenButton.Notify(self) # to perform the usual processing...

That should work, I think. I've done quite a bit of code involving
the <WXP> tag recently, so I guess I've got no excuse if not...

Cheerio, Chris

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users

Oh dear, I'm sorry, my mistake entirely--that __init__ should read:

    def __init__(self,parent,**kw): # note additional 'parent', also in the
following line
        apply(wxGenButton.__init__,(self,parent),kw)
        self.label = kw['label']

I DO apologise for your wasted time...

Perhaps it it now works you could be kind enough to forward a copy of this
message to the wxPython-users list?

Cheerio, Chris

···

-----Original Message-----
From: wxpython-users-admin@wxwindows.org
[mailto:wxpython-users-admin@wxwindows.org]On Behalf Of Chris Fama
Sent: Saturday, 19 August 2000 10:15 PM
To: wxpython-users@wxwindows.org
Subject: RE: [wxPython] GetLabel in WXP created buttons

> How do I retrieve the label from a button created using the WXP elements
> within a wxHTML window? I've tried using GetLabel(), but am
not sure what
> the attribute should attach to. Below are applicable HTML and code
> snippets.
>
> Eric Freese
>
>
> <wxp class='wxButton' width='100%'>
> <param name='label' value='test'>
> <param name='id' value='200'>
> </wxp>
>
>
> EVT_BUTTON(self, 200, self.OnOk)
>
> def OnOk(self, event):
> self.log.WriteText("Button Label: %s\n" % event.GetId())

Try making the first line of that HTML something like

<wxp module="mybutton" class='my_wxButton' width='100%'>

And do something in mybutton.py like

class my_wxButton(wxGenButton):
    def __init__(self,**kw):
        apply(wxGenButton.__init__,(self,),kw)
        self.label = kw['label']

    def Notify(self):
        self.log.WriteText("Button Label: %s\n" % self.label)
        # pot any extra label-dependent code that you wish here...
        pass
        wxGenButton.Notify(self) # to perform the usual processing...

That should work, I think. I've done quite a bit of code involving
the <WXP> tag recently, so I guess I've got no excuse if not...

Cheerio, Chris

_______________________________________________
wxPython-users mailing list wxPython-users@wxwindows.org
http://wxwindows.org/mailman/listinfo/wxpython-users