Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

[SOLVED] Possibility to listen to events within a plugin?

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: [SOLVED] Possibility to listen to events within a plugin

Post by Sem;colon »

Hi Pako,

I have never been to Dresden yet, but I heard from many people that it's a very nice old city, I hope you had a good time in Germany 8)

As for the EventListener; it works very similar to LogListener, but hands over the whole event object, not only a string.
You can use it like this:

Code: Select all

class LogWrapper:
        
    def AddEventListener(self):
        if self not in eg.log.eventListeners:
            eg.log.AddEventListener(self)

    def LogEvent(self, event):
        print event.suffix

    def StopEventListener(self):
        if self in eg.log.eventListeners:
            eg.log.RemoveEventListener(self)
            
eg.globals.LogWrapper=LogWrapper()
eg.globals.LogWrapper.AddEventListener()
If you like my work, Image me a drink :wink:
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: [SOLVED] Possibility to listen to events within a plugin

Post by Pako »

Sem;colon wrote:I heard from many people that it's a very nice old city ...
Yes, Dresden is a very nice city.
I've been there several times already.
Sem;colon wrote:You can use it like this:
Yes, of course you are right.
I forgot that you can redefine the method "LogEvent".

I think it is useful improvements. It is good that you made ÔÇïÔÇïa note about it in the appropriate topic.

Pako
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: [SOLVED] Possibility to listen to events within a plugin

Post by Sem;colon »

Bugfix on this Modification:

I noticed that it's only working if "only log assigned events" is unticked.

I attached a corrected version.
Attachments
Eventghost.zip
Fixed version
(5.42 KiB) Downloaded 160 times
If you like my work, Image me a drink :wink:
Post Reply