setting the background image of a panel managed by an aui manager (code attached)

Dear wxpython users,

I
have an application that contains an aui notebook. Each page of this notebook hosts a panel that should be managed by an aui manager.

When
I try to set a background image to this panel the image is not displayed and the event wx.EVT_ERASE_BACKGROUND is event not

fired. You will find attached a snippet that reproduces this (unwanted) behaviour.

Would you have any idea about what is wrong with my code and how I can solve this ?

thanks a lot

Eric

test.py (1.55 KB)

Greeting Eric,

I have attached an updated version of your code using some samples from various sources (including Mouse vs Python). If you are using wxPython 2.9.x it has been found that BG_STYLE_CUSTOM causes issues, so that is commented out. I’ve also did a little bit of tidying up on your original code. You may notice that AuiManager and AuiNotebook are being subclassed, in my opinion this will make it easier to “customize / tweak” later. I also set AuiManager to manage the notebook, this was not present in the original code. I may be wrong, but it appeared that you were setting up AuiManager, but not using it.

Hopefully someone with more wxPython knowledge can help explain anything I may have missed or didn’t explain correctly.

  • Mike S

test_updated.py (1.87 KB)

···

On Wednesday, April 23, 2014 6:07:41 AM UTC-4, Eric wrote:

Dear wxpython users,

I
have an application that contains an aui notebook. Each page of this notebook hosts a panel that should be managed by an aui manager.

When
I try to set a background image to this panel the image is not displayed and the event wx.EVT_ERASE_BACKGROUND is event not

fired. You will find attached a snippet that reproduces this (unwanted) behaviour.

Would you have any idea about what is wrong with my code and how I can solve this ?

thanks a lot

Eric

Hi Mike,

thanks a lot for your help.

Unfortunately, running your updated version of the snippet still did not showed any bitmap in the panel. In the meantime, I could find a way to make it out.
This was done by replacing:

self.Bind(wx.EVT_ERASE_
BACKGROUND, self.OnEraseBackground)

by:

self.Bind(wxaui.EVT_AUI_RENDER, self.OnEraseBackground)

You
will find this in the new version of the test enclosed. I relocated the
aui manager in its original place as, in the whole application, it is used to dock some pane inside a given page of the notebook.
The problem with this approach is that the event handler is called several times with very huge values of the dc.GetSize() and I do not understand why and what is exactly going on. Would you have any
idea about this ?

thanks

Eric

test_updated.py (1.9 KB)

···

On Wednesday, April 23, 2014 3:16:54 PM UTC+2, Mike Stover wrote:

Greeting Eric,

I have attached an updated version of your code using some samples from various sources (including Mouse vs Python). If you are using wxPython 2.9.x it has been found that BG_STYLE_CUSTOM causes issues, so that is commented out. I’ve also did a little bit of tidying up on your original code. You may notice that AuiManager and AuiNotebook are being subclassed, in my opinion this will make it easier to “customize / tweak” later. I also set AuiManager to manage the notebook, this was not present in the original code. I may be wrong, but it appeared that you were setting up AuiManager, but not using it.

Hopefully someone with more wxPython knowledge can help explain anything I may have missed or didn’t explain correctly.

  • Mike S

On Wednesday, April 23, 2014 6:07:41 AM UTC-4, Eric wrote:

Dear wxpython users,

I
have an application that contains an aui notebook. Each page of this notebook hosts a panel that should be managed by an aui manager.

When
I try to set a background image to this panel the image is not displayed and the event wx.EVT_ERASE_BACKGROUND is event not

fired. You will find attached a snippet that reproduces this (unwanted) behaviour.

Would you have any idea about what is wrong with my code and how I can solve this ?

thanks a lot

Eric

What versions of Python and wxPython are you using? The code worked for me with Python 2.7.5 and wxPython 2.9.5.0 on Win7 32bit as well as Python 2.7.5, wxPython 3.0.0.0 on Ubuntu 12.04. I was also using a random jpg image I found via Google as the original image I attempted to use was too large.

···

On Wednesday, April 23, 2014 10:22:36 AM UTC-4, Eric wrote:

Hi Mike,

thanks a lot for your help.

Unfortunately, running your updated version of the snippet still did not showed any bitmap in the panel. In the meantime, I could find a way to make it out.
This was done by replacing:

self.Bind(wx.EVT_ERASE_
BACKGROUND, self.OnEraseBackground)

by:

self.Bind(wxaui.EVT_AUI_RENDER, self.OnEraseBackground)

You
will find this in the new version of the test enclosed. I relocated the
aui manager in its original place as, in the whole application, it is used to dock some pane inside a given page of the notebook.
The problem with this approach is that the event handler is called several times with very huge values of the dc.GetSize() and I do not understand why and what is exactly going on. Would you have any
idea about this ?

thanks

Eric

On Wednesday, April 23, 2014 3:16:54 PM UTC+2, Mike Stover wrote:

Greeting Eric,

I have attached an updated version of your code using some samples from various sources (including Mouse vs Python). If you are using wxPython 2.9.x it has been found that BG_STYLE_CUSTOM causes issues, so that is commented out. I’ve also did a little bit of tidying up on your original code. You may notice that AuiManager and AuiNotebook are being subclassed, in my opinion this will make it easier to “customize / tweak” later. I also set AuiManager to manage the notebook, this was not present in the original code. I may be wrong, but it appeared that you were setting up AuiManager, but not using it.

Hopefully someone with more wxPython knowledge can help explain anything I may have missed or didn’t explain correctly.

  • Mike S

On Wednesday, April 23, 2014 6:07:41 AM UTC-4, Eric wrote:

Dear wxpython users,

I
have an application that contains an aui notebook. Each page of this notebook hosts a panel that should be managed by an aui manager.

When
I try to set a background image to this panel the image is not displayed and the event wx.EVT_ERASE_BACKGROUND is event not

fired. You will find attached a snippet that reproduces this (unwanted) behaviour.

Would you have any idea about what is wrong with my code and how I can solve this ?

thanks a lot

Eric

Hi Mike,

I work on python 2.7.3 with wx 2.8.12.1 on an Ubuntu 12.04 machine.

Eric

What versions of Python and wxPython are you using? The code worked for me with Python 2.7.5 and wxPython 2.9.5.0 on Win7 32bit as well as Python 2.7.5, wxPython
3.0.0.0 on Ubuntu 12.04. I was also using a random jpg image I found via Google as the original image I attempted to use was too large.

···

Le Mercredi 23 avril 2014 16h29, Mike Stover hakugin.gin@gmail.com a écrit :

On Wednesday, April 23, 2014 10:22:36 AM UTC-4, Eric wrote:

Hi Mike,

thanks a lot for your help.

Unfortunately, running your updated version of the snippet still did not showed any bitmap in the panel. In the meantime, I could find a way to make it out.
This was done by replacing:

self.Bind(wx.EVT_ERASE_
BACKGROUND, self.OnEraseBackground)

by:

self.Bind(wxaui.EVT_AUI_ RENDER, self.OnEraseBackground)

You
will find this in the new version of the test enclosed. I relocated the
aui manager in its original place as, in the whole application, it is used to dock some pane inside a given page of the notebook.
The problem with this approach is that the event handler is called several times with very huge values of the dc.GetSize() and I do not understand why and what is exactly going on. Would you have any
idea about this ?

thanks

Eric

On Wednesday, April 23, 2014 3:16:54 PM UTC+2, Mike Stover wrote:

Greeting Eric,

I have attached an updated version of your code using some samples from various sources (including Mouse vs Python ). If you are using wxPython 2.9.x it has been found that BG_STYLE_CUSTOM causes issues, so that is commented out. I’ve also did a little bit of tidying up on your original code. You may notice that AuiManager and AuiNotebook are being subclassed, in my opinion this will make it easier to
“customize / tweak” later. I also set AuiManager to manage the notebook, this was not present in the original code. I may be wrong, but it appeared that you were setting up AuiManager, but not using it.

Hopefully someone with more wxPython knowledge can help explain anything I may have missed or didn’t explain correctly.

  • Mike S

On Wednesday, April 23, 2014 6:07:41 AM UTC-4, Eric wrote:

Dear wxpython users,

I
have an application that contains an aui notebook. Each page of this notebook hosts a panel that should be managed by an aui manager.

When
I try to set a background image to this panel the image is not displayed and the event wx.EVT_ERASE_BACKGROUND is event not

fired. You will find attached a snippet that reproduces this (unwanted) behaviour.

Would you have any idea about what is wrong with my code and how I can solve this ?

thanks a lot

Eric

Ok, that may be why the code I supplied works on my systems but not yours, we’re using different versions of wxPython. At the moment I do not have a system with wx 2.8 installed, however I do not mind setting up a virtual machine when I get home if nobody else here is using the same version.

···

On Thursday, April 24, 2014 10:39:24 AM UTC-4, Eric wrote:

Hi Mike,

I work on python 2.7.3 with wx 2.8.12.1 on an Ubuntu 12.04 machine.

Eric

Le Mercredi 23 avril 2014 16h29, Mike Stover hakug...@gmail.com a écrit :

What versions of Python and wxPython are you using? The code worked for me with Python 2.7.5 and wxPython 2.9.5.0 on Win7 32bit as well as Python 2.7.5, wxPython
3.0.0.0 on Ubuntu 12.04. I was also using a random jpg image I found via Google as the original image I attempted to use was too large.

On Wednesday, April 23, 2014 10:22:36 AM UTC-4, Eric wrote:

Hi Mike,

thanks a lot for your help.

Unfortunately, running your updated version of the snippet still did not showed any bitmap in the panel. In the meantime, I could find a way to make it out.
This was done by replacing:

self.Bind(wx.EVT_ERASE_
BACKGROUND, self.OnEraseBackground)

by:

self.Bind(wxaui.EVT_AUI_ RENDER, self.OnEraseBackground)

You
will find this in the new version of the test enclosed. I relocated the
aui manager in its original place as, in the whole application, it is used to dock some pane inside a given page of the notebook.
The problem with this approach is that the event handler is called several times with very huge values of the dc.GetSize() and I do not understand why and what is exactly going on. Would you have any
idea about this ?

thanks

Eric

On Wednesday, April 23, 2014 3:16:54 PM UTC+2, Mike Stover wrote:

Greeting Eric,

I have attached an updated version of your code using some samples from various sources (including Mouse vs Python ). If you are using wxPython 2.9.x it has been found that BG_STYLE_CUSTOM causes issues, so that is commented out. I’ve also did a little bit of tidying up on your original code. You may notice that AuiManager and AuiNotebook are being subclassed, in my opinion this will make it easier to
“customize / tweak” later. I also set AuiManager to manage the notebook, this was not present in the original code. I may be wrong, but it appeared that you were setting up AuiManager, but not using it.

Hopefully someone with more wxPython knowledge can help explain anything I may have missed or didn’t explain correctly.

  • Mike S

On Wednesday, April 23, 2014 6:07:41 AM UTC-4, Eric wrote:

Dear wxpython users,

I
have an application that contains an aui notebook. Each page of this notebook hosts a panel that should be managed by an aui manager.

When
I try to set a background image to this panel the image is not displayed and the event wx.EVT_ERASE_BACKGROUND is event not

fired. You will find attached a snippet that reproduces this (unwanted) behaviour.

Would you have any idea about what is wrong with my code and how I can solve this ?

thanks a lot

Eric

Hi,

I use the same config in Ubuntu 14.04 64bits, the test sent by Mike dont work but the test sent by Eric is working with no problems, showing the tab with an image there.

Saludos / Best regards

Mario Lacunza
Email:: mlacunza@gmail.com
Personal Website:: http://www.lacunza.biz/
Hosting:: http://mlv-host.com/
Mascotas Perdidas:: http://mascotas-perdidas.com/
Google Talk / Y! messenger / Skype: mlacunzav

···

El 24/04/14 10:39, Mike Stover escribió:

Ok, that may be why the code I supplied works on my systems but not yours, we're using different versions of wxPython. At the moment I do not have a system with wx 2.8 installed, however I do not mind setting up a virtual machine when I get home if nobody else here is using the same version.

On Thursday, April 24, 2014 10:39:24 AM UTC-4, Eric wrote:

    Hi Mike,

    I work on python 2.7.3 with wx 2.8.12.1 on an Ubuntu 12.04 machine.

    Eric

    Le Mercredi 23 avril 2014 16h29, Mike Stover <hakug...@gmail.com > <javascript:>> a écrit :
    What versions of Python and wxPython are you using? The code
    worked for me with Python 2.7.5 and wxPython 2.9.5.0 on Win7 32bit
    as well as Python 2.7.5, wxPython 3.0.0.0 on Ubuntu 12.04. I was
    also using a random jpg image I found via Google as the original
    image I attempted to use was too large.

    On Wednesday, April 23, 2014 10:22:36 AM UTC-4, Eric wrote:

        Hi Mike,

        thanks a lot for your help.

        Unfortunately, running your updated version of the snippet
        still did not showed any bitmap in the panel. In the meantime,
        I could find a way to make it out. This was done by replacing:

        self.Bind(wx.EVT_ERASE_
        BACKGROUND, self.OnEraseBackground)

        by:

        self.Bind(wxaui.EVT_AUI_ RENDER, self.OnEraseBackground)

        You will find this in the new version of the test enclosed. I
        relocated the aui manager in its original place as, in the
        whole application, it is used to dock some pane inside a given
        page of the notebook.
        The problem with this approach is that the event handler is
        called several times with very huge values of the dc.GetSize()
        and I do not understand why and what is exactly going on.
        Would you have any
        idea about this ?

        thanks

        Eric

        On Wednesday, April 23, 2014 3:16:54 PM UTC+2, Mike Stover wrote:

            Greeting Eric,

            I have attached an updated version of your code using some
            samples from various sources (including Mouse vs Python
            <http://blog.pythonlibrary.org/&gt;\). If you are using
            wxPython 2.9.x it has been found that BG_STYLE_CUSTOM
            causes issues, so that is commented out. I've also did a
            little bit of tidying up on your original code. You may
            notice that AuiManager and AuiNotebook are being
            subclassed, in my opinion this will make it easier to
            "customize / tweak" later. I also set AuiManager to manage
            the notebook, this was not present in the original code. I
            may be wrong, but it appeared that you were setting up
            AuiManager, but not using it.

            Hopefully someone with more wxPython knowledge can help
            explain anything I may have missed or didn't explain
            correctly.

            - Mike S

            On Wednesday, April 23, 2014 6:07:41 AM UTC-4, Eric wrote:

                Dear wxpython users,

                I have an application that contains an aui notebook.
                Each page of this notebook hosts a panel that should
                be managed by an aui manager.
                When I try to set a background image to this panel the
                image is not displayed and the event
                wx.EVT_ERASE_BACKGROUND is event not
                fired. You will find attached a snippet that
                reproduces this (unwanted) behaviour.

                Would you have any idea about what is wrong with my
                code and how I can solve this ?

                thanks a lot

                Eric

--
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 wxpython-users+unsubscribe@googlegroups.com <mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

Just to be clear: the second example sent by Eric works fine.

Saludos / Best regards

Mario Lacunza
Email:: mlacunza@gmail.com
Personal Website:: http://www.lacunza.biz/
Hosting:: http://mlv-host.com/
Mascotas Perdidas:: http://mascotas-perdidas.com/
Google Talk / Y! messenger / Skype: mlacunzav

···

El 24/04/14 10:39, Mike Stover escribió:

Ok, that may be why the code I supplied works on my systems but not yours, we're using different versions of wxPython. At the moment I do not have a system with wx 2.8 installed, however I do not mind setting up a virtual machine when I get home if nobody else here is using the same version.

On Thursday, April 24, 2014 10:39:24 AM UTC-4, Eric wrote:

    Hi Mike,

    I work on python 2.7.3 with wx 2.8.12.1 on an Ubuntu 12.04 machine.

    Eric

    Le Mercredi 23 avril 2014 16h29, Mike Stover <hakug...@gmail.com > <javascript:>> a écrit :
    What versions of Python and wxPython are you using? The code
    worked for me with Python 2.7.5 and wxPython 2.9.5.0 on Win7 32bit
    as well as Python 2.7.5, wxPython 3.0.0.0 on Ubuntu 12.04. I was
    also using a random jpg image I found via Google as the original
    image I attempted to use was too large.

    On Wednesday, April 23, 2014 10:22:36 AM UTC-4, Eric wrote:

        Hi Mike,

        thanks a lot for your help.

        Unfortunately, running your updated version of the snippet
        still did not showed any bitmap in the panel. In the meantime,
        I could find a way to make it out. This was done by replacing:

        self.Bind(wx.EVT_ERASE_
        BACKGROUND, self.OnEraseBackground)

        by:

        self.Bind(wxaui.EVT_AUI_ RENDER, self.OnEraseBackground)

        You will find this in the new version of the test enclosed. I
        relocated the aui manager in its original place as, in the
        whole application, it is used to dock some pane inside a given
        page of the notebook.
        The problem with this approach is that the event handler is
        called several times with very huge values of the dc.GetSize()
        and I do not understand why and what is exactly going on.
        Would you have any
        idea about this ?

        thanks

        Eric

        On Wednesday, April 23, 2014 3:16:54 PM UTC+2, Mike Stover wrote:

            Greeting Eric,

            I have attached an updated version of your code using some
            samples from various sources (including Mouse vs Python
            <http://blog.pythonlibrary.org/&gt;\). If you are using
            wxPython 2.9.x it has been found that BG_STYLE_CUSTOM
            causes issues, so that is commented out. I've also did a
            little bit of tidying up on your original code. You may
            notice that AuiManager and AuiNotebook are being
            subclassed, in my opinion this will make it easier to
            "customize / tweak" later. I also set AuiManager to manage
            the notebook, this was not present in the original code. I
            may be wrong, but it appeared that you were setting up
            AuiManager, but not using it.

            Hopefully someone with more wxPython knowledge can help
            explain anything I may have missed or didn't explain
            correctly.

            - Mike S

            On Wednesday, April 23, 2014 6:07:41 AM UTC-4, Eric wrote:

                Dear wxpython users,

                I have an application that contains an aui notebook.
                Each page of this notebook hosts a panel that should
                be managed by an aui manager.
                When I try to set a background image to this panel the
                image is not displayed and the event
                wx.EVT_ERASE_BACKGROUND is event not
                fired. You will find attached a snippet that
                reproduces this (unwanted) behaviour.

                Would you have any idea about what is wrong with my
                code and how I can solve this ?

                thanks a lot

                Eric

--
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 wxpython-users+unsubscribe@googlegroups.com <mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

well, Mikes example worked, but Erics second didnt on MSWindows.

I think you might be going about this the wrong way. Not sure exactly what you are trying to accomplish,
but this is how I would handle the notebook panel drawing. If you really need to use ClientDC, then adjust code accordingly.

If you are trying to change the actual AUI background or the notebook background, then derive subcass the appropriate ArtProvider cass and set it.

Anyway, my example uses BufferedPaint, and should work on all platforms.
normally I would just call widget.Refresh() programmatically, when I want to redraw.

If the image is not showing, please state back the OS you are running.

image.png

test_mcow.py (1.72 KB)

At least I’m not going insane and my example did work for someone else. I also checked your example Metallicow and I have to say its looks much cleaner and no “artifacting” occurs on resize, thanks. The systems I tested it on are the same as before.

···

On Thursday, April 24, 2014 8:40:01 PM UTC-4, Metallicow wrote:

well, Mikes example worked, but Erics second didnt on MSWindows.

I think you might be going about this the wrong way. Not sure exactly what you are trying to accomplish,
but this is how I would handle the notebook panel drawing. If you really need to use ClientDC, then adjust code accordingly.

If you are trying to change the actual AUI background or the notebook background, then derive subcass the appropriate ArtProvider cass and set it.

Anyway, my example uses BufferedPaint, and should work on all platforms.
normally I would just call widget.Refresh() programmatically, when I want to redraw.

If the image is not showing, please state back the OS you are running.