[wxPython-users] how to draw the image in wx.BufferedDC on the
page created by AddPage of wx.Notebook
Christopher Barker
Chris.Barker at noaa.gov
Thu Aug 10 09:52:25 PDT 2006
zxo102 wrote:
> Hi everyone, I have tried two days to figure out how to draw the
> image in wx.BufferedDC on the page created by AddPage of wx.Notebook
> but still got no clue.
You problem has nothing to do with the BufferedWindow. Your issue is =
that when a Frame has only one child, the child is automatically fit to =
the Frame. wx.Notebooks don't do the same auto-sizing, so you were =
getting your window, but it was tiny and up in the corner.
In situations like this, it's always a good idea to reduce the problem =
to it's simplest -- try putting just a blank wx.panel or something on a =
Notebook, and see what happens.
I've enclosed a version of the code that sort of works -- it makes the =
Frame too small to begin with, but if you re-size it it should work.
To do this right, you'll need to use some Sizers.
I changed a couple things in the BufferedWindow code, to make passing =
parameters in cleaner, so I could pass in a size parameter when creating =
it. I also cleaned up a few style issues -- be sure to check out:
http://wiki.wxpython.org/index.cgi/wxPython_Style_Guide
I'm sorry that the BufferedWindow code doesn't conform to that style -- =
I haven't had the chance to change it. Feel free to go in and fix that =
up in the Wiki.
Here are some comments on a few other points:
class DrawWindow(BufferedWindow):
def __init__(self, *args, **kwargs):
BufferedWindow.__init__(self, parent, id)
There is no reason to create an __init__ that does nothing but call the =
superclass __init__ it will be called anyway.
wx.Frame.__init__(self, None, -1, "Double Buffered Test",
wx.DefaultPosition,
size=3D(500,500),
style=3D wx.DEFAULT_FRAME_STYLE | =
wx.NO_FULL_REPAINT_ON_RESIZE)
if you use keyword parameters, you don't need the defaults.
I think wx.NO_FULL_REPAINT_ON_RESIZE is now default, so you can do this =
instead:
wx.Frame.__init__(self, None,
title=3D"Double Buffered Test",
size=3D(500,500)
)
str =3D apply(os.path.join, tuple(path.split('/')))
you don't need apply:
str =3D os.path.join(*(path.split('/')))
The "*" means: pass this sequence in as the arguments.
def __init__(self, parent, id,
pos =3D wx.DefaultPosition,
size =3D wx.DefaultSize,
style=3Dwx.NO_FULL_REPAINT_ON_RESIZE):
wx.Window.__init__(self, parent, id, pos, size, style)
It's much cleaner to just do the pass-through:
def __init__(self, *args, **kwargs):
wx.Window.__init__(self, *args, **kwargs)
-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 at noaa.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: double_buffer_operation22.py
Type: text/x-python
Size: 4505 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20060=
810/2f39a3a7/double_buffer_operation22.py
More information about the wxpython-users
mailing list