wxClientDC drawing to wxScrolledWindow (continued)

Ok, here's my barebones app example where I'm trying to use a wxClientDC
to draw to a wxScrolledWindow

I get no errors but don't get any drawing either

from wxPython.wx import *

class MyFrame(wxFrame):
    def __init__(self, parent, id, title,
        pos = wxPyDefaultPosition, size = wxPyDefaultSize,
        style = wxDEFAULT_FRAME_STYLE ):
        wxFrame.__init__(self, parent, id, title, pos, size, style)
        self.bg_bmp = wxBitmap('metal.png', wxBITMAP_TYPE_PNG)
        self.sw = wxScrolledWindow(self, -1)
        siz = wxBoxSizer(wxVERTICAL)
        self.sw.SetSizer(siz)
        dc = wxClientDC(self.sw)
        dc.SetPen(wxRED_PEN)
        self.sw.PrepareDC(dc)
        dc.DrawCircle(100, 100,100)
        dc.DrawBitmap(self.bg_bmp, 200, 200, False)
   
        EVT_CLOSE(self, self.OnCloseWindow)

    def OnCloseWindow(self, event):
        self.Destroy()

···

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

class MyApp(wxApp):
    
    def OnInit(self):
        wxInitAllImageHandlers()
        frame = MyFrame(None, -1, "test", wxPoint(20,20),
wxSize(500,340) )
        frame.Show(True)
        return True

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

app = MyApp(True)
app.MainLoop()

Rob A Brooks wrote:

Ok, here's my barebones app example where I'm trying to use a wxClientDC
to draw to a wxScrolledWindow

I get no errors but don't get any drawing either

I suspect that your problem is no OnPaint method. a wxClientDC will draw
to the window that exists when the code runs, but if the window gets
refreshed after that, you'll lose everything. YOu Always need a method
to draw the screen when a Paint event happens. You only want to use a
wxClientDC when you want to updatet he screen outside of a Paint event.

-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

Thx Chris, I think I see it now ...

···

-----Original Message-----
From: Chris Barker [mailto:Chris.Barker@noaa.gov]
Sent: Thursday, April 17, 2003 5:21 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] wxClientDC drawing to wxScrolledWindow
(continued)

Rob A Brooks wrote:

Ok, here's my barebones app example where I'm trying to use a

wxClientDC

to draw to a wxScrolledWindow

I get no errors but don't get any drawing either

I suspect that your problem is no OnPaint method. a wxClientDC will draw
to the window that exists when the code runs, but if the window gets
refreshed after that, you'll lose everything. YOu Always need a method
to draw the screen when a Paint event happens. You only want to use a
wxClientDC when you want to updatet he screen outside of a Paint event.

-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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org