Creating a background image

Hi,

I'm trying to create a background image on a wxFrame
and not having much luck. Below I have some code wich
adds an image and then some controls. The Controls
show up and are accessable via keyboard, but not mouse
clicks.

Is there something I'm doing wrong? Is there a better
way?

Thanks,
Seth.

···

-------------------------------------------------

from wxPython.wx import *
import string

class MainWindow(wxFrame):
    wxInitAllImageHandlers()
    def __init__(self,parent,id,title):
        wxFrame.__init__(self,parent,-4, title, size =
( 400,400),
                                    
style=wxDEFAULT_FRAME_STYLE)
        
        bmp = wxBitmap('Winter.jpg',
wxBITMAP_TYPE_JPEG)
        staticBmpCtrl = wxStaticBitmap(self, -1, bmp,
(0, 0))
         
        button1 = wxButton(self, 10, "Hello",
wxPoint(20, 20))

        button2 = wxButton(self, 20, "goodby",
wxPoint(200, 200))

        self.SetAutoLayout(true)
        
        EVT_BUTTON(self, 10, self.OnClick1)
        EVT_BUTTON(self, 20, self.OnClick2)

        self.Show(true)
        self.Refresh()
        
    def OnClick1(self, event):
        print "OnClick1"
    
    def OnClick2(self, event):
        print "OnClick2"
        
app = wxPySimpleApp()
frame = MainWindow(None, -1, "background try")
app.MainLoop()

#----------------------------------------------------------------------

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Seth Shikora wrote:

I'm trying to create a background image on a wxFrame
and not having much luck. Below I have some code wich
adds an image and then some controls. The Controls
show up and are accessable via keyboard, but not mouse
clicks.

It works fine for me: wxGTK2.4.1.2, Python2.3, Redhat Linux7.2

What system/versions are you running?

Is there something I'm doing wrong? Is there a better
way?

There was a discussion about this a littel while ago on this list. Check
the archives. I suspect that you don't want to use wxStaticBitmap to
draw your image. What you are doing is putting controls on top of each
other, and is suspect that is your problem. I think a wxStaicBitmap is
not a "true" control on GTK, so it works for me, but may not on other
platforms.

By the way, you don't need:

wxInitAllImageHandlers()

wxPySimpleApp already does that.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (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

Seth Shikora wrote:

Hi,

I'm trying to create a background image on a wxFrame
and not having much luck. Below I have some code wich
adds an image and then some controls. The Controls
show up and are accessable via keyboard, but not mouse
clicks.

Is there something I'm doing wrong?

Yep. You're overlapping controls and not looking at the demo for better ideas. :wink:

Is there a better
way?

Draw the image in the EVT_ERASE_BACKGROUND event like in the ColourDB sample

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!