Python Example:
import wx from MplCirclePack import * class CircleFrame(wx.Frame): def __init__(self, parent, id, title, size): wx.Frame.__init__(self, parent, id, title, size=size) self.CreateButton('Solve', (18, 60), (80, 25), self.Solve) self.CreateButton('Clear', (18, 95), (80, 25), self.Clear) wx.StaticText(self, -1, "Number of Circles:", (18, 18)) self.txtCircles = wx.TextCtrl(self, -1, value="3", pos=wx.Point(125, 15), size=wx.Size(50, 20)) self.panel = wx.Panel(self, -1, size=(503,503), pos=(125,60), style=wx.BORDER_SUNKEN) def CreateButton(self, label, pos, size, cmd): button = wx.Button(self, -1, label, pos, size) button.Bind(wx.EVT_BUTTON, cmd) return button def Clear(self, event): self.panel.Refresh() def Solve(self, event): circlesStr = self.txtCircles.GetValue() try: circles = int(circlesStr) except ValueError: print("Please enter a valid integer value for Number of Circles") return circlePack = MplCirclePack() result = circlePack.SolveModel("LGO", circles) if result == False: print("There is no solution available with this input.\n" + "The solver returned the following message:\n" + str(circlePack.ResultString)) return self.DrawCircles(circlePack.SolXVal, circlePack.SolYVal, circlePack.SolRadius, 250) def DrawCircles(self, xVal, yVal, radius, size): count = len(xVal) dc = wx.ClientDC(self.panel) dc.SetPen(wx.Pen("#000000", 1, wx.SOLID)) dc.SetBrush(wx.Brush('#f08080')) for i in range(count): dc.DrawCircle((xVal[i] + 1.0) * size, (yVal[i] + 1.0) * size, radius * size) if __name__ == '__main__': app = wx.PySimpleApp() frame = CircleFrame(None, -1, 'CirclePack', (680, 630)) frame.Center() frame.Show() app.MainLoop()