is it possible to use evt as a global variable?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

is it possible to use evt as a global variable?

sebastian lópez
Good morning

is it possible to make something like this?

from wx import evt

def funccallbac(param1):
   
if evt.GetKeyCode() == 13:
       
return do_something()
   
return



The objective is to be able to call a function but without the need of passing the event as a function argument.

Thanks to your comments and suggestions.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to use evt as a global variable?

sebastian lópez
where evt is an envent

El jueves, 5 de abril de 2018, 9:23:21 (UTC-5), sebastian lópez escribió:
Good morning

is it possible to make something like this?

from wx import evt

def funccallbac(param1):
   
if evt.GetKeyCode() == 13:
       
return do_something()
   
return



The objective is to be able to call a function but without the need of passing the event as a function argument.

Thanks to your comments and suggestions.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: is it possible to use evt as a global variable?

Chris Barker - NOAA Federal


On Thu, Apr 5, 2018 at 8:08 AM, sebastian lópez <[hidden email]> wrote:
where evt is an envent


El jueves, 5 de abril de 2018, 9:23:21 (UTC-5), sebastian lópez escribió:
Good morning

is it possible to make something like this?

from wx import evt

def funccallbac(param1):
   
if evt.GetKeyCode() == 13:
       
return do_something()
   
return



The objective is to be able to call a function but without the need of passing the event as a function argument.

well, no.

if you have an event like that, with a KeyCode, or whatever, that event get created by the system, and it somehow needs to get to your code.

That is all handles in wx by the mainloop. when you bind event to a handler, then the mailoop knows to call that handler when that event occurs, and passes the event to the handler can know the details of what occured to trigger that event.

You should probably tell us what you are trying to accomplish, because what you are asking for really doesn't make sense:

when would funccallbac()get called in your example? How would it know there was an event to work with? The answete is that in event driven programming, EVERYTHING happens as the result of an event. there is no other way to run code after the mainloop is started.

-CHB



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.