an issue with circles in circles

14 views
Skip to first unread message

Nathan smith

unread,
Nov 10, 2021, 7:33:01 PM11/10/21
to wxpytho...@googlegroups.com
Hi there,


I'm having a little issue with drawing a circle within a circle, within
a cirlce.

I've bound to the wx.EVT_PAINT event, have a black pen with width 4 and
color black on a unmodified frame background.


The following code draws a box on the screen and splits it up the middle:

  size=self.GetClientSize()
  tpx=int(size.x/10)
  tpy=int(size.y/10)
  dc.DrawLine(tpx*2, tpy*2, tpx*8, tpy*2)
  dc.DrawLine(tpx*2, tpy*8, tpx*8, tpy*8)
  dc.DrawLine(tpx*2, tpy*2, tpx*2, tpy*8)
  dc.DrawLine(tpx*8, tpy*2, tpx*8, tpy*8)
  dc.DrawLine(tpx*5, tpy*2, tpx*5, tpy*8)


The following two variables set the center point for the left and right
boxes.

  lc=[int(tpx*4), tpy*4]
  rc=[int(tpx*6), tpy*4]


I have a list of numbers like the following:

shells=[[4, []], [6, []], [8, []]


I then draw the circles as follows:

for x in shells:

 dc.DrawCircle(lc[0], lc[1], (size.x/100)*x[0])


When this code is run, it draws the first central circle when it is
added, but the more circles i add to the list, instead of drawing circle
B around Circle A, it deletes Circle A and just draws a bigger circle B.

Is this to do with overlapping backgrounds?

I'm confused!


Best,

Nathan

Tim Roberts

unread,
Nov 11, 2021, 4:22:37 PM11/11/21
to wxPython-users
Sort of.  By default, circles are filled.  The perimeter is drawn with the pen, the inside is drawn with a brush.  You just need to set an empty brush.

dc.SetBrush(*wxTRANSPARENT_BRUSH);

Nathan smith

unread,
Nov 13, 2021, 6:39:13 PM11/13/21
to wxpytho...@googlegroups.com

Thanks Tim, this was just the thing.


Nathan

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/3e84b68c-5431-40a7-9529-c26bae697e05n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages