event passing

I have been using the wxPython demo code as a reference for writing my own application. I have added a taskbaricon in my application using the tbicon in the demo code as the reference. When I close my application using my exit menu, it is only the frame that closes while the application and the taskbaricon still runs. I added a tbicon.Destroy at the exit menu’s handler and it works fine. Upon examining the wxPython demo code’s exit menu’s handler, I found this function definition:

def OnFileExit(self, *event):
self.Close()

and this works; it closes the app as well as the tbicon. I just want to ask what is the difference between passing event and *event, and when do I use one against the other?

I have been using the wxPython demo code as a reference for writing my own
application. I have added a taskbaricon in my application using the tbicon
in the demo code as the reference. When I close my application using my exit
menu, it is only the frame that closes while the application and the
taskbaricon still runs. I added a tbicon.Destroy at the exit menu's handler
and it works fine. Upon examining the wxPython demo code's exit menu's
handler, I found this function definition:

def OnFileExit(self, *event):
        self.Close()

and this works; it closes the app as well as the tbicon. I just want to ask
what is the difference between passing event and *event, and when do I use
one against the other?

In Python, seeing a function definition of the form...

    def foo(arg1, *args):
        print args

...means that args will take the value of a tuple of however many extra
arguments were passed. For example...

    >>> foo(1, 2, 3)
    (2, 3)
    >>>

Similarly, if you have a bunch of arguments you want to pass, but you
have them in the form of a list or tuple, you can pass them all using a
similar syntax...

    >>> foo(*(1,2,3))
    (2, 3)
    >>>

However, your function definition does not need to have a *varargs
parameter to support the receiving of list/tuple arguments...

    >>> def goo(arg1, arg2):
    ... print arg1, arg2
    ...
    >>> goo(*[1,2])
    1 2
    >>>

This is all covered in the Python tutorial available on python.org .

To answer the specific question you had, you would use OnFileExit(*event)
if event was a list or tuple, but OnFileExit(event) if it was just an
event. Then again, it doesn't matter, as it seems as though the
definition doesn't use the event argument at all, so you could get away
with not passing anything.

- Josiah

···

"Allan Noriel Estrella" <allan.noriel.estrella@gmail.com> wrote:

Can anybody tell me “how to send
event to sizer”

Suppose i want to send wxEVT_SIZE to wxsizer.

thanks

`amit

*********************** Aricent-Unclassified ***********************`

"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly
prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus."

I'll take a shot, though the last time I answered you I was wrong.

As far as I know, you can't send events to sizers. Only classes deriving from EvtHandler can accept events, and sizers aren't.

Why would you want to sent a size event to a sizer? Maybe what you're looking for is a call to the sizer's Layout function?

···

Amit15.Kumar@aricent.com wrote:

Can anybody tell me "how to send event to sizer"

Suppose i want to send wxEVT_SIZE to wxsizer.

thanks
amit

*********************** Aricent-Unclassified ***********************

"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly
prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus."

Thanks Eli

calling Layout() is working :slight_smile:

Eli Golovinsky gooli@tuzig.com

Sent by: news news@sea.gmane.org
02/09/2007 04:48 PM

Please respond to

wxPython-users@lists.wxwidgets.org

To

wxpython-users@lists.wxwidgets.org
cc

Subject

[wxPython-users] Re:
Send event to Sizer

`I’ll take a shot, though the last time I answered
you I was wrong.

As far as I know, you can’t send events to sizers. Only classes deriving

from EvtHandler can accept events, and sizers aren’t.

Why would you want to sent a size event to a sizer? Maybe what you’re

looking for is a call to the sizer’s Layout function?

Can anybody tell me “how to send event to sizer”

Suppose i want to send wxEVT_SIZE to wxsizer.

thanks

amit

*********************** Aricent-Unclassified ***********************

"DISCLAIMER: This message is proprietary to Aricent and is intended
solely for the use of

the individual to whom it is addressed. It may contain privileged
or confidential information and should not be

circulated or used for any purpose other than for what it is intended.
If you have received this message in error,

please notify the originator immediately. If you are not the intended
recipient, you are notified that you are strictly

prohibited from using, copying, altering, or disclosing the contents
of this message. Aricent accepts no responsibility for

loss or damage arising from the use of the information transmitted
by this email including damage from virus."

···

Amit15.Kumar@aricent.com wrote:


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

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

`

*********************** Aricent-Unclassified ***********************

"DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly
prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus."