Programación Web y Scripting > Python
Rectángulo
(1/1)
luesmo2:
O pongo el siguiente código, haber si me podeis decir por qué no pinta el rectángulo. Todo los demás está en el sitio (sólo es una prueba). El texto "Pintado" si sale.
Gracias a todos. Luis....
--- Código: Text ---#!/usr/bin/python from wx import *import osimport sys ID_boton1=1ID_salir= 2ID_ejecutar=3 class Absolute(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(250, 180)) self.panel = wx.Panel(self, -1) menubar = wx.MenuBar() menu= wx.Menu() menu.Append(ID_ejecutar,'Ejecutar','Ejecuta un programa') menu.Append(ID_salir,'Salir','Para salir') menubar.Append(menu, '&Opciones') self.SetMenuBar(menubar) self.st = wx.StaticText(self.panel, -1, "Ciao",pos=(0,80),size=(50,20)) wx.TextCtrl(self.panel, -1, pos=(10,10), size=(50, 20)) wx.Button(self.panel,ID_boton1,'Boton 1', pos=(10,30), size=(70,25)) EVT_BUTTON(self, ID_boton1, self.Click_Boton1) self.Bind(wx.EVT_MENU, self.Click_Salir, id=ID_salir) self.Bind(wx.EVT_MENU, self.Click_Ejecutar, id=ID_ejecutar) self.Pintar() self.Centre() self.Show(True) def Click_Boton1(self, event): wx.MessageBox("Has pulsado el boton 1") def Click_Salir(self, event): wx.MessageBox("Has pulsado salir") self.Close(1) def Click_Ejecutar(self, event): #wx.MessageBox("Has pulsado ejecutar") cmd='python Ejecuta.py En' sts=os.system (cmd) p = Popen(cmd, shell=True) sts = os.waitpid(p.pid, 0) def Pintar(self): #Hostiasssssss :argh: self.dc = wx.PaintDC(self.panel) self.dc.Clear() self.dc.BeginDrawing() self.dc.SetPen(wx.Pen("BLACK",1)) self.dc.DrawRectangle(70, 50, 120, 120) self.dc.EndDrawing() self.st.SetLabel('Dibujado') del self.dc #os.chdir('/home/luesmo2/Proyectos/Pruebas/') app = wx.App(0)Absolute(None, -1, 'Prueba')app.MainLoop()
Navegación
Ir a la versión completa