Project using GDI for mouse over events.

I've been playing with a few things since I spent a long time reading
about the graphic device interface the past few days and got an idea.

Trying to mix the old school "arcade graphics" feel to some of the GUI
elements for various events. The code is a bit clunky at the moment,
but it does work. I'll flesh it out more when I get a little more
into it.

Anyhow, would someone be willing to take a look, run the code, and
tell me what they think? The background image and two static bitmaps
can be anything. I made the static bitmaps custom looking close
window and minimize "buttons".

Anyhow, when you mouse over the static bitmaps a thread is started
that draws a bunch of lines for make concentric boxes and changes
color of the lines in a for loop.

The nifty thing is it should work with any size widget in any position
as long as the event object is capable of delivering a GetSize() and
GetPosition() the rest is calculated in the thread.

My question is: Is there a better way to do this?

Here is the code... I think it's a cool look tell me what you think.

##CODE
import wx
import time
import thread

class MouseOverThread:
    def __init__(self, EventObj):
        self.EventObj = EventObj

    def Start(self):
        self.Working = self.running = True
        thread.start_new_thread(self.Run, ())

    def Stop(self):
        self.Working = False

    def IsRunning(self):
        return self.running

    def Run(self):
        while self.Working:
            self.EventObjParent = self.EventObj.GetParent()
            self.ObjSize = self.EventObj.GetSize()
            self.ObjPos = self.EventObj.GetPosition()

            PenColor = ['#0055FF', '#0000FF', '#00D4FF', '#0000FF']
            for item in PenColor:
                self.EventObjParent.DC.SetPen(wx.Pen(item))

                LConstX = self.ObjPos[0] - 1
                LStartY = self.ObjPos[1]
                LEndY = self.ObjPos[1] + self.ObjSize[1]
                self.EventObjParent.DC.DrawLine(LConstX, LStartY,
LConstX, LEndY)

                RConstX = self.ObjPos[0] + self.ObjSize[0]
                RStartY = self.ObjPos[1]
                REndY = self.ObjPos[1] + self.ObjSize[1]
                self.EventObjParent.DC.DrawLine(RConstX, RStartY,
RConstX, REndY)

                TStartX = self.ObjPos[0] - 1
                TEndX = self.ObjPos[0] + self.ObjSize[0] + 1
                TConstY = self.ObjPos[1] - 1
                self.EventObjParent.DC.DrawLine(TStartX, TConstY,
TEndX, TConstY)

                BStartX = self.ObjPos[0] - 1
                BEndX = self.ObjPos[0] + self.ObjSize[0] + 1
                BConstY = self.ObjPos[1] + self.ObjSize[1]
                self.EventObjParent.DC.DrawLine(BStartX, BConstY,
BEndX, BConstY)
                time.sleep(0.05)

                LConstX = self.ObjPos[0] - 2
                LStartY = self.ObjPos[1] - 1
                LEndY = self.ObjPos[1] + self.ObjSize[1] + 1
                self.EventObjParent.DC.DrawLine(LConstX, LStartY,
LConstX, LEndY)

                RConstX = self.ObjPos[0] + self.ObjSize[0] + 1
                RStartY = self.ObjPos[1] - 1
                REndY = self.ObjPos[1] + self.ObjSize[1] + 1
                self.EventObjParent.DC.DrawLine(RConstX, RStartY,
RConstX, REndY)

                TStartX = self.ObjPos[0] - 2
                TEndX = self.ObjPos[0] + self.ObjSize[0] + 2
                TConstY = self.ObjPos[1] - 2
                self.EventObjParent.DC.DrawLine(TStartX, TConstY,
TEndX, TConstY)

                BStartX = self.ObjPos[0] - 2
                BEndX = self.ObjPos[0] + self.ObjSize[0] + 2
                BConstY = self.ObjPos[1] + self.ObjSize[1] + 1
                self.EventObjParent.DC.DrawLine(BStartX, BConstY,
BEndX, BConstY)
                time.sleep(0.05)

                LConstX = self.ObjPos[0] - 3
                LStartY = self.ObjPos[1] - 2
                LEndY = self.ObjPos[1] + self.ObjSize[1] + 2
                self.EventObjParent.DC.DrawLine(LConstX, LStartY,
LConstX, LEndY)

                RConstX = self.ObjPos[0] + self.ObjSize[0] + 2
                RStartY = self.ObjPos[1] - 2
                REndY = self.ObjPos[1] + self.ObjSize[1] + 2
                self.EventObjParent.DC.DrawLine(RConstX, RStartY,
RConstX, REndY)

                TStartX = self.ObjPos[0] - 3
                TEndX = self.ObjPos[0] + self.ObjSize[0] + 3
                TConstY = self.ObjPos[1] - 3
                self.EventObjParent.DC.DrawLine(TStartX, TConstY,
TEndX, TConstY)

                BStartX = self.ObjPos[0] - 3
                BEndX = self.ObjPos[0] + self.ObjSize[0] + 3
                BConstY = self.ObjPos[1] + self.ObjSize[1] + 2
                self.EventObjParent.DC.DrawLine(BStartX, BConstY,
BEndX, BConstY)
                time.sleep(0.05)

        self.running = False

class BasePanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        self.ScreenResolution = wx.GetDisplaySize()
        self.GP = self.GetParent()
        self.DC = wx.ClientDC(self)

        self.BGBitmap = wx.Bitmap('Graphic Resources\Panel
Background.png')

        CloseWindowResource = 'Graphic Resources\Close Window.png'
        self.CloseWindowBMP = wx.Bitmap(CloseWindowResource)
        self.CloseWindowSBMP = wx.StaticBitmap(self, -1,
self.CloseWindowBMP, (self.ScreenResolution[0] -50, 15))

        MinimizeWindowResource = 'Graphic Resources\Minimize
Window.png'
        self.MinimizeWindowBMP = wx.Bitmap(MinimizeWindowResource)
        self.MinimizeWindowSBMP = wx.StaticBitmap(self, -1,
self.MinimizeWindowBMP, (self.ScreenResolution[0] -100, 15))

        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.CloseWindowSBMP.Bind(wx.EVT_ENTER_WINDOW,
self.OnWindowEnter)
        self.CloseWindowSBMP.Bind(wx.EVT_LEAVE_WINDOW,
self.OnWindowLeave)
        self.CloseWindowSBMP.Bind(wx.EVT_LEFT_DOWN,
self.OnCloseWindowClick)
        self.MinimizeWindowSBMP.Bind(wx.EVT_ENTER_WINDOW,
self.OnWindowEnter)
        self.MinimizeWindowSBMP.Bind(wx.EVT_LEAVE_WINDOW,
self.OnWindowLeave)
        self.MinimizeWindowSBMP.Bind(wx.EVT_LEFT_DOWN,
self.OnMinimizeWindowClick)

    def OnEraseBackground(self, event):
        EraseDC = event.GetDC()

        if EraseDC is None:
            EraseDC = wx.ClientDC(self)

        MemoryDC = wx.MemoryDC()
        MemoryDC.SelectObject(self.BGBitmap)
        EraseDC.Blit(0,0, self.BGBitmap.GetWidth(),
self.BGBitmap.GetHeight(), MemoryDC, 0,0)
        MemoryDC.SelectObject(wx.NullBitmap)

    def OnGUIThreadStop(self):
        self.t.Stop()

        running = 1

        while running:
            running = 0

            running = running + self.t.IsRunning()

            time.sleep(0.05)

    def OnWindowEnter(self, event):
        self.EventObj = event.GetEventObject()
        self.t = MouseOverThread(self.EventObj)
        self.t.Start()

    def OnWindowLeave(self, event):
        self.OnGUIThreadStop()
        self.Refresh()

    def OnCloseWindowClick(self, event):
        self.OnGUIThreadStop()
        self.GP.Close()

    def OnMinimizeWindowClick(self, event):
        self.GP.Iconize(True)

class BaseFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Soma")
        self.BP = BasePanel(self)
        self. ShowFullScreen(True, style = wx.FULLSCREEN_ALL)

class SomaApp(wx.App):
    def OnInit(self):
        BF = BaseFrame()
        BF.Show(True)
        return True

App = SomaApp(False)
App.MainLoop()

Hi,

I've been playing with a few things since I spent a long time reading
about the graphic device interface the past few days and got an idea.

Trying to mix the old school "arcade graphics" feel to some of the GUI
elements for various events. The code is a bit clunky at the moment,
but it does work. I'll flesh it out more when I get a little more
into it.

Anyhow, would someone be willing to take a look, run the code, and
tell me what they think? The background image and two static bitmaps
can be anything. I made the static bitmaps custom looking close
window and minimize "buttons".

Anyhow, when you mouse over the static bitmaps a thread is started
that draws a bunch of lines for make concentric boxes and changes
color of the lines in a for loop.

The nifty thing is it should work with any size widget in any position
as long as the event object is capable of delivering a GetSize() and
GetPosition() the rest is calculated in the thread.

My question is: Is there a better way to do this?

Yes :slight_smile: . First thing first, unfortunately you can not do any
wx-related stuff (like drawing) in separate threads. All the
operations need to be performed in the main thread, as wxWidgets (and
wxPython) are not thread-safe in that sense. It may appear to work now
(or to work for some time) on your Windows box, but it will definitely
break on a long run (and it will not be cross-platform). You can of
course start and run as many threads as you want to do calculations,
but the UI stuff needs to be done by the main thread. There are many
examples on this, the wxPython demo itself has 2 thread-based samples.

Secondly, once you have moved all your drawing stuff in the main
thread, I would say that your for loop over the pen colors can be
greatly simplified by reducing code duplication. You are basically
writing over and over again pretty much the same instructions for the
dc.DrawLine() stuff. If you store your X, Y offset in a list (or
whatever) that for loop could be reduced to just 2 or 3 lines of code.

Thirdly, I would recommend you take a glance at the wxPython style guide here:

http://wiki.wxpython.org/wxPython%20Style%20Guide

In addition, the tradition in the wx world is to use camel case
variableNames or pep_8_variable_names, as using the style
VariableNames as you are doing may conflict with some wxPython
properties for a widget (like obj.EventObject, for example).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

···

On 11 March 2012 23:01, Steve Freedenburg wrote:

I appreciate the input! I know I’ve got a long way to go.

You should have seen me 3 years ago :stuck_out_tongue: My coding has gotten better for sure. But I’m aware there are things I need to improve.

I’m at a loss on how to do what I want to do with GUI manipulation and not lock up the UI. I looked at the bubbles.py and it was inspiring,

and confusing…

I’ll take a look at the style guide, always trying to do things better. Thanks again!

···

On Sunday, March 11, 2012 6:01:45 PM UTC-4, Steve Freedenburg wrote:

I’ve been playing with a few things since I spent a long time reading

about the graphic device interface the past few days and got an idea.

Trying to mix the old school “arcade graphics” feel to some of the GUI

elements for various events. The code is a bit clunky at the moment,

but it does work. I’ll flesh it out more when I get a little more

into it.

Anyhow, would someone be willing to take a look, run the code, and

tell me what they think? The background image and two static bitmaps

can be anything. I made the static bitmaps custom looking close

window and minimize “buttons”.

Anyhow, when you mouse over the static bitmaps a thread is started

that draws a bunch of lines for make concentric boxes and changes

color of the lines in a for loop.

The nifty thing is it should work with any size widget in any position

as long as the event object is capable of delivering a GetSize() and

GetPosition() the rest is calculated in the thread.

My question is: Is there a better way to do this?

Here is the code… I think it’s a cool look tell me what you think.

##CODE

import wx

import time

import thread

class MouseOverThread:

def __init__(self, EventObj):

    self.EventObj = EventObj



def Start(self):

    self.Working = self.running = True

    thread.start_new_thread(self.Run, ())



def Stop(self):

    self.Working = False



def IsRunning(self):

    return self.running



def Run(self):

    while self.Working:

        self.EventObjParent = self.EventObj.GetParent()

        self.ObjSize = self.EventObj.GetSize()

        self.ObjPos = self.EventObj.GetPosition()



        PenColor = ['#0055FF', '#0000FF', '#00D4FF', '#0000FF']

        for item in PenColor:

            self.EventObjParent.DC.SetPen(wx.Pen(item))



            LConstX = self.ObjPos[0] - 1

            LStartY = self.ObjPos[1]

            LEndY = self.ObjPos[1] + self.ObjSize[1]

            self.EventObjParent.DC.DrawLine(LConstX, LStartY,

LConstX, LEndY)

            RConstX = self.ObjPos[0] + self.ObjSize[0]

            RStartY = self.ObjPos[1]

            REndY = self.ObjPos[1] + self.ObjSize[1]

            self.EventObjParent.DC.DrawLine(RConstX, RStartY,

RConstX, REndY)

            TStartX = self.ObjPos[0] - 1

            TEndX = self.ObjPos[0] + self.ObjSize[0] + 1

            TConstY = self.ObjPos[1] - 1

            self.EventObjParent.DC.DrawLine(TStartX, TConstY,

TEndX, TConstY)

            BStartX = self.ObjPos[0] - 1

            BEndX = self.ObjPos[0] + self.ObjSize[0] + 1

            BConstY = self.ObjPos[1] + self.ObjSize[1]

            self.EventObjParent.DC.DrawLine(BStartX, BConstY,

BEndX, BConstY)

            time.sleep(0.05)



            LConstX = self.ObjPos[0] - 2

            LStartY = self.ObjPos[1] - 1

            LEndY = self.ObjPos[1] + self.ObjSize[1] + 1

            self.EventObjParent.DC.DrawLine(LConstX, LStartY,

LConstX, LEndY)

            RConstX = self.ObjPos[0] + self.ObjSize[0] + 1

            RStartY = self.ObjPos[1] - 1

            REndY = self.ObjPos[1] + self.ObjSize[1] + 1

            self.EventObjParent.DC.DrawLine(RConstX, RStartY,

RConstX, REndY)

            TStartX = self.ObjPos[0] - 2

            TEndX = self.ObjPos[0] + self.ObjSize[0] + 2

            TConstY = self.ObjPos[1] - 2

            self.EventObjParent.DC.DrawLine(TStartX, TConstY,

TEndX, TConstY)

            BStartX = self.ObjPos[0] - 2

            BEndX = self.ObjPos[0] + self.ObjSize[0] + 2

            BConstY = self.ObjPos[1] + self.ObjSize[1] + 1

            self.EventObjParent.DC.DrawLine(BStartX, BConstY,

BEndX, BConstY)

            time.sleep(0.05)



            LConstX = self.ObjPos[0] - 3

            LStartY = self.ObjPos[1] - 2

            LEndY = self.ObjPos[1] + self.ObjSize[1] + 2

            self.EventObjParent.DC.DrawLine(LConstX, LStartY,

LConstX, LEndY)

            RConstX = self.ObjPos[0] + self.ObjSize[0] + 2

            RStartY = self.ObjPos[1] - 2

            REndY = self.ObjPos[1] + self.ObjSize[1] + 2

            self.EventObjParent.DC.DrawLine(RConstX, RStartY,

RConstX, REndY)

            TStartX = self.ObjPos[0] - 3

            TEndX = self.ObjPos[0] + self.ObjSize[0] + 3

            TConstY = self.ObjPos[1] - 3

            self.EventObjParent.DC.DrawLine(TStartX, TConstY,

TEndX, TConstY)

            BStartX = self.ObjPos[0] - 3

            BEndX = self.ObjPos[0] + self.ObjSize[0] + 3

            BConstY = self.ObjPos[1] + self.ObjSize[1] + 2

            self.EventObjParent.DC.DrawLine(BStartX, BConstY,

BEndX, BConstY)

            time.sleep(0.05)







    self.running = False

class BasePanel(wx.Panel):

def __init__(self, parent):

    wx.Panel.__init__(self, parent, -1)



    self.ScreenResolution = wx.GetDisplaySize()

    self.GP = self.GetParent()

    self.DC = wx.ClientDC(self)



    self.BGBitmap = wx.Bitmap('Graphic Resources\Panel

Background.png’)

    CloseWindowResource = 'Graphic Resources\Close Window.png'

    self.CloseWindowBMP = wx.Bitmap(CloseWindowResource)

    self.CloseWindowSBMP = wx.StaticBitmap(self, -1,

self.CloseWindowBMP, (self.ScreenResolution[0] -50, 15))

    MinimizeWindowResource = 'Graphic Resources\Minimize

Window.png’

    self.MinimizeWindowBMP = wx.Bitmap(MinimizeWindowResource)

    self.MinimizeWindowSBMP = wx.StaticBitmap(self, -1,

self.MinimizeWindowBMP, (self.ScreenResolution[0] -100, 15))

    self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)

    self.CloseWindowSBMP.Bind(wx.EVT_ENTER_WINDOW,

self.OnWindowEnter)

    self.CloseWindowSBMP.Bind(wx.EVT_LEAVE_WINDOW,

self.OnWindowLeave)

    self.CloseWindowSBMP.Bind(wx.EVT_LEFT_DOWN,

self.OnCloseWindowClick)

    self.MinimizeWindowSBMP.Bind(wx.EVT_ENTER_WINDOW,

self.OnWindowEnter)

    self.MinimizeWindowSBMP.Bind(wx.EVT_LEAVE_WINDOW,

self.OnWindowLeave)

    self.MinimizeWindowSBMP.Bind(wx.EVT_LEFT_DOWN,

self.OnMinimizeWindowClick)

def OnEraseBackground(self, event):

    EraseDC = event.GetDC()



    if EraseDC is None:

        EraseDC = wx.ClientDC(self)



    MemoryDC = wx.MemoryDC()

    MemoryDC.SelectObject(self.BGBitmap)

    EraseDC.Blit(0,0, self.BGBitmap.GetWidth(),

self.BGBitmap.GetHeight(), MemoryDC, 0,0)

    MemoryDC.SelectObject(wx.NullBitmap)



def OnGUIThreadStop(self):

    self.t.Stop()



    running = 1



    while running:

        running = 0



        running = running + self.t.IsRunning()



        time.sleep(0.05)



def OnWindowEnter(self, event):

    self.EventObj = event.GetEventObject()

    self.t = MouseOverThread(self.EventObj)

    self.t.Start()



def OnWindowLeave(self, event):

    self.OnGUIThreadStop()

    self.Refresh()



def OnCloseWindowClick(self, event):

    self.OnGUIThreadStop()

    self.GP.Close()



def OnMinimizeWindowClick(self, event):

    self.GP.Iconize(True)

class BaseFrame(wx.Frame):

def __init__(self):

    wx.Frame.__init__(self, None, -1, "Soma")

    self.BP = BasePanel(self)

    self. ShowFullScreen(True, style = wx.FULLSCREEN_ALL)

class SomaApp(wx.App):

def OnInit(self):

    BF = BaseFrame()

    BF.Show(True)

    return True

App = SomaApp(False)

App.MainLoop()

On Sunday, March 11, 2012 6:01:45 PM UTC-4, Steve Freedenburg wrote:

I’ve been playing with a few things since I spent a long time reading

about the graphic device interface the past few days and got an idea.

Trying to mix the old school “arcade graphics” feel to some of the GUI

elements for various events. The code is a bit clunky at the moment,

but it does work. I’ll flesh it out more when I get a little more

into it.

Anyhow, would someone be willing to take a look, run the code, and

tell me what they think? The background image and two static bitmaps

can be anything. I made the static bitmaps custom looking close

window and minimize “buttons”.

Anyhow, when you mouse over the static bitmaps a thread is started

that draws a bunch of lines for make concentric boxes and changes

color of the lines in a for loop.

The nifty thing is it should work with any size widget in any position

as long as the event object is capable of delivering a GetSize() and

GetPosition() the rest is calculated in the thread.

My question is: Is there a better way to do this?

Here is the code… I think it’s a cool look tell me what you think.

##CODE

import wx

import time

import thread

class MouseOverThread:

def __init__(self, EventObj):

    self.EventObj = EventObj



def Start(self):

    self.Working = self.running = True

    thread.start_new_thread(self.Run, ())



def Stop(self):

    self.Working = False



def IsRunning(self):

    return self.running



def Run(self):

    while self.Working:

        self.EventObjParent = self.EventObj.GetParent()

        self.ObjSize = self.EventObj.GetSize()

        self.ObjPos = self.EventObj.GetPosition()



        PenColor = ['#0055FF', '#0000FF', '#00D4FF', '#0000FF']

        for item in PenColor:

            self.EventObjParent.DC.SetPen(wx.Pen(item))



            LConstX = self.ObjPos[0] - 1

            LStartY = self.ObjPos[1]

            LEndY = self.ObjPos[1] + self.ObjSize[1]

            self.EventObjParent.DC.DrawLine(LConstX, LStartY,

LConstX, LEndY)

            RConstX = self.ObjPos[0] + self.ObjSize[0]

            RStartY = self.ObjPos[1]

            REndY = self.ObjPos[1] + self.ObjSize[1]

            self.EventObjParent.DC.DrawLine(RConstX, RStartY,

RConstX, REndY)

            TStartX = self.ObjPos[0] - 1

            TEndX = self.ObjPos[0] + self.ObjSize[0] + 1

            TConstY = self.ObjPos[1] - 1

            self.EventObjParent.DC.DrawLine(TStartX, TConstY,

TEndX, TConstY)

            BStartX = self.ObjPos[0] - 1

            BEndX = self.ObjPos[0] + self.ObjSize[0] + 1

            BConstY = self.ObjPos[1] + self.ObjSize[1]

            self.EventObjParent.DC.DrawLine(BStartX, BConstY,

BEndX, BConstY)

            time.sleep(0.05)



            LConstX = self.ObjPos[0] - 2

            LStartY = self.ObjPos[1] - 1

            LEndY = self.ObjPos[1] + self.ObjSize[1] + 1

            self.EventObjParent.DC.DrawLine(LConstX, LStartY,

LConstX, LEndY)

            RConstX = self.ObjPos[0] + self.ObjSize[0] + 1

            RStartY = self.ObjPos[1] - 1

            REndY = self.ObjPos[1] + self.ObjSize[1] + 1

            self.EventObjParent.DC.DrawLine(RConstX, RStartY,

RConstX, REndY)

            TStartX = self.ObjPos[0] - 2

            TEndX = self.ObjPos[0] + self.ObjSize[0] + 2

            TConstY = self.ObjPos[1] - 2

            self.EventObjParent.DC.DrawLine(TStartX, TConstY,

TEndX, TConstY)

            BStartX = self.ObjPos[0] - 2

            BEndX = self.ObjPos[0] + self.ObjSize[0] + 2

            BConstY = self.ObjPos[1] + self.ObjSize[1] + 1

            self.EventObjParent.DC.DrawLine(BStartX, BConstY,

BEndX, BConstY)

            time.sleep(0.05)



            LConstX = self.ObjPos[0] - 3

            LStartY = self.ObjPos[1] - 2

            LEndY = self.ObjPos[1] + self.ObjSize[1] + 2

            self.EventObjParent.DC.DrawLine(LConstX, LStartY,

LConstX, LEndY)

            RConstX = self.ObjPos[0] + self.ObjSize[0] + 2

            RStartY = self.ObjPos[1] - 2

            REndY = self.ObjPos[1] + self.ObjSize[1] + 2

            self.EventObjParent.DC.DrawLine(RConstX, RStartY,

RConstX, REndY)

            TStartX = self.ObjPos[0] - 3

            TEndX = self.ObjPos[0] + self.ObjSize[0] + 3

            TConstY = self.ObjPos[1] - 3

            self.EventObjParent.DC.DrawLine(TStartX, TConstY,

TEndX, TConstY)

            BStartX = self.ObjPos[0] - 3

            BEndX = self.ObjPos[0] + self.ObjSize[0] + 3

            BConstY = self.ObjPos[1] + self.ObjSize[1] + 2

            self.EventObjParent.DC.DrawLine(BStartX, BConstY,

BEndX, BConstY)

            time.sleep(0.05)







    self.running = False

class BasePanel(wx.Panel):

def __init__(self, parent):

    wx.Panel.__init__(self, parent, -1)



    self.ScreenResolution = wx.GetDisplaySize()

    self.GP = self.GetParent()

    self.DC = wx.ClientDC(self)



    self.BGBitmap = wx.Bitmap('Graphic Resources\Panel

Background.png’)

    CloseWindowResource = 'Graphic Resources\Close Window.png'

    self.CloseWindowBMP = wx.Bitmap(CloseWindowResource)

    self.CloseWindowSBMP = wx.StaticBitmap(self, -1,

self.CloseWindowBMP, (self.ScreenResolution[0] -50, 15))

    MinimizeWindowResource = 'Graphic Resources\Minimize

Window.png’

    self.MinimizeWindowBMP = wx.Bitmap(MinimizeWindowResource)

    self.MinimizeWindowSBMP = wx.StaticBitmap(self, -1,

self.MinimizeWindowBMP, (self.ScreenResolution[0] -100, 15))

    self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)

    self.CloseWindowSBMP.Bind(wx.EVT_ENTER_WINDOW,

self.OnWindowEnter)

    self.CloseWindowSBMP.Bind(wx.EVT_LEAVE_WINDOW,

self.OnWindowLeave)

    self.CloseWindowSBMP.Bind(wx.EVT_LEFT_DOWN,

self.OnCloseWindowClick)

    self.MinimizeWindowSBMP.Bind(wx.EVT_ENTER_WINDOW,

self.OnWindowEnter)

    self.MinimizeWindowSBMP.Bind(wx.EVT_LEAVE_WINDOW,

self.OnWindowLeave)

    self.MinimizeWindowSBMP.Bind(wx.EVT_LEFT_DOWN,

self.OnMinimizeWindowClick)

def OnEraseBackground(self, event):

    EraseDC = event.GetDC()



    if EraseDC is None:

        EraseDC = wx.ClientDC(self)



    MemoryDC = wx.MemoryDC()

    MemoryDC.SelectObject(self.BGBitmap)

    EraseDC.Blit(0,0, self.BGBitmap.GetWidth(),

self.BGBitmap.GetHeight(), MemoryDC, 0,0)

    MemoryDC.SelectObject(wx.NullBitmap)



def OnGUIThreadStop(self):

    self.t.Stop()



    running = 1



    while running:

        running = 0



        running = running + self.t.IsRunning()



        time.sleep(0.05)



def OnWindowEnter(self, event):

    self.EventObj = event.GetEventObject()

    self.t = MouseOverThread(self.EventObj)

    self.t.Start()



def OnWindowLeave(self, event):

    self.OnGUIThreadStop()

    self.Refresh()



def OnCloseWindowClick(self, event):

    self.OnGUIThreadStop()

    self.GP.Close()



def OnMinimizeWindowClick(self, event):

    self.GP.Iconize(True)

class BaseFrame(wx.Frame):

def __init__(self):

    wx.Frame.__init__(self, None, -1, "Soma")

    self.BP = BasePanel(self)

    self. ShowFullScreen(True, style = wx.FULLSCREEN_ALL)

class SomaApp(wx.App):

def OnInit(self):

    BF = BaseFrame()

    BF.Show(True)

    return True

App = SomaApp(False)

App.MainLoop()

take a look at wx.Timer , wx.CallAfter, and wx.CallLater. If each
individual action doesn't take long, one of those should work fine --
they are essentially ways to easily put stuff on the event stack.

···

On Mon, Mar 12, 2012 at 5:26 PM, Steve Freedenburg <stevefreedenburg@gmail.com> wrote:

I'm at a loss on how to do what I want to do with GUI manipulation and not
lock up the UI.

--

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

Chris.Barker@noaa.gov