Pen and Brush Styles

58 views
Skip to first unread message

Andrea Gavana

unread,
Aug 8, 2011, 5:22:26 PM8/8/11
to wxPython-users, wxPyth...@googlegroups.com
Hi All,

    I know that the OwnerDrawnCombobox sample provides an overview of the available styles for wx.Pen. However, I thought it would be nice to have a more comprehensive demo about all the possible styles available for wx.Pen and wx.Brush.

So I put together this small demo showing exactly what wx.Pen and wx.Brush are capable of. Please let me know if there is any interest about this (maybe we might think of including it in the wxPython demo?).

Tested on wxPython 2.8.11 and Python 2.5, wxPython 2.9.2.1 and Python 2.7, Windows Vista and Windows 7.


Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

pen_brush_styles.py

Ray Pasco

unread,
Aug 9, 2011, 1:28:55 PM8/9/11
to wxpytho...@googlegroups.com, wxPython-users, wxPyth...@googlegroups.com
"A picture is worth a thousand words."

Very nice !  This needs to go into the wxPython Demo app.

The display becomes much more informative if the single dc.DrawLine() call at the bottom of PenPanel:: is replaced by these two :

        dc.DrawLine( 5, 30, width-5, 45 )
        dc.DrawLine( 5, 25, width-5, 25 )

There's no apparent use to drawing a line that's set to wx.TRANSPARENT. There is a purpose drawing a box which is set that way, but  whichhas a visible outline.  Add these lines near the bottom of BrushPanel::OnPaint() :

        if "wx.TRANSPARENT" in name :
            dc.SetPen( wx.Pen( wx.BLUE, 2, wx.SOLID ) )


Ray

Ray Pasco

unread,
Aug 9, 2011, 1:46:50 PM8/9/11
to wxpytho...@googlegroups.com, wxPython-users, wxPyth...@googlegroups.com
I hadn't had my 2nd cup of coffee yet on my previous post...

In PenPanel::OnPaint() the two dc.DrawLine() calls can be :

        dc.DrawLine( 5, 25, width-5, 25 )               # horizontal (constant Y value)
        dc.DrawLine( 5, 30, width-5, self.Size[1]-10 )  # diagonal U-L to L-R

Now, try resizing the Frame.

Ray

pen_brush_styles_Mod.py

Robin Dunn

unread,
Aug 9, 2011, 2:23:39 PM8/9/11
to wxpytho...@googlegroups.com
On 8/9/11 10:28 AM, Ray Pasco wrote:
>
> There's no apparent use to drawing a line that's set to wx.TRANSPARENT.

The demo is not about "drawing a line" but rather displaying the
available pen styles and what they look like, and there are plenty of
reasons to sometimes use a transparent pen when using a DC for drawing.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Ray Pasco

unread,
Aug 9, 2011, 3:11:29 PM8/9/11
to wxpytho...@googlegroups.com
What is the point of drawing a transparent line all by itself ?  It seems to make sense only when calling DrawRectangle() so that the rectangle outline is not seen.


Ray Pasco

Robin Dunn

unread,
Aug 10, 2011, 12:31:04 PM8/10/11
to wxpytho...@googlegroups.com
On 8/9/11 12:11 PM, Ray Pasco wrote:

> The demo is not about "drawing a line" but rather displaying the
> available pen styles and what they look like, and there are plenty
> of reasons to sometimes use a transparent pen when using a DC for
> drawing.
>

>


> What is the point of drawing a transparent line all by itself ? It
> seems to make sense only when calling DrawRectangle() so that the
> rectangle outline is not seen.

Like I said above, it doesn't matter that it makes no sense to draw a
transparent line. The point of the demo is to let the user know what
the pen and brush styles are and what they look like. wx.TRANSPARENT is
a valid pen style, and when you use it with a pen in a DC drawing
operation the pen is not stroked. I think the demo is showing that just
fine.

Ray Pasco

unread,
Aug 11, 2011, 2:14:32 AM8/11/11
to wxpytho...@googlegroups.com

    PenAndBrushStyles wxPython wiki page
Reply all
Reply to author
Forward
0 new messages