ya intente hacerlo pero me han salido unos errores
Código python:
Ver originalimport wx
import wx.stc as stc
class Log:
def WriteText(self, text):
if text[-1:] == '\n':
text = text[:-1]
wx.LogMessage(text)
write = WriteText
debug = 1
log = Log
class Style(stc.StyledTextCtrl):
def __init__(self, parent, id):
stc.StyledTextCtrl.__init__(self, parent, id)
self.log = log
self.Bind(stc.EVT_STC_DO_DROP, self.OnDoDrop)
self.Bind(stc.EVT_STC_DRAG_OVER, self.OnDragOver)
self.Bind(stc.EVT_STC_START_DRAG, self.OnStartDrag)
self.Bind(stc.EVT_STC_MODIFIED, self.OnModified)
def OnStartDrag(self, evt):
self.log.write("OnStartDrag: %d, %s\n"
% (evt.GetDragAllowMove(), evt.GetDragText()))
if debug and evt.GetPosition() < 250:
evt.SetDragAllowMove(False) # you can prevent moving of text (only copy)
evt.SetDragText("DRAGGED TEXT") # you can change what is dragged
def OnDragOver(self, evt):
self.log.write(
"OnDrag: x,y=(%d, %d) pos: %d DragResult: %d\n"
% (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult())
)
if debug and evt.GetPosition() < 250:
evt.SetDragResult(wx.DragNone)
def OnDoDrop(self, evt):
self.log.write("OnDrop: x,y=(%d, %d) pos: %d DragResult: %d\n" "\ttext: %s\n"
% (evt.GetX(), evt.GetY(), evt.GetPosition(), evt.GetDragResult(),
evt.GetDragText()))
if debug and evt.GetPosition() < 500:
evt.SetDragText("DROPPED TEXT")
def OnModified(self, evt):
self.log.write("""OnModified
Mod type: %s
At position: %d
Lines added: %d
Text Length: %d
Text: %s\n""" % ( self.transModType(evt.GetModificationType()),
evt.GetPosition(),
evt.GetLinesAdded(),
evt.GetLength(),
repr(evt.GetText() )))
def transModType(self, modType):
st = ""
table = [(stc.STC_MOD_INSERTTEXT, "InsertText"),
(stc.STC_MOD_DELETETEXT, "DeleteText"),
(stc.STC_MOD_CHANGESTYLE, "ChangeStyle"),
(stc.STC_MOD_CHANGEFOLD, "ChangeFold"),
(stc.STC_PERFORMED_USER, "UserFlag"),
(stc.STC_PERFORMED_UNDO, "Undo"),
(stc.STC_PERFORMED_REDO, "Redo"),
(stc.STC_LASTSTEPINUNDOREDO, "Last-Undo/Redo"),
(stc.STC_MOD_CHANGEMARKER, "ChangeMarker"),
(stc.STC_MOD_BEFOREINSERT, "B4-Insert"),
(stc.STC_MOD_BEFOREDELETE, "B4-Delete")
]
for flag,text in table:
if flag & modType:
st = st + text + " "
if not st:
st = 'UNKNOWN'
return st
class Mystyle(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title)
style = Style(self, -1)
self.Show(True)
app = wx.App()
Mystyle( None, -1, "stylado")
app.MainLoop()
aver si lo pueden probar y decirme porque no funciona que es el str que me falta