Código Python:
Ver originalimport wx
import random
class ventana(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self,parent,size=(700,700))
self.Show()
self.Bind(wx.EVT_PAINT,self.onpaint)
self.Bind(wx.EVT_BUTTON,self.onboton)
boton = wx.Button(self, label="inicio", pos=(450, 450))
self.entes = 10
def onboton(self,event):
self.entes = random.randrange(10,390,20)
self.Refresh()
self.Update()
def onpaint(self,event):
dc = wx.PaintDC(self)
dc.SetPen(wx.Pen("BLACK"))
dc.DrawRectangle(10,10,400,400)
dc.DrawLine(30,10,30,410)
dc.DrawLine(50,10,50,410)
dc.DrawLine(70,10,70,410)
dc.DrawLine(90,10,90,410)
dc.DrawLine(110,10,110,410)
dc.DrawLine(130,10,130,410)
dc.DrawLine(150,10,150,410)
dc.DrawLine(170,10,170,410)
dc.DrawLine(190,10,190,410)
dc.DrawLine(210,10,210,410)
dc.DrawLine(230,10,230,410)
dc.DrawLine(250,10,250,410)
dc.DrawLine(270,10,270,410)
dc.DrawLine(290,10,290,410)
dc.DrawLine(310,10,310,410)
dc.DrawLine(330,10,330,410)
dc.DrawLine(350,10,350,410)
dc.DrawLine(370,10,370,410)
dc.DrawLine(390,10,390,410)
dc.DrawLine(10,30,410,30)
dc.DrawLine(10,50,410,50)
dc.DrawLine(10,70,410,70)
dc.DrawLine(10,90,410,90)
dc.DrawLine(10,110,410,110)
dc.DrawLine(10,130,410,130)
dc.DrawLine(10,150,410,150)
dc.DrawLine(10,170,410,170)
dc.DrawLine(10,190,410,190)
dc.DrawLine(10,210,410,210)
dc.DrawLine(10,230,410,230)
dc.DrawLine(10,250,410,250)
dc.DrawLine(10,270,410,270)
dc.DrawLine(10,290,410,290)
dc.DrawLine(10,310,410,310)
dc.DrawLine(10,330,410,330)
dc.DrawLine(10,350,410,350)
dc.DrawLine(10,370,410,370)
dc.DrawLine(10,390,410,390)
dc.SetBrush(wx.Brush("BLUE",wx.SOLID))
dc.DrawRectangle(self.entes, self.entes, 20, 20)
dc.SetBrush(wx.Brush("RED",wx.SOLID))
dc.DrawRectangle(70,70,20,20)
dc.SetBrush(wx.Brush("BLACK",wx.SOLID))
dc.DrawRectangle(270,270,20,20)
app = wx.App(0)
v = ventana(None)
app.MainLoop()