Ver Mensaje Individual
  #4 (permalink)  
Antiguo 28/02/2009, 20:20
iozk
 
Fecha de Ingreso: mayo-2008
Mensajes: 499
Antigüedad: 16 años
Puntos: 1
Respuesta: ayuda!!! con codigo

ya intente hacerlo pero me han salido unos errores

Código python:
Ver original
  1. import wx
  2. import wx.stc as stc
  3.  
  4.  
  5.  
  6. class Log:
  7.     def WriteText(self, text):
  8.         if text[-1:] == '\n':
  9.             text = text[:-1]
  10.         wx.LogMessage(text)
  11.     write = WriteText
  12. debug = 1
  13. log = Log
  14.  
  15. class Style(stc.StyledTextCtrl):
  16.     def __init__(self, parent, id):
  17.         stc.StyledTextCtrl.__init__(self, parent, id)
  18.         self.log = log
  19.  
  20.        
  21.         self.Bind(stc.EVT_STC_DO_DROP, self.OnDoDrop)
  22.         self.Bind(stc.EVT_STC_DRAG_OVER, self.OnDragOver)
  23.         self.Bind(stc.EVT_STC_START_DRAG, self.OnStartDrag)
  24.         self.Bind(stc.EVT_STC_MODIFIED, self.OnModified)
  25.  
  26.  
  27.  
  28.     def OnStartDrag(self, evt):
  29.         self.log.write("OnStartDrag: %d, %s\n"
  30.                        % (evt.GetDragAllowMove(), evt.GetDragText()))
  31.  
  32.         if debug and evt.GetPosition() < 250:
  33.             evt.SetDragAllowMove(False)     # you can prevent moving of text (only copy)
  34.             evt.SetDragText("DRAGGED TEXT") # you can change what is dragged
  35.            
  36.     def OnDragOver(self, evt):
  37.         self.log.write(
  38.             "OnDrag: x,y=(%d, %d)  pos: %d  DragResult: %d\n"
  39.             % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult())
  40.             )
  41.  
  42.         if debug and evt.GetPosition() < 250:
  43.             evt.SetDragResult(wx.DragNone)
  44.            
  45.     def OnDoDrop(self, evt):
  46.         self.log.write("OnDrop: x,y=(%d, %d) pos: %d DragResult: %d\n" "\ttext: %s\n"
  47.                        % (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult(),
  48.                           evt.GetDragText()))
  49.         if debug and evt.GetPosition() < 500:
  50.             evt.SetDragText("DROPPED TEXT")
  51.  
  52.     def OnModified(self, evt):
  53.         self.log.write("""OnModified
  54.        Mod type:     %s
  55.        At position:  %d
  56.        Lines added:  %d
  57.        Text Length:  %d
  58.        Text:         %s\n""" % ( self.transModType(evt.GetModificationType()),
  59.                                   evt.GetPosition(),
  60.                                   evt.GetLinesAdded(),
  61.                                   evt.GetLength(),
  62.                                   repr(evt.GetText() )))
  63.  
  64.     def transModType(self, modType):
  65.         st = ""
  66.         table = [(stc.STC_MOD_INSERTTEXT, "InsertText"),
  67.                  (stc.STC_MOD_DELETETEXT, "DeleteText"),
  68.                  (stc.STC_MOD_CHANGESTYLE, "ChangeStyle"),
  69.                  (stc.STC_MOD_CHANGEFOLD, "ChangeFold"),
  70.                  (stc.STC_PERFORMED_USER, "UserFlag"),
  71.                  (stc.STC_PERFORMED_UNDO, "Undo"),
  72.                  (stc.STC_PERFORMED_REDO, "Redo"),
  73.                  (stc.STC_LASTSTEPINUNDOREDO, "Last-Undo/Redo"),
  74.                  (stc.STC_MOD_CHANGEMARKER, "ChangeMarker"),
  75.                  (stc.STC_MOD_BEFOREINSERT, "B4-Insert"),
  76.                  (stc.STC_MOD_BEFOREDELETE, "B4-Delete")
  77.                  ]
  78.  
  79.         for flag,text in table:
  80.             if flag & modType:
  81.                 st = st + text + " "
  82.  
  83.         if not st:
  84.             st = 'UNKNOWN'
  85.  
  86.         return st
  87.    
  88.    
  89.  
  90. class Mystyle(wx.Frame):
  91.     def __init__(self, parent, id, title):
  92.         wx.Frame.__init__(self, parent, id, title)
  93.  
  94.         style = Style(self, -1)
  95.  
  96.         self.Show(True)
  97.  
  98. app = wx.App()
  99. Mystyle( None, -1, "stylado")
  100. app.MainLoop()

aver si lo pueden probar y decirme porque no funciona que es el str que me falta