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 Panel(wx.Panel):
def __init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
self.x = None
self.y = None
self.r = None
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.SetAutoLayout(True)
self.SetSizer(box)
self.Layout()
self.bttn.Bind(wx.EVT_BUTTON, self.OnClick)
self.Bind(wx.EVT_PAINT, self.OnPaint)
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)
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.x = x
self.y = y
self.r = r
self.Update()
self.Refresh()
app = wx.App(0)
f = MyFrame(None,-1,"hola")
app.MainLoop()
Mismo código pero con un solo panel.