The three events call methods which call doDrawing().
Now, if I comment out the EVT_SIZE and EVT_PAINT, my key press event
will still call the doDrawing method.
However, what I can't understand is that without the wx.EVT_SIZE
binding, nothing draws on start-up i.e. my call to doDrawing() isn't
working in __init__.
What am I missing? I'm sure it works like this for a good reason, so
there's obviously some gotchas I need to be aware of.
Regards,
Liam Clarke
···
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
The three events call methods which call doDrawing().
Now, if I comment out the EVT_SIZE and EVT_PAINT, my key press event
will still call the doDrawing method.
However, what I can't understand is that without the wx.EVT_SIZE
binding, nothing draws on start-up i.e. my call to doDrawing() isn't
working in __init__.
Are you sure that it isn't the EVT_PAINT that if it is not present will not give you anything at startup?
You really shouldn't need to do any drawing to the screen from the EVT_SIZE event anyway. If the size causes more of the window to become visible then the system will send you an EVT_PAINT event anyway.
What am I missing? I'm sure it works like this for a good reason, so
there's obviously some gotchas I need to be aware of.
There is usually an initial size event when the window is shown.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
No, the size event is what's drawing on init for me, I went through
and commented one by one.
I just wondered why an explicit call to the drawing method from the
__init__ method didn't have the same functionality, this actually
caused me a whole lot of confusion when I first tried to use dc's, as
I was chucking the dc calls in the __init__ of a class, just to test
it out, it wasn't until I (in desperation) added the two event
handlers that I had any success.
Regards,
Liam Clarke
···
On Apr 6, 2005 2:28 PM, Robin Dunn <robin@alldunn.com> wrote:
Liam Clarke wrote:
> Hi all,
>
> Please bear with this wxNewbie.
>
> I'm poking the dc objects, and I've got this
>
> class DrawPanel(wx.Panel):
>
> def __init__(self, parent, id = -1, size = wx.DefaultSize):
> wx.Panel.__init__( self, parent, id, wx.DefaultPosition, size)
> wx.EVT_SIZE(self, self.onSize)
> wx.EVT_PAINT(self, self.onPaint)
> wx.EVT_CHAR(self, self.onKey)
> self.doDrawing()
>
>
> The three events call methods which call doDrawing().
>
> Now, if I comment out the EVT_SIZE and EVT_PAINT, my key press event
> will still call the doDrawing method.
>
> However, what I can't understand is that without the wx.EVT_SIZE
> binding, nothing draws on start-up i.e. my call to doDrawing() isn't
> working in __init__.
Are you sure that it isn't the EVT_PAINT that if it is not present will
not give you anything at startup?
You really shouldn't need to do any drawing to the screen from the
EVT_SIZE event anyway. If the size causes more of the window to become
visible then the system will send you an EVT_PAINT event anyway.
>
> What am I missing? I'm sure it works like this for a good reason, so
> there's obviously some gotchas I need to be aware of.
There is usually an initial size event when the window is shown.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
No, the size event is what's drawing on init for me, I went through
and commented one by one.
I just wondered why an explicit call to the drawing method from the
__init__ method didn't have the same functionality,
Because the window is not visible at that point in time, and when it becomes visible it is cleared by the system and it then sends a paint event (among others) so the window can do whatever drawing it needs to do.
this actually
caused me a whole lot of confusion when I first tried to use dc's, as
I was chucking the dc calls in the __init__ of a class, just to test
it out, it wasn't until I (in desperation) added the two event
handlers that I had any success.
If a paint event is not happening when the window is first shown then there is some problem. Can you please make a small sample app that shows this issue and post it here?
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
> I just wondered why an explicit call to the drawing method from the
> __init__ method didn't have the same functionality,
Because the window is not visible at that point in time, and when it
becomes visible it is cleared by the system and it then sends a paint
event (among others) so the window can do whatever drawing it needs to do.
Ah, that would explain it. Thanks, the fog of powerful versatility is
lifting. : )
If a paint event is not happening when the window is first shown then
there is some problem. Can you please make a small sample app that
shows this issue and post it here?
Um... I'm embarrassed now, I went and looked at my code, and corrected
my typo, and the paint event works fine... mea culpa.
Out of curiosity though, when the docs say that a dc should only be
used as a stack object, does that mean it's ok to have a dc such as
class foo()
self.DC = wx.ClientDC(self),
but just not to pickle it or similar?
Thanks a bundle,
Liam Clarke
···
On Apr 6, 2005 4:34 PM, Robin Dunn <robin@alldunn.com> wrote:
--
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
Out of curiosity though, when the docs say that a dc should only be
used as a stack object, does that mean it's ok to have a dc such as
class foo()
self.DC = wx.ClientDC(self),
but just not to pickle it or similar?
No, storing it in the instance, like self, means that it sticks around as long as the object does, which is what you are being warned against. The general practice to to create a new wx.DC in every method you need one.
That being said, you are unlikely to run into any problems keeping a few DCs around, except maybe on older versions of Windows.
-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