• Jueves 28 de Marzo de 2024, 13:20

Autor Tema:  Rectángulo  (Leído 1135 veces)

luesmo2

  • Nuevo Miembro
  • *
  • Mensajes: 6
    • Ver Perfil
Rectángulo
« en: Sábado 27 de Septiembre de 2008, 12:24 »
0
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
  1. #!/usr/bin/python
  2.  
  3. from wx import *
  4. import os
  5. import sys
  6.  
  7. ID_boton1=1
  8. ID_salir= 2
  9. ID_ejecutar=3
  10.  
  11. class Absolute(wx.Frame):  
  12.     def __init__(self, parent, id, title):
  13.         wx.Frame.__init__(self, parent, id, title, size=(250, 180))
  14.         self.panel = wx.Panel(self, -1)
  15.        
  16.         menubar = wx.MenuBar()
  17.         menu= wx.Menu()
  18.         menu.Append(ID_ejecutar,'Ejecutar','Ejecuta un programa')
  19.         menu.Append(ID_salir,'Salir','Para salir')
  20.  
  21.         menubar.Append(menu, '&Opciones')
  22.        
  23.         self.SetMenuBar(menubar)
  24.  
  25.         self.st = wx.StaticText(self.panel, -1, "Ciao",pos=(0,80),size=(50,20))      
  26.  
  27.         wx.TextCtrl(self.panel, -1, pos=(10,10), size=(50, 20))
  28.                
  29.         wx.Button(self.panel,ID_boton1,'Boton 1', pos=(10,30), size=(70,25))
  30.         EVT_BUTTON(self, ID_boton1, self.Click_Boton1)
  31.         self.Bind(wx.EVT_MENU, self.Click_Salir, id=ID_salir)
  32.         self.Bind(wx.EVT_MENU, self.Click_Ejecutar, id=ID_ejecutar)
  33.  
  34.         self.Pintar()        
  35.        
  36.         self.Centre()
  37.         self.Show(True)
  38.    
  39.     def Click_Boton1(self, event):
  40.  
  41.         wx.MessageBox("Has pulsado el boton 1")
  42.        
  43.  
  44.  
  45.     def Click_Salir(self, event):
  46.  
  47.         wx.MessageBox("Has pulsado salir")
  48.         self.Close(1)
  49.  
  50.  
  51.     def Click_Ejecutar(self, event):
  52.  
  53.         #wx.MessageBox("Has pulsado ejecutar")
  54.         cmd='python Ejecuta.py En'
  55.  
  56.         sts=os.system (cmd)
  57.         p = Popen(cmd, shell=True)
  58.         sts = os.waitpid(p.pid, 0)
  59.        
  60.  
  61.     def Pintar(self):                                      #Hostiasssssss :argh:
  62.         self.dc = wx.PaintDC(self.panel)
  63.         self.dc.Clear()
  64.         self.dc.BeginDrawing()
  65.         self.dc.SetPen(wx.Pen("BLACK",1))
  66.         self.dc.DrawRectangle(70, 50, 120, 120)
  67.         self.dc.EndDrawing()
  68.         self.st.SetLabel('Dibujado')
  69.         del self.dc
  70.  
  71. #os.chdir('/home/luesmo2/Proyectos/Pruebas/')
  72.  
  73. app = wx.App(0)
  74. Absolute(None, -1, 'Prueba')
  75. app.MainLoop()
  76.