PythonWin/Scintilla aggressive folding...

Olivier Dagenais olivierS.dagenaisP at canadaA.comM
Tue Jul 25 11:36:44 EDT 2000


I have the following wxPython code:

class ztApp ( wxApp ) :

 def OnInit ( self ) :
  frame = ztLoader ( )
  frame.Show ( true )
  self.SetTopWindow ( frame )
  return true


# Main code
pngHandler = wxPNGHandler ( )
wxImage_AddHandler ( pngHandler )
app = ztApp ( 0 )
app.MainLoop ( )



...which is fine and dandy.  Next, I want fold away the class, and the
result is this:


class ztApp ( wxApp ) :
pngHandler = wxPNGHandler ( )
wxImage_AddHandler ( pngHandler )
app = ztApp ( 0 )
app.MainLoop ( )


My comment is missing.  It isn't part of the class definition, yet was
"gobbled up" by the fold.  Can I prevent this?  Also, I'd like it to be even
smarter and not gobble up blank lines after the class definition, so that
the end result would look like so:

class ztApp ( wxApp ) :


# Main code
pngHandler = wxPNGHandler ( )
wxImage_AddHandler ( pngHandler )
app = ztApp ( 0 )
app.MainLoop ( )


Ideas?  This seems to be a Scintilla issue, as
pywin\framework\editor\color\coloreditor.py seems to indicate that PythonWin
doesn't do the actual folding:

def FoldExpandEvent(self, event):
  if not self.bFolding:
   win32api.MessageBeep()
   return
  win32ui.DoWaitCursor(1)
  lineno = self.LineFromChar(self.GetSel()[0])
  if self.SCIGetFoldLevel(lineno) & SC_FOLDLEVELHEADERFLAG and \
    not self.SCIGetFoldExpanded(lineno):
   self.SCIToggleFold(lineno)
  win32ui.DoWaitCursor(-1)


Thanks for your help!

--
----------------------------------------------------------------------
Olivier A. Dagenais - Carleton University - Computer Science III







More information about the Python-list mailing list