I am having problems with dc.Clear() and wondered if I am going mad.
I am developing in Linux (rd7.2) and Windows Me
wxPython Version 2.2.5
I have read the documentation and it clearly states:
···
-------
wxDC.Clear()
void Clear()
Clears the device context using the current background brush
-------
Now ether I'm doing something wrong or there are two lies in the
statement.
Lie number one: "current background brush"
On Linux, dc.Clear() clears the dc but uses the white brush _not_ the
current background brush.
----
class MyCanvas(wxScrolledWindow):
def __init__(self, parent, id=-1, size=wxDefaultSize):
wxScrolledWindow.__init__(self, parent, id, wxDefaultPosition,
size, wxSUNKEN_BORDER)
self.SetBackgroundColour(wxNamedColor("Gray"))
----
<snip>
----
def OnLeftButtonEvent(self, event):
if event.Dragging():
dc = wxClientDC(self)
self.PrepareDC(dc)
dc.SetClippingRegion(self.clipping_x1,self.clipping_y1,self.clipping_width,self.clipping_height)
dc.Clear()
dc.BeginDrawing()
self.DrawObjects(dc)
dc.EndDrawing()
dc.DestroyClippingRegion()
----
(btw: The gray background does work before the dc.Clear())
Lie number two: "Clears the device context"
On Windows, dc.Clear() doesn't do anything.
So, Am I mad?
Please Help
-Andy
First, you need to select a brush into the dc. the SetBackround sets the
background color for text. dc.SelectObject(wxBrush("Grey")) or something
similar. Without this, it uses a default brush which may be different under
both systems.
···
----- Original Message -----
From: "Andy Dawkins" <andyd@nipltd.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Monday, June 04, 2001 9:38 AM
Subject: [wxPython] dc.Clear probs, am i mad?
I am having problems with dc.Clear() and wondered if I am going mad.
I am developing in Linux (rd7.2) and Windows Me
wxPython Version 2.2.5
I have read the documentation and it clearly states:
-------
wxDC.Clear()
void Clear()
Clears the device context using the current background brush
-------
Now ether I'm doing something wrong or there are two lies in the
statement.
Lie number one: "current background brush"
On Linux, dc.Clear() clears the dc but uses the white brush _not_ the
current background brush.
----
class MyCanvas(wxScrolledWindow):
def __init__(self, parent, id=-1, size=wxDefaultSize):
wxScrolledWindow.__init__(self, parent, id, wxDefaultPosition,
size, wxSUNKEN_BORDER)
self.SetBackgroundColour(wxNamedColor("Gray"))
----
<snip>
----
def OnLeftButtonEvent(self, event):
if event.Dragging():
dc = wxClientDC(self)
self.PrepareDC(dc)
dc.SetClippingRegion(self.clipping_x1,self.clipping_y1,self.clipping_width,s
elf.clipping_height)
dc.Clear()
dc.BeginDrawing()
self.DrawObjects(dc)
dc.EndDrawing()
dc.DestroyClippingRegion()
----
(btw: The gray background does work before the dc.Clear())
Lie number two: "Clears the device context"
On Windows, dc.Clear() doesn't do anything.
So, Am I mad?
Please Help
-Andy
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
ok, so i am slightly mad.
I solved Lie Number One by adding
dc.SetBackground(wxBrush('Gray'))
DOH!
But Lie Number Two is still causing problems.
btw: I have upgrading wxPython to 2.3.0 in my windows machine.
-Andy
Andy Dawkins wrote:
···
I am having problems with dc.Clear() and wondered if I am going mad.
I am developing in Linux (rd7.2) and Windows Me
wxPython Version 2.2.5
I have read the documentation and it clearly states:
-------
wxDC.Clear()
void Clear()
Clears the device context using the current background brush
-------
Now ether I'm doing something wrong or there are two lies in the
statement.
Lie number one: "current background brush"
On Linux, dc.Clear() clears the dc but uses the white brush _not_ the
current background brush.
----
class MyCanvas(wxScrolledWindow):
def __init__(self, parent, id=-1, size=wxDefaultSize):
wxScrolledWindow.__init__(self, parent, id, wxDefaultPosition,
size, wxSUNKEN_BORDER)
self.SetBackgroundColour(wxNamedColor("Gray"))
----
<snip>
----
def OnLeftButtonEvent(self, event):
if event.Dragging():
dc = wxClientDC(self)
self.PrepareDC(dc)
dc.SetClippingRegion(self.clipping_x1,self.clipping_y1,self.clipping_width,self.clipping_height)
dc.Clear()
dc.BeginDrawing()
self.DrawObjects(dc)
dc.EndDrawing()
dc.DestroyClippingRegion()
----
(btw: The gray background does work before the dc.Clear())
Lie number two: "Clears the device context"
On Windows, dc.Clear() doesn't do anything.
So, Am I mad?
Please Help
-Andy
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users