Might be just me but.. Weird Themeing issue.

This is where you report any issues if you are running a beta version of EventGhost
Forum rules
To submit a possible bug report please follow this template

Version: 0.5 beta 2 (the version you are running)
Traceback: Traceback (most recent call last):
File "<SOME_EVENTGHOST_FILE.py>", line 10, in <module>
SOME_FUNCTION()
File "<SOME_EVENTGHOST_FILE.py>", line 4, in SOME_EVENTGHOST_MODULE
SOME_FUNCTION()

copy and past any traceback information from the log if there is no traceback put NONE

Event:
Main.test.0.1.2.3.4.5.6.7.8
1
2

in the Event field you will want to put the event that was triggered just prior to the traceback occurring, if there is personal data put PERSONAL DATA if there was no traceback or no event triggered right before the traceback put NO EVENT

Description: if you have the ability to replicate the issue then put in here a description of what you are doing to create the problem.

Screen Shots: screen shots of the error and any events/macros/acrions that were run before the issue or screen shots of the problem

Files: any files that may be used to isolate where the issue is. something like the log.txt file would go here

if you provide the above information before hand it will greatly speed up the diagnostic process. we will not have to ask for the bits and pieces. And also having a well formatted Bug Report filled out will get answered sooner then the ones that aren't
Post Reply
dan Edens
Experienced User
Posts: 91
Joined: Mon Sep 24, 2018 7:57 pm

Might be just me but.. Weird Themeing issue.

Post by dan Edens » Tue Nov 12, 2019 4:34 pm

So i run a heavily hacked up and custom version of EG.
Most of it is just replacing globalized features with things targeted to my specific machine, nothing i would share with anybody (get your copy here! :D https://github.com/DanEdens/EventGhost) but one of the things I'm really happy i changed is the color scheme.

I have thoughts of turning this into a plugin, but for now it's just hacked.
My EG looks like this.
2019-11-12 09_50_07-Task Manager.png
simple dark theme.

So whenever the window minimizes, it comes back up like this.
2019-11-12 09_51_04-Task Manager.png
It might be impossible to figure out without my theme changes, but if anyone knows why the colors it loads on boot, are not the same as the ones it loads on restore from minimize, I'd LOVE to fix this, have to restart all the time.

It is the same effect with "hide/show" from the tray menu, and "close/open" from the eg action

something to do with %AppData%\EventGhost\config.py?

Code: Select all

    class System:
            class Registry:
                lastKeySelected = 2147483649L
                lastSubkeySelected = u'Control Panel\\Colors'
                lastValueNameSelected = u'WindowFrame'

User avatar
kgschlosser
Site Admin
Posts: 5028
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Might be just me but.. Weird Themeing issue.

Post by kgschlosser » Fri Nov 15, 2019 9:28 am

OK when Eg was originally written was wayyy back in the hayday of Windows XP and most machines had 256MB of ram.. So ram consumption was a big thing. In order to decrease the memory use when you minimize EG if you notice the taskbar icon disappears. That is because the frame has been destroyed. It does not exist anymore. when you use the tray icon to show EG the whole GUI gets built again. So if you do not have your color changing bits in the proper place they are not going to get used each and every single time the frame gets built.

The best way to do this is to override eg.Classes.Document.Document.ShowFrame

Code: Select all


old_show_frame = eg.document.ShowFrame

def new_show_frame(*args, **kwargs):
    res = old_show_frame(*args, **kwargs)
    
    if eg.document.frame is not None:
        # place code here to to change the theme.
        pass
    return res
    
eg.document.ShowFrame = new_show_frame


This is going to ensure that your theme gets set in place each and every single time the frame gets created.
If you like the work I have been doing then feel free to Image

dan Edens
Experienced User
Posts: 91
Joined: Mon Sep 24, 2018 7:57 pm

Re: Might be just me but.. Weird Themeing issue.

Post by dan Edens » Sat Nov 16, 2019 11:14 pm

Thanks this answers alot of questions.
and raises more :D lol

First I need to figure out why we changed my showframe to look like this for something else.
altho i reversed it and nothing caught on fire so

Code: Select all

    def ShowFrame(self):
        if self.reentrantLock.acquire(False):
            import threading

            event = threading.Event()

            def do():
                if self.frame is None:
                    self.frame = eg.mainFrame = eg.MainFrame(self)
                    self.frame.Show()

                    def iter_child(parent):
                        try:
                            for child in parent.GetChildren():
                                child.SetBackgroundColour(
                                    wx.Colour(60, 60, 60)
                                )

                                child.SetForegroundColour(
                                    wx.Colour(195, 195, 195)
                                )
                                iter_child(child)

                        except:
                            pass

                    iter_child(eg.mainFrame)
                    from .MainFrame.LogCtrl import _create_colour_attributes

                    eg.mainFrame.logCtrl.logColours = _create_colour_attributes(
                        (195, 195, 195),
                        (60, 60, 60)
                    )

                    eg.mainFrame.logCtrl.Refresh()
                    eg.mainFrame.logCtrl.Update()

                else:
                    self.frame.Raise()
                event.set()
instead of

Code: Select all

@ -485,6 +485,33 @@ class Document(object):
                if self.frame is None:
                    self.frame = eg.mainFrame = eg.MainFrame(self)
                    self.frame.Show()

                else:
                    self.frame.Raise()
                event.set()
I'm running the above you posted as a script inside EG? That basically solves the whole themeing project for me If i can change what show frame does from inside. I'll get to revert my sloppy hacks that's exciting

Seems to work if I just have it print a log entry whenever it should do the recoloring after removing the changes i made above, which once i figure out where the coloring actually happens and not just where the variables are should work great.

The dig begins!




Also I noticed there's already sort of an override going on in the globalmonitor plugin.
It probably isn't related but I'm pasting it to keep it in my head. Your work in the globalmonitor plugin has been HUGE for examples i look at it often.

Code: Select all

    def ShowFrame(self):
        if eg.document.reentrantLock.acquire(False):
            if eg.document.frame is None:
                eg.document.frame = eg.MainFrame(eg.document)
                eg.document.frame.Show()
                self.UI = UI(self)
                eg.document.frame.menuBar.Insert(
                    3,
                    self.CreateMenu(),
                    Text.menuLbl
                )
                eg.document.frame.menuBar.Refresh()
            eg.document.frame.Raise()
            eg.document.reentrantLock.release()
            

User avatar
kgschlosser
Site Admin
Posts: 5028
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Might be just me but.. Weird Themeing issue.

Post by kgschlosser » Tue Nov 19, 2019 6:04 am

the global monitor having also overridden the ShowFrame is no biggie. the 2 will work together without a concern.

Now the ShowFrame that is in your first code block. That was the one I gave you a while back that simply iterates over all of the children of the eventghost application gui frame. it's a recursive iteration so it does the children of the children of the children.... etc... That is supposed to set the colors to whatever colors you want to use.

While that is not the perfect solution it does handle the majority. there are some special use cases that would need to be handled like HTML windows and such.
If you like the work I have been doing then feel free to Image

Post Reply