Espero que esto mas o menos te ayude.
Código Python:
Ver originalimport wx
class MyFrame(wx.Frame):
def __init__(self, parent,id, title):
wx.Frame.__init__(self, parent,id, title,size=(700,700))
self.Panel = Panel(self)
self.Show()
class DrawPanel(wx.Panel):
def __init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.x = None
self.y = None
self.r = None
def OnPaint(self, event):
dc = wx.PaintDC(self)
dc.SetPen(wx.Pen("BLACK", 4))
if(self.x is not None and self.y is not None and self.r is not None):
dc.DrawCircle(self.x, self.y, self.r)
class Panel(wx.Panel):
def __init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
box = wx.BoxSizer(wx.VERTICAL)
box1 = wx.BoxSizer(wx.HORIZONTAL)
self.txt1 = wx.TextCtrl(self)
self.lbl1 = wx.StaticText(self, label='x: ')
box1.Add(self.lbl1)
box1.Add(self.txt1)
box2 = wx.BoxSizer(wx.HORIZONTAL)
self.txt2 = wx.TextCtrl(self)
self.lbl2 = wx.StaticText(self, label='y: ')
box2.Add(self.lbl2)
box2.Add(self.txt2)
box3 = wx.BoxSizer(wx.HORIZONTAL)
self.txt3 = wx.TextCtrl(self)
self.lbl3 = wx.StaticText(self, label='radio: ')
box3.Add(self.lbl3)
box3.Add(self.txt3)
box.Add(box1)
box.Add(box2)
box.Add(box3)
self.bttn = wx.Button(self, label='Dibujar')
box.Add(self.bttn)
self.dc = DrawPanel(self)
box.Add(self.dc, 1, wx.EXPAND)
self.SetAutoLayout(True)
self.SetSizer(box)
self.Layout()
self.bttn.Bind(wx.EVT_BUTTON, self.OnClick)
def OnClick(self, event):
try:
x = int(self.txt1.GetValue())
y = int(self.txt2.GetValue())
r = int(self.txt3.GetValue())
except ValueError:
print "x, y o radio no son numeros"
return
self.dc.x = x
self.dc.y = y
self.dc.r = r
self.dc.Update()
self.dc.Refresh()
app = wx.App(0)
f = MyFrame(None,-1,"hola")
app.MainLoop()