Search code examples
wxpythonwxwidgets

Why wxwidgets draw loosely the circles or rounded polygons?


For example, if I draw this circle

Circle

is clearly imprecise and ugly. Is there any way to adjust the sensitivity of the draw?

edit:

I can summarize to:

self.da = wx.Panel(self, -1, size=(-1, 800))
self.da.Bind(wx.EVT_PAINT, self.paint)

self._buffer = wx.EmptyBitmap(500,500) # creating empty buffer
dc = wx.MemoryDC(self._buffer)  # to handle the buffer
dc.SetBackground( wx.Brush("White") )  # setting background
dc.DrawCircle(50,40,100)  #drawing circle


def paint(self, evt):
    dc = wx.BufferedPaintDC(self.da, self._buffer) #on paint event draw this

Solution

  • You can use wx.GCDC because it support anti-aliased drawing

    Try this:

    buffer = wx.EmptyBitmap(500,500) # creating empty buffer
    dc = wx.MemoryDC(buffer)  # to handle the buffer
    dc = wx.GCDC(dc)
    
    dc.SetBackground( wx.Brush("White") )  # setting background
    dc.DrawCircle(50,40,100)  #drawing circle
    dc.DrawCircle(200,200,100)  #drawing circle
    

    enter image description here