Ver Mensaje Individual
  #4 (permalink)  
Antiguo 10/10/2008, 15:16
iozk
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 16 años, 6 meses
Puntos: 1
Respuesta: hacer .exe a los archivos .py

no funciona mi codigo

Código python:
Ver original
  1. import wx
  2.  
  3. class SketchWindow(wx.Window):
  4.     def __init__(self, parent, ID):
  5.         wx.Window.__init__(self, parent, ID)
  6.  
  7.        
  8.        
  9.         self.SetBackgroundColour("blue")
  10.         self.color = "white"
  11.         self.thickness = 1
  12.         self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)
  13.         self.lines = []
  14.         self.curLine = []
  15.         self.pos = (0, 0)
  16.         self.InitBuffer()
  17.         self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
  18.         self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
  19.         self.Bind(wx.EVT_MOTION, self.OnMotion)
  20.         self.Bind(wx.EVT_SIZE, self.OnSize)
  21.         self.Bind(wx.EVT_IDLE, self.OnIdle)
  22.         self.Bind(wx.EVT_PAINT, self.OnPaint)
  23.  
  24.  
  25.     def InitBuffer(self):
  26.         size = self.GetClientSize()
  27.         self.buffer = wx.EmptyBitmap(size.width, size.height)
  28.         dc = wx.BufferedDC(None, self.buffer)
  29.         dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
  30.         dc.Clear()
  31.         self.DrawLines(dc)
  32.         self.reInitBuffer = False
  33.  
  34.     def GetLinesData(self):
  35.         return self.lines[:]
  36.  
  37.     def SetLinesData(self, lines):
  38.         self.lines = lines[:]
  39.         self.InitBuffer()
  40.         self.Refresh()
  41.  
  42.     def OnLeftDown(self, event):
  43.         self.curLine = []
  44.         self.pos = event.GetPositionTuple()
  45.         self.CaptureMouse()
  46.  
  47.     def OnLeftUp(self, event):
  48.         if self.HasCapture():
  49.             self.lines.append((self.color, self.thickness, self.curLine))
  50.             self.curLine = []
  51.             self.ReleaseMouse()
  52.  
  53.     def OnMotion(self, event):
  54.         if event.Dragging() and event.LeftIsDown():
  55.             dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
  56.             self.drawMotion(dc, event)
  57.             event.Skip()
  58.  
  59.     def drawMotion(self, dc, event):
  60.         dc.SetPen(self.pen)
  61.         newPos = event.GetPositionTuple()
  62.         coords = self.pos + newPos
  63.         self.curLine.append(coords)
  64.         dc.DrawLine(*coords)
  65.         self.pos = newPos
  66.  
  67.     def OnSize(self, event):
  68.         self.reInitBuffer = True
  69.  
  70.     def OnIdle(self, event):
  71.         if self.reInitBuffer:
  72.             self.InitBuffer()
  73.             self.Refresh(False)
  74.  
  75.     def OnPaint(self, event):
  76.         dc = wx.BufferedPaintDC(self, self.buffer)
  77.  
  78.     def DrawLines(self, dc):
  79.         for colour, thickness, line in self.lines:
  80.             pen = wx.Pen(colour, thickness, wx.SOLID)
  81.             dc.SetPen(pen)
  82.             for coords in line:
  83.                 dc.DrawLine(*coords)
  84.  
  85.     def SetColor(self, color):
  86.         self.color = color
  87.         self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)
  88.  
  89.     def SetThickness(self, num):
  90.         self.thickness = num
  91.         self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)
  92.  
  93.  
  94. class SketchFrame(wx.Frame):
  95.     def __init__(self, parent, id, title):
  96.         wx.Frame.__init__(self, parent, id, size=(800,600))
  97.         self.sketch = SketchWindow(self, -1)
  98.         menubar = wx.MenuBar()
  99.         file = wx.Menu()
  100.         file.Append(file, '&File')
  101.         self.SetMenuBar(menubar)
  102.  
  103.         self.Show(True)
  104.  
  105. app = wx.App()
  106. SketchFrame(None, -1, "Sketch Frame",)
  107. app.MainLoop()

Última edición por iozk; 10/10/2008 a las 15:29 Razón: highlight