Commits

stani  committed 5887ab9
  • Participants
  • Parent commits 3c132f2

Comments (0)

Files changed (7)

File Child2.py

-####(c)www.stani.be-------------------------------------------------------------
-
-import _spe.info
-INFO=_spe.info.copy()
-
-INFO['description']=\
-"""File browser as tab."""
-
-__doc__=INFO['doc']%INFO
-
-####Modules---------------------------------------------------------------------
-import codecs, inspect, os, sys, re, time
-
-import wx
-from wx.lib.evtmgr import eventManager
-
-import sm, sm.uml, sm.wxp
-from sm.wxp.stc import PythonSTC
-from sm.wxp.realtime import Tree, ListCtrl
-
-import _spe.help as help
-import _spe.plugins.Pycheck as Pycheck
-from sidebar.Browser import Browser
-
-####Constants-------------------------------------------------------------------
-DEFAULT                 = "<default>"
-NEWFILE                 = 'unnamed'
-SPE_ALLOWED_EXTENSIONS  = ['.py','.pyw','.tpy','.txt','.htm','.html']
-STYLE_LIST              = wx.LC_REPORT
-STYLE_NOTEBOOK          = wx.NO_BORDER
-STYLE_NOTES             = wx.TE_MULTILINE|wx.TE_DONTWRAP
-STYLE_SPLIT             = wx.SP_NOBORDER|wx.FULL_REPAINT_ON_RESIZE
-STYLE_TREE              = wx.TR_HAS_BUTTONS
-RE_TODO                 = re.compile('.*#[ ]*TODO[ ]*:(.+)', re.IGNORECASE)
-RE_SEPARATOR            = re.compile('^.*(#-{3})')
-RE_SEPARATOR_HIGHLIGHT  = re.compile('^.*(#{4})')
-RE_ENCODING             = re.compile('# -[*]- coding[:=]\s*([-\w.]+)', re.IGNORECASE)
-
-####Utilities-------------------------------------------------------------------
-def umlAdd(classes, umlClass):
-    """Add umlClass to classes dictionary"""
-    if umlClass: 
-        classes[umlClass.name.split('(')[0]] = umlClass
-
-####Child Panel class-----------------------------------------------------------
-class Source(PythonSTC):
-    def __init__(self,parent):
-        child = parent
-        while child.__class__ != Panel:
-            child = child.GetParent()
-        PythonSTC.__init__(self,parent=parent,
-            namespace= child.parentPanel.shell.interp.locals,
-            path=child._fileName,config=child.parentPanel.config)
-        self.SetHelpText(help.CHILD_SOURCE)
-        child.source = self
-
-
-class Panel(wx.SplitterWindow):
-    ####Constructors------------------------------------------------------------
-    def __init__(self,parent,name='',fileName='',source='',*args,**kwds):
-        self._fileName      = fileName
-        self._source        = source
-        #initialize
-        self.changed        = 0
-        self.column         = 1
-        self.line           = 1
-        self.sashPosition   = 285
-        self.saved          = ''
-        self.todoMax        = 1
-        #construct
-        wx.SplitterWindow.__init__(self, id=-1, parent=parent,style=STYLE_SPLIT)
-        self.SetMinimumPaneSize(1)
-        #Remember if this file contains DOS line endings (\r\n)
-        #Otherwise assume Unix (\n)
-        self.dosLines = (source.find('\r\n') >= 0)
-        self.sashDelta      = 1
-        
-        
-    def __finish__(self):
-        frame = self.frame
-        frame.setTitle(page=os.path.basename(self._fileName),extra=self._fileName)
-        frame.SetIcon(sm.wxp.bitmap2Icon(self.app.bitmap('icon_py.png')))
-        self.__source__(self._fileName,self._source)
-        self.__sideBar__()
-        #events
-        self.source.SetDropTarget(DropOpen(self.parentPanel.openList))
-        eventManager.Register(self.onSetFocus, wx.EVT_SET_FOCUS, self)
-        
-    def __sideBar__(self):
-        """Create notebook contents."""
-        #notebook
-        notebook = self.notebook = wx.Notebook(id=-1, parent=self, pos=wx.Point(2, 2),
-              size=wx.Size(198, 481),style=STYLE_NOTEBOOK)
-        self.notebookLabel  = ['Explore','Browser','Todo','Index','Notes','Check']
-        self.notebookIcons  = wx.ImageList(16,16)
-        self.exploreIcon    = self.notebookIcons.Add(self.parentPanel.icons['explore.png'])
-        self.browserIcon    = self.notebookIcons.Add(self.parentPanel.icons['browser.png'])
-        self.todoIcon       = self.notebookIcons.Add(self.parentPanel.icons['todo.png'])
-        self.indexIcon      = self.notebookIcons.Add(self.parentPanel.icons['index.png'])
-        self.notesIcon      = self.notebookIcons.Add(self.parentPanel.icons['notes.png'])
-        self.pycheckerIcon  = self.notebookIcons.Add(self.parentPanel.icons['pychecker.png'])
-        if sys.platform != 'darwin':
-            self.notebook.SetBackgroundColour(wx.Colour(255,255,255))
-        notebook.AssignImageList(self.notebookIcons)
-        self.notebookSizer = wx.BoxSizer(wx.VERTICAL)
-        self.notebookSizer.Add(self.notebook, 1, wx.ALL | wx.EXPAND , 10)
-        #self.SetAutoLayout(1)
-        self.SetSizer(self.notebookSizer)
-        notebook.parentPanel=self.parentPanel
-
-        #explore
-        explore     = self.explore = Tree(parent=self.notebook,style=STYLE_TREE)#wx.TreeCtrl
-        explore.SetBackgroundColour(wx.Colour(255,255,255))
-        self.root   = self.explore.AddRoot('Right click to locate')
-        explore.SetPyData(self.root,0)
-        explore.SetImageList(self.parentPanel.iconsList)
-        explore.SetItemImage(self.root,self.parentPanel.iconsListIndex['note.png'])
-        explore.SetItemImage(self.root,self.parentPanel.iconsListIndex['note.png'],wx.TreeItemIcon_SelectedExpanded)
-        explore.SetItemImage(self.root,self.parentPanel.iconsListIndex['note.png'],wx.TreeItemIcon_Expanded)
-        explore.SetItemImage(self.root,self.parentPanel.iconsListIndex['note.png'],wx.TreeItemIcon_Selected)
-        explore.SetHelpText(help.CHILD_EXPLORE)
-        notebook.AddPage(page=self.explore.wx, text='Explore',imageId=self.exploreIcon)
-        #browser
-        browser         = self.browser = Browser(self.notebook, -1, os.path.dirname ( self._fileName ))
-        browser.open    = self.onOpenFromBrowser
-        notebook.AddPage (page=self.browser, text='', imageId=self.browserIcon)
-        #todo
-        todo            = self.todo = ListCtrl(parent=self.notebook,style=STYLE_LIST)
-        todo.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT, 
-                heading='Line',width=40)
-        todo.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT, 
-                heading='!',width=20)
-        todo.InsertColumn(col=2, format=wx.LIST_FORMAT_LEFT, 
-                heading='Task',width=500)
-        todo.SetHelpText(help.CHILD_TODO)
-        self.previousTodoHighlights = []
-        notebook.AddPage(page=self.todo.wx, text='',imageId=self.todoIcon)
-        #index
-        index = self.index = ListCtrl(parent=self.notebook,style=STYLE_LIST)
-        index.SetImageList(self.parentPanel.iconsList,wx.IMAGE_LIST_SMALL)
-        index.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT, 
-                heading='Line',width=50)
-        index.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT, 
-                heading='Entry',width=500)
-        index.SetHelpText(help.CHILD_INDEX)
-        notebook.AddPage(page=self.index.wx, text='',imageId=self.indexIcon)
-        #notes
-        self.notes = wx.TextCtrl(parent=self.notebook,id=-1,value=self.notesText,
-            style=STYLE_NOTES)
-        self.notes.SetHelpText(help.CHILD_NOTES)
-        self.notebook.AddPage(page=self.notes, text='',imageId=self.notesIcon)
-        #pyChecker
-        self.pychecker          = Pycheck.Panel(self.notebook,page=5)
-        self.notebook.AddPage(page=self.pychecker, text='',imageId=self.pycheckerIcon)        
-        #events
-        self.updateSidebarTab=[self.updateExplore,self.updateBrowser,self.updateTodo,self.updateIndex,self.doNothing,self.doNothing]
-        self.source.SetModEventMask(wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER)
-        eventManager.Register(self.onSourceChange,wx.stc.EVT_STC_CHANGE,self.source)
-        eventManager.Register(self.onSourceFromExplore,wx.EVT_TREE_ITEM_ACTIVATED,self.explore)
-        eventManager.Register(self.onSourceFromExplore,wx.EVT_TREE_ITEM_RIGHT_CLICK,self.explore)
-        eventManager.Register(self.onSourceFromTodo,wx.EVT_LIST_ITEM_SELECTED,self.todo)
-        eventManager.Register(self.onSourceFromTodo,wx.EVT_LIST_ITEM_RIGHT_CLICK,self.todo)
-        eventManager.Register(self.onSourceFromIndex,wx.EVT_LIST_ITEM_RIGHT_CLICK,self.index)
-        eventManager.Register(self.onSourceFromIndex,wx.EVT_LIST_ITEM_SELECTED,self.index)
-        eventManager.Register(self.updateSidebar,wx.EVT_NOTEBOOK_PAGE_CHANGED,self.notebook)
-        #split
-        self.SplitVertically(self.notebook, self.main, self.sashPosition)
-        self.SetAutoLayout(True)
-        #update
-        self.updateExplore()
-
-    def __source__(self,fileName,source):
-        #notebook
-        self.main = wx.Notebook(id=-1, parent=self, size=wx.Size(5000, 5000),style=wx.NO_BORDER)#, pos=wx.Point(2, 2),size=wx.Size(198, 481))
-        self.mainIcons   = wx.ImageList(16,16)
-        self.sashIcon    = self.mainIcons.Add(self.parentPanel.icons['source.png'])
-        self.umlIcon     = self.mainIcons.Add(self.parentPanel.icons['uml.png'])
-        self.main.AssignImageList(self.mainIcons)
-        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
-        self.mainSizer.Add(self.main, 1, wx.ALL | wx.EXPAND , 10)
-        self.SetAutoLayout(1)
-        self.SetSizer(self.mainSizer)
-        
-        #sash
-        self.sash = PythonSTC(parent=self.main,
-            namespace=self.parentPanel.shell.interp.locals,
-            path=os.path.dirname(fileName),config=self.parentPanel.config)
-        self.sash.SetHelpText(help.CHILD_SOURCE)
-        self.source = self.sash
-        #todo: implement this again with sashview
-        #if wx.Platform == "__WXMAC__":
-        #    self.source = self.sash
-        #else:
-        #    self.source = self.sash.view
-        if fileName:
-            self.fileName=fileName
-            self.revert(source)
-        else: 
-            self.fileName=NEWFILE
-            self.notesText=''
-            self.frame.setTitle()
-        self.source.EmptyUndoBuffer()
-        self.source.Colourise(0, -1)
-        self.source.menu=self.parentFrame.menuBar.edit
-        self.eventChanged = False
-        self.main.AddPage(page=self.sash, text='Source',imageId=self.sashIcon)
-        
-        #uml
-        self.uml    = sm.uml.wxCanvas(parent=self.main,style=wx.FULL_REPAINT_ON_RESIZE)
-        self.main.AddPage(page=self.uml, text='Uml',imageId=self.umlIcon)
-        
-        #events
-        eventManager.Register(self.onKillFocus, wx.EVT_KILL_FOCUS, self.source)
-        eventManager.Register(self.source.OnRightClick, wx.EVT_RIGHT_UP, self.source)
-        eventManager.Register(self.updateMain,wx.EVT_NOTEBOOK_PAGE_CHANGED,self.main)
-    ####Menu--------------------------------------------------------------------
-    #---file
-    def save(self,fileName=None):
-        """Saves the file."""
-        if fileName: self.setFileName(fileName)     
-        if self.fileName==NEWFILE or not(os.path.exists(self.fileName)):
-            self.saveAs()
-        else:
-            self.source.assertEOL()
-            source=self.source.GetText()
-            if self.parentPanel.getValue('StripTrailingSpaces'):
-                source='\n'.join([l.rstrip() for l in source.split('\n')])
-            content = str(source.replace('\r\n','\n'))
-            if not self.dosLines:
-                #convert to Unix lines
-                content     = str(source.replace('\r\n','\n'))
-            #Note that the mode here must be "wb" to allow
-            #line endings to be preserved.
-            if self.encoding:
-                file        = codecs.open(str(self.fileName),'wb',self.encoding)
-            else:
-                file        = open(str(self.fileName),'wb')
-            file.write(content)
-            file.close()
-            self.notesSave(file=1)
-            self.changed    = 0
-            self.saved      = source
-            self.updateSidebar()
-            self.parentPanel.recent.add([self.fileName])
-            if self.parentPanel.getValue('CheckFileOnSave'):
-                if not self.check():
-                    self.parentPanel.shell.prompt()
-            else:
-                self.SetStatusText("File '%s' saved"%self.fileName,1)
-            if fileName:
-                self.frame.setTitle(os.path.basename(fileName),fileName)
-            else:
-                self.frame.setTitle()
-        self.fileTime=os.path.getmtime(self.fileName)
-    
-    def saveAs(self):
-        defaultDir=os.path.dirname(self.fileName)
-        dlg = wx.FileDialog(self, "Save As - www.stani.be", defaultDir=defaultDir, 
-            wildcard=_spe.info.WILDCARD, 
-            style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
-        if dlg.ShowModal() == wx.ID_OK:
-            paths = dlg.GetPaths()
-            self.save(paths[0])
-        dlg.Destroy()
-        
-    #---edit
-    def comment(self):
-        """Comment section"""
-        doc = self.source
-        sel = doc.GetSelection()
-        start = doc.LineFromPosition(sel[0])
-        end = doc.LineFromPosition(sel[1])
-        if end > start and doc.GetColumn(sel[1]) == 0:
-            end = end - 1
-        doc.BeginUndoAction()
-        for lineNumber in range(start, end + 1):
-            firstChar = doc.PositionFromLine(lineNumber)
-            doc.InsertText(firstChar, '##')
-        doc.SetCurrentPos(doc.PositionFromLine(start))
-        doc.SetAnchor(doc.GetLineEndPosition(end))
-        doc.EndUndoAction()
-        
-    def uncomment(self):
-        """Uncomment section"""
-        doc = self.source
-        sel = doc.GetSelection()
-        start = doc.LineFromPosition(sel[0])
-        end = doc.LineFromPosition(sel[1])
-        if end > start and doc.GetColumn(sel[1]) == 0:
-            end = end - 1
-        doc.BeginUndoAction()
-        for lineNumber in range(start, end + 1):
-            firstChar = doc.PositionFromLine(lineNumber)
-            if chr(doc.GetCharAt(firstChar)) == '#':
-                if chr(doc.GetCharAt(firstChar + 1)) == '#':
-                    # line starts with ##
-                    doc.SetCurrentPos(firstChar + 2)
-                else:
-                    # line starts with #
-                    doc.SetCurrentPos(firstChar + 1)
-                doc.DelLineLeft()
-        doc.SetSelection(sel[0],doc.PositionFromLine(end+1))
-        doc.EndUndoAction()
-                
-    def insert_separator(self):
-        from dialogs import separatorDialog
-        separatorDialog.create(self).ShowModal()
-        
-    def go_to_line(self,scroll=1):
-        """Go to line dialog & action"""
-        line=self.parentPanel.messageEntry('Enter line number:')
-        if line: self.scrollTo(int(line)-1)
-
-    #---View
-    def refresh(self):
-        if self.parentPanel.redraw:self.parentPanel.redraw()
-        self.updateSidebar()
-        
-    def toggle_sidebar(self,event):
-        pos = self.GetSashPosition()
-        if pos > 5:
-            self.sashPosition   = pos
-            self.SetSashPosition(1)
-        else:
-            self.SetSashPosition(self.sashPosition)
-        if self.frame.menuBar:
-            self.frame.menuBar.check_sidebar(event)
-        else:
-            self.parentFrame.menuBar.check_sidebar(event)
-        
-    #---Tools
-    def open_terminal_emulator(self):
-        """Open terminal emulator"""       
-        path,fileName=os.path.split(self.fileName)
-        params = {'file':fileName,'path':path}
-        terminal=self.parentPanel.get('Terminal')
-        if terminal==DEFAULT:
-            if sys.platform=='win32':
-                os.system('start "Spe console - Press Ctrl+Break to stop" /D"%(path)s"'%params)
-            else:
-                os.system("cd \"%(path)s\"; /usr/X11R6/bin/xterm &"%params)
-        else:
-            os.system(terminal%params)
-
-    def run_in_terminal_emulator(self):
-        """Run in terminal emulator"""
-        # todo: input stuff from preferences dialog box!
-        path,fileName=os.path.split(self.fileName)
-        params = {'file':fileName,'path':path}
-        terminal=self.parentPanel.get('TerminalRun')
-        if terminal==DEFAULT:
-            if sys.platform=='win32':
-                os.system('start "Spe - %(file)s - Press Ctrl+Break to stop" /D"%(path)s" start /B python "%(file)s"'%params)
-            else:
-                os.system("/usr/bin/Eterm -e 'cd \"%(path)s\"; python \"%(file)s\"'"%params)
-        else:
-            os.system(terminal%params)
-            
-    def run_in_terminal_emulator_exit(self):
-        path,fileName=os.path.split(self.fileName)
-        params = {'file':fileName,'path':path}
-        terminal=self.parentPanel.get('TerminalRunExit')
-        if terminal==DEFAULT:
-            if sys.platform=='win32':
-                os.system('start "Spe - %(file)s - Press Ctrl+Break to stop" /D"%(path)s" python "%(file)s"'%params)
-            else:
-                os.system("/usr/bin/Eterm -e 'cd \"%(path)s\"; python \"%(file)s\"'"%params)
-        else:
-            os.system(terminal%params)
-        
-    def check_source_with_pychecker(self): 
-        """Check source with pychecker"""
-        self.pychecker.check()
-        
-    #---Blender
-    def load_in_blender(self):
-        """Load in blender"""
-        if self.checkBlender():
-            child=self.parentPanel.childActive
-            answer=child.confirmSave('Only saved contents will be loaded in Blender.')
-            if answer:
-                import blenpy.pyGui
-                blenpy.pyGui.pythonLoad(child.fileName)
-        
-    def reference_in_blender(self):
-        """Reference in blender"""
-        if self.checkBlender():
-            import blenpy.plugins.mouse
-            blenpy.plugins.mouse.reference(self.parentPanel.childActive.fileName)
-        
-    ####Events------------------------------------------------------------------
-    #---Smdi events
-    def onActivate(self,event=None):
-        if self.frame.menuBar:
-            self.frame.menuBar.check_sidebar()
-        else:
-            self.parentFrame.menuBar.check_sidebar()
-            self.updateStatus()
-        self.source.SetFocus()
-
-    def onClose(self, event=None):
-        if self.confirmSave():
-            eventManager.DeregisterWindow(self)
-            self.frame.dead = 1
-            if len(self.app.children)==1:
-                self.parentFrame.menuBar.enable(0)
-            return True
-        else: return False
-        return True
-        
-    def onSize(self, event=None):
-        self.source.SetFocus()
-
-    #---Panel events
-    def onSetFocus(self,event):
-        event.Skip()
-        self.checkTime()
-        try:
-            self.source.SetFocus()
-        except:
-            pass
-       
-    #---Source events
-    def onSourceChange(self,event):
-        self.eventChanged = True
-
-    def onSourcePositionChange(self,event=None):
-        """Updates statusbar with current position."""
-        
-    def idle(self,event=None):
-        if not self.frame.dead and self.eventChanged:
-            if self.changed==0:
-                self.changed=1
-                self.frame.setTitle()
-            elif self.changed<0:
-                self.changed+=1
-            self.eventChanged = False
-            if self.parentPanel.get('UpdateSidebar')=='realtime':
-                self.updateSidebarTab[self.notebook.GetSelection()]()
-            self.updateStatus()
-            #if not self.check():
-            #    self.parentPanel.shell.prompt()
-                
-    def onKillFocus(self,event=None):
-        if self.app.DEBUG:
-            print 'Event:  Child: %s.onKillFocus(dead=%s)'%(self.__class__,self.frame.dead)
-        try:
-            if self.parentPanel.get('UpdateSidebar')=='when clicked':
-                self.source.SetSTCFocus(0)
-                self.updateSidebar()
-            event.Skip()
-        except:
-            pass
-        
-    #---Sidebar update methods & jump events
-    def updateSidebar(self,event=None):
-        if event:
-            tab = event.GetSelection()
-            self.notebook.SetPageText(event.GetOldSelection(),'')
-            self.notebook.SetPageText(tab,self.notebookLabel[tab])
-            event.Skip()
-        else:
-            tab = self.notebook.GetSelection()
-        self.updateSidebarTab[tab]()
-        
-    def updateBrowser(self): 
-        self.browser.update()
-        
-    def updateStatus(self):
-        if hasattr(self,'source'):
-            source=self.source
-            pos=source.GetCurrentPos()
-            self.position=pos
-            line=source.LineFromPosition(pos)
-            column=source.GetColumn(pos)
-            if line!=self.line:
-                self.line=line
-                self.SetStatusText('Line %05d'%(line+1),2)
-            if column!=self.column:
-                self.column=column
-                self.SetStatusText('Column %03d'%column,3)
-        else:
-            self.SetStatusText('',2)
-            self.SetStatusText('',3)
-       
-    def updateTodo(self):
-        """Update todo tab in sidebar."""
-        #get text
-        try:
-            text=self.source.GetText().split('\n')
-        except:
-            return
-        #initialize
-        tryMode                     = 0 #try, except are false indentations
-        hierarchyIndex              = 0
-        todoData                    = []
-        todoIndex                   = 0
-        self.todoMax                = 1
-        self.todoHighlights         = []
-        self.todoList               = []
-        hierarchy                   = [(-1,self.root)]
-        self.todo.DeleteAllItems()
-        #loop through code wxPython.lib.evtmgr
-        for line in range(len(text)):
-            l                       = text[line].strip()
-            todo_hit                = RE_TODO.match(l)
-            first                   = l.split(' ')[0]
-            if first=='try:':
-                tryMode         += 1
-            elif first[:6]=='except':
-                tryMode         = max(0,tryMode-1)
-            elif first[:7]=='finally':
-                tryMode         = max(0,tryMode-1)
-            elif todo_hit:
-                #todo entry
-                task                    = todo_hit.group(1)
-                urgency                 = task.count('!')
-                self.todoList.append((line,urgency,task))
-                item                    = self.todo.InsertStringItem(todoIndex, str(line+1), str(urgency), task)
-                self.todo.SetItemData(item,line+1)
-                #highlights
-                newMax                  = max(self.todoMax,urgency)
-                if newMax>self.todoMax:
-                    self.todoMax        =   newMax
-                    self.todoHighlights = [item]
-                elif urgency==self.todoMax:
-                    self.todoHighlights.append(item)
-                todoIndex+=1
-        #highlight most urgent todos
-        for i in self.todoHighlights:
-            if i not in self.previousTodoHighlights:
-                item=self.todo.GetItem(i)
-                item.SetBackgroundColour(wx.Colour(255,255,0))
-                self.todo.SetItem(item)
-        for i in self.previousTodoHighlights:
-            if i not in self.todoHighlights:
-                item=self.todo.GetItem(i)
-                item.SetBackgroundColour(wx.Colour(255,255,255))
-                self.todo.SetItem(item)
-        self.previousTodoHighlights = self.todoHighlights
-        self.todo.Clean()
-        
-    def updateIndex(self):
-        """Update index tab in sidebar."""
-        #get code
-        try:
-            text=self.source.GetText().split('\n')
-        except:
-            return
-        #initialize
-        tryMode         = 0
-        hierarchyIndex  = 0
-        self.indexData  = []
-        #loop through code
-        for line in range(len(text)):
-            l           = text[line].split('#')[0].strip()
-            first       = l.split(' ')[0]
-            if first=='try:':
-                tryMode         += 1
-            elif first[:6]=='except':
-                tryMode         = max(0,tryMode-1)
-            elif first[:7]=='finally':
-                tryMode         = max(0,tryMode-1)
-            elif first in ['class','def'] and l[:8]!='__init__':
-                if first=='class':
-                    colour  = wx.Colour(255,0,0)
-                    icon    = 'folder_tar.png'
-                else:
-                    colour  = wx.Colour(0,0,255)
-                    icon    = 'kmail.png'
-                self.indexData.append((l.replace('_',' ').lstrip(),l,line+1,colour,
-                    self.parentPanel.iconsListIndex[icon],self.fileName))
-        #make index tab
-        self.indexData.sort()
-        firstLetter = ''
-        x           = 0
-        self.index.DeleteAllItems()
-        for element in self.indexData:
-            stripped,entry,line,colour,icon,fileName=element
-            if entry.split(' ')[1][0]!=firstLetter:
-                firstLetter=entry.split(' ')[1][0]
-                self.index.InsertStringItem(x, ' ', '%s (%s)'%(firstLetter.upper(),entry.split(' ')[0]))
-                x+=1
-            item=self.index.InsertImageStringItem(x, icon, str(line), entry)
-            self.index.SetItemData(item,line-1)
-            self.index.SetItemTextColour(item,colour)
-            x+=1
-        #if self.parentPanel.indexVisible...
-            
-    def updateExplore(self,uml=0):
-        """Updates explore in sidebar."""
-        #get text
-        try:
-            text=self.source.GetText().split('\n')
-        except:
-            return
-        #initialize
-        if uml:         
-            self.umlClass   = None
-            previous    = 0
-        classes         = {}
-        n               = len(text)
-        tryMode         = 0
-        hierarchyIndex  = 0
-        hierarchy       = [(-1,self.root)]
-        separators      = []
-        self.encoding   = None
-        self.explore.CollapseAndReset(self.root)
-        for line in range(len(text)):
-            l           = text[line].strip()
-            first       = l.split(' ')[0]
-            sepa_hit    = RE_SEPARATOR.match(l)
-            sepb_hit    = RE_SEPARATOR_HIGHLIGHT.match(l)
-            encode_hit  = RE_ENCODING.match(l)
-            if first in ['class','def','import','from'] or encode_hit:
-                if 1 or l.find('(')!=-1 or l.find(':') !=-1 or first in ['from','import'] or encode_hit:
-                    #indentation--------------------------------------------
-                    indentation         = max(0,len(text[line])-
-                        len(text[line].lstrip())-tryMode*4)
-                    #situate in hierachy------------------------------------
-                    hierarchyIndex      = 0
-                    while hierarchyIndex+1<len(hierarchy) and \
-                            hierarchy[hierarchyIndex+1][0]<indentation:
-                        hierarchyIndex  += 1
-                    hierarchy=hierarchy[:hierarchyIndex+1]
-                    if uml and hierarchyIndex<=previous: 
-                        umlAdd(classes,self.umlClass)
-                        self.umlClass    = None
-                    #get definition-----------------------------------------
-                    if encode_hit:
-                        l = encode_hit.group(1)
-                        self.encoding = l
-                    else:
-                        l = l.split('#')[0].strip()
-                    i=1
-                    if not(first in ['import','from'] or encode_hit):
-                        search  = 1
-                        rest    = ' '
-                        while search and l[-1] != ':' and i+line<n:
-                            #get the whole multi-line definition
-                            next = text[line+i].split('#')[0].strip()
-                            if next.find('class')==-1 and next.find('def')==-1 and next.find('import')==-1:
-                                rest    += next
-                                i       += 1
-                            else:
-                                search = 0
-                        if rest[-1] == ':':l+= rest
-                    #put in tree with color---------------------------------
-                    l=l.split(':')[0].replace('class ','').replace('def ','').strip()
-                    if separators: 
-                        self.appendSeparators(separators,hierarchy,hierarchyIndex,uml)
-                        separators      = []
-                    if l:
-                        item                = self.explore.AppendItem(hierarchy[hierarchyIndex][1],l)
-                        self.explore.SetPyData(item,line)
-                        intensity=max(50,255-indentation*20)
-                        if encode_hit:
-                            colour              = wx.Colour(intensity-50,0,intensity-50)
-                            icon                = iconExpand = 'encoding.png'
-                        elif first == 'class':
-                            if uml:
-                                umlAdd(classes,self.umlClass)
-                                self.umlClass   = sm.uml.Class(name=l,data=line)
-                                previous        = hierarchyIndex
-                            colour              = wx.Colour(intensity,0,0)
-                            icon                = 'class.png'
-                            iconExpand          = 'class.png'
-                        elif first in ['import','from']:
-                            colour              = wx.Colour(0,intensity-50,0)
-                            icon                = iconExpand = 'import.png'
-                        else:
-                            if uml and self.umlClass: self.umlClass.append(l)
-                            colour          = wx.Colour(0,0,intensity)
-                            icon            = iconExpand = 'def.png'
-                        self.explore.SetItemTextColour(item,colour)
-                        self.explore.SetItemImage(item,
-                            self.parentPanel.iconsListIndex[icon],
-                            which=wx.TreeItemIcon_Normal)
-                        if first=='class':
-                            self.explore.SetItemImage(item,
-                                self.parentPanel.iconsListIndex[iconExpand],
-                                which       = wx.TreeItemIcon_Expanded)
-                        hierarchy.append((indentation,item))
-            elif sepa_hit:
-                #separator
-                pos = sepa_hit.end()
-                colours=l[pos:].split('#')
-                if len(colours)==3:
-                    s       = sm.rstrip(colours[0],'_')
-                    fore    = '#'+colours[1][:6]
-                    back    = '#'+colours[2][:6]
-                else:
-                    s=sm.rstrip(l[pos:],'-')
-                    fore=wx.Colour(128,128,128)
-                    back=None
-                if s.strip(): separators.append((s,line,fore,back))
-            elif sepb_hit:
-                #highlighted separator (yellow)
-                pos = sepb_hit.end()
-                s   = sm.rstrip(l[pos:],'-')
-                if s.strip(): separators.append((s,line,wx.Colour(0,0,0),wx.Colour(255,255,0)))
-            elif first=='try:':
-                tryMode         += 1
-            elif first[:6]=='except':
-                tryMode         = max(0,tryMode-1)
-            elif first[:7]=='finally':
-                tryMode         = max(0,tryMode-1)
-        self.appendSeparators(separators,hierarchy,hierarchyIndex,uml)
-        if uml: umlAdd(classes,self.umlClass)
-        #expand root of explore
-        self.explore.Expand(self.root)
-        #if self.parentPanel.exploreVisible: ...
-        self.explore.Clean()
-        return classes
-        
-    def updateMain(self,event=None):
-        if event:
-            tab = event.GetSelection()
-            event.Skip()
-            if tab == 0:
-                self.source.SetFocus()
-            elif tab == 1:
-                self.uml.DrawUml(classes=self.updateExplore(uml=1))
-        else:
-            tab = self.notebook.GetSelection()
-        self.updateSidebarTab[tab]()
-        
-    def refreshMain(self):
-        pos = self.GetSashPosition()
-        self.sashDelta *= -1
-        self.SetSashPosition(pos+self.sashDelta, redraw=1)
-        
-    def doNothing(self):
-        pass
-    
-    def appendSeparators(self,separators,hierarchy,hierarchyIndex,uml):
-        explore = self.explore
-        for separator in separators:
-            label,line,fore,back=separator
-            sep=explore.AppendItem(hierarchy[hierarchyIndex][1],label)
-            explore.SetItemBold(sep)
-            explore.SetItemTextColour(sep,fore)
-            if back:explore.SetItemBackgroundColour(sep,back)
-            explore.SetItemImage(sep,self.parentPanel.iconsListIndex['separator.png'])
-            explore.SetPyData(sep,line)
-            if uml and self.umlClass: self.umlClass.append(label,t=sm.uml.SEPARATOR)
-
-    def onSourceFromExplore(self,event):
-        """Jump to source line by clicking class or function in explore."""
-        line=self.explore.GetPyData(event.GetItem())
-        self.scrollTo(line,select='line')
-            
-    def onOpenFromBrowser(self, fname):
-        if os.path.splitext(fname)[-1] in SPE_ALLOWED_EXTENSIONS:
-            self.parentPanel.openList([fname])
-        else:
-            os.startfile(fname)
-
-    def onSourceFromTodo(self,event):
-        """Jump to source line by clicking task in todo."""
-        line=event.GetData()
-        self.scrollTo(line-1,scroll=1)
-        
-    def onSourceFromIndex(self,event):
-        """Jump to source line by clicking task in todo."""
-        line=event.GetData()
-        self.scrollTo(line,scroll=1)
-
-#---methods---------------------------------------------------------------------
-    def check(self):
-        pythonFile=(os.path.splitext(self.fileName)[1].lower() in ['.py','.pyw'])
-        if pythonFile:
-            from sm.scriptutils import CheckFile
-            return CheckFile(self.fileName,jump=self.parentPanel.openList,
-                status=self.setStatus)
-        else: return 1
-
-    def checkTime(self):
-        if (not self.frame.dead) and os.path.exists(self.fileName):
-            try:
-                pos=self.source.GetCurrentPos()
-                fileTime=os.path.getmtime(self.fileName)
-                if fileTime>self.fileTime:
-                    #file is modified
-                    self.fileTime=fileTime
-                    baseName=os.path.basename(self.fileName)
-                    message=baseName+' is modified externally.\nDo you want to reload it%s?'
-                    if  (self.changed>0 and self.parentPanel.messageConfirm(message%' and loose current changes')) or\
-                    (not self.changed>0 and (self.parentPanel.getValue('AutoReloadChangedFile') or self.parentPanel.messageConfirm(message%''))): 
-                        self.revert()
-                        self.source.GotoPos(pos)
-                        return 1
-            except:
-                return 0
-                
-
-    def confirmSave(self, message=''):
-        self.notesSave(file=1)
-        if self.changed>0:
-            self.Raise()
-            message+='\nSave changes to "%s"?'%self.fileName
-            answer=self.parentPanel.messageCancel(message)
-            if answer==wx.ID_CANCEL:
-                return 0
-            elif self.parentPanel.messageIsOk(answer):
-                self.save()
-                return 1
-            else:return 1
-        else:return 1
-        
-    def refreshTitle(self):
-        if self.app.DEBUG:
-            print 'Method: Child: %s.refreshTitle("%s")'%(self.__class__,self.fileName)
-        self.frame.setTitle()
-        
-    def revert(self,source=None):
-        if not source:
-            try:
-                source=open(self.fileName).read()
-            except:
-                source=''
-        if self.parentPanel.getValue('ConvertTabsToSpaces'):
-            source=source.replace('\t',' '.ljust(self.parentPanel.getValue('TabWidth')))
-        self.source.SetText(source)
-        self.source.assertEOL()
-        try:
-            self.notesText=open(self.notesFile()).read()
-        except:
-            self.notesText=''
-        self.frame.setTitle()
-        self.changed=0
-
-    def setFileName(self,fileName):
-        self.fileName   = fileName
-        self.name       = self.name = os.path.basename(self.fileName)
-        index           = self.frame.getIndex()
-        mdi             = self.app.mdi
-        if not mdi:index+= 1
-        self.frame.tabs.SetPageText(index,self.name)
-        self.frame.setTitle()
-        if not mdi:
-            for child in self.app.children:
-                child.tabs.SetPageText(index,self.name)
-
-    def setStatus(self,text,i=1):
-        self.SetStatusText(text,i)
-        
-    def sidebarVisible(self):
-        return self.GetSashPosition() > 5
-        
-    def scrollTo(self,line=0,column=0,select='pos',scroll=0):
-        source  = self.source
-        source.EnsureVisible(line)
-        line    = source.VisibleFromDocLine(line)
-        linePos = source.PositionFromLine(line)
-        pos     = linePos+column
-        if select=='line':
-            source.SetSelection(linePos, source.GetLineEndPosition(line))
-        else: #select=='pos':
-            source.GotoPos(pos)
-        source.ScrollToLine(line)
-        source.ScrollToColumn(0)
-        source.SetFocus()
-
-    def notesFile(self):
-        return os.path.splitext(self.fileName)[0]+'_notes.txt'
-    
-    def notesSave(self,file=0):
-        self.notesText=self.notes.GetValue()
-        if file:
-            if not self.notesText:
-                try:
-                    os.remove(self.notesFile())
-                except:
-                    pass
-            else:
-                f=open(self.notesFile(),'w')
-                f.write(self.notesText)
-                f.close()
-
-    def selectLine(self,line):
-        source=self.source
-        
-
-class DropOpen(wx.FileDropTarget):
-    """Opens a file when dropped on parent frame."""
-    def __init__(self,openList):
-        wx.FileDropTarget.__init__(self)
-        self.openList   = openList
-    def OnDropFiles(self,x,y,fileNames):
-        fileNames       = [script for script in fileNames 
-            if os.path.splitext(script)[-1].lower() in SPE_ALLOWED_EXTENSIONS]
-        if fileNames:
-            self.openList(fileNames)
-            return 1
-        else:return 0
 #!/usr/bin/env python
 """Shortcut to launch spe in Windows."""
 if __name__=='__main__':
-    from _spe import main
-    main()
+    import _spe.SPE
 DARWIN                      = PLATFORM.startswith('darwin')
 
 path                        = os.path.dirname(__file__)
-os.chdir(path)
 
 #---Append sm
 smLocation                  = os.path.join(path,'sm')
-if smLocation not in sys.path:
-    sys.path.append(smLocation)
+if path not in sys.path:
+    sys.path.append(path)
 import sm.osx
 
 INFO={
     'author'           : "www.stani.be",
+    'author_email'     : 'spe.stani.be@gmail.com',
     'title'            : "SPE",
     'date'             : "13-9-2003",
     'doc'              : "%(titleFull)s\n\n%(description)s\n\n%(links)s\n\n%(requirements)s\n\n%(copyright)s",
     'pyVersion'        : "2.3",
     'pyVersionC'       : sys.version.split(' ')[0],
     'wxVersion'        : "2.6.1.0.",
+    'license'          : 'GPL',
     'location'         : path,
     'smLocation'       : smLocation,
+    'url'              : 'http://www.stani.be/python/spe', 
     'userPath'         : sm.osx.userPath('.spe'),
+    'scripts'          : ['spe']
 }
 
 
 INFO['titleFull']    = "%(title)s %(version)s"%INFO
 
 INFO['links']=\
-"""Homepage : http://spe.pycs.net
-Website  : http://projects.blender.org/projects/spe/
-Forum    : http://projects.blender.org/forum/?group_id=30
-Contact  : http://www.pycs.net/system/mailto.py?usernum=0000167"""
+"""Homepage : %s
+Donwloads: http://www.stani.be/python/spe/page_blender
+Forum    : http://www.stani.be/python/spe/page_forum
+Lists    : http://www.stani.be/python/spe/page_mailman"""%INFO['url']
 
 INFO['description']=\
 """Stani's Python Editor

File sm/wxp/smdi2.py

-####(c)www.stani.be-------------------------------------------------------------
-
-try:
-    import sm
-    INFO=sm.INFO.copy()
-    
-    INFO['title']     = INFO['titleFull'] = 'Sdi/Mdi Framework'
-    
-    INFO['description']=\
-    """Framework which makes it easy to switch between Sdi (Linux/Mac) 
-    and Mdi (Windows).
-    """
-
-    __doc__=INFO['doc']%INFO
-except:
-    __doc__=="Stani's Multiple Document Interface (c)www.stani.be"
-
-"""
-Attributes of Application:
-    - properties:
-        - children
-        - config
-        - DEBUG
-        - imagePath
-        - mdi
-        - title
-        - parentFrame
-        - pos
-        - size
-        - style
-    - methods:
-        - SetMdi
-    - classes:
-        - ChildFrame
-        - ChildPanel
-        - MenuBar
-        - ParentFrame
-        - ParentPanel
-        - StatusBar
-        - ToolBar
-        
-Attributes of Frame:
-    - properties:
-        - app
-        - dead
-        - menuBar
-        - parentFrame
-        - toolBar
-    - methods:
-        - getIndex
-        - (maximize)
-        - setTitle
-        - SetStatusText
-    - events:
-        - bindTabs
-        - unbindTabs
-        - onFrameActivate
-        - onFrameClose
-        - onFrameMove
-        - onFrameSize
-        - (onFrameTab)
-    - classes:
-        - Panel
-        
-Attributes of Panel:
-    - properties:
-        - changed
-        - frame
-        - title
-        - parentFrame
-        - parentPanel
-    - methods:
-    
-Attributes of MenuBar:
-    - properties:
-        - app
-        - frame
-        - parentFrame
-        - parentPanel
-        - toolBar
-
-Attributes of ToolBar:
-    - properties:
-        - app
-        - frame
-        - menuBar
-    
-Todo:
-- icon support
-"""
-
-####Modules
-import  os, sys, pprint
-import  wx
-from    wx.lib.evtmgr import eventManager
-#import sm.spy
-
-####Constants
-#values
-SDI                 = 0
-MDI_SASH            = 1
-MDI_SASH_TABS       = 2
-MDI                 = 3
-MDI_TABS            = 4
-#descriptions
-SDI_MAC             = "single with tabs (mac default, linux, windows)"
-MDI_SASH_WIN        = "multiple with sash (windows)"
-MDI_SASH_TABS_LINUX = "multiple with sash & tabs (linux default)"
-MDI_SASH_TABS_WIN   = "multiple with sash & tabs (windows default)"
-MDI_WIN             = "multiple (windows)"
-MDI_MAC             = "single (mac)"
-MDI_TABS_LINUX      = "multiple with tabs (linux)"
-MDI_TABS_WIN        = "multiple with tabs (linux)"
-MDI_TABS_MAC        = "single with tabs (mac)"
-
-DEFAULT             = "<default>"
-DI                  = {SDI_MAC                  : SDI,
-                       MDI_SASH_WIN             : MDI_SASH,
-                       MDI_SASH_TABS_LINUX      : MDI_SASH,
-                       MDI_SASH_TABS_WIN        : MDI_SASH_TABS,
-                       MDI_WIN                  : MDI,
-                       MDI_MAC                  : MDI,
-                       MDI_TABS_LINUX           : MDI,
-                       MDI_TABS_WIN             : MDI_TABS,
-                       MDI_TABS_MAC             : MDI_TABS,
-                       DEFAULT  : -1}
-
-PLATFORM                    = sys.platform
-WIN                         = PLATFORM.startswith('win')
-DARWIN                      = PLATFORM.startswith('darwin')
-
-#wx related
-FULL_REPAINT_ON_RESIZE      = wx.FULL_REPAINT_ON_RESIZE
-POS                         = (10,10)
-SIZE                        = (600,400)
-STYLE_CHILDFRAME            = wx.DEFAULT_FRAME_STYLE
-STYLE_NOTEBOOK              = FULL_REPAINT_ON_RESIZE|wx.CLIP_CHILDREN|wx.NO_BORDER
-STYLE_PARENTFRAME           = wx.DEFAULT_FRAME_STYLE #| wx.MAXIMIZE 
-STYLE_TOOLBAR               = wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT
-TABSASH_HEIGHT              = 28
-TITLE                       = 'www.stani.be'
-UNNAMED                     = 'unnamed'
-
-####Menu helper function
-def _(x):
-    if DARWIN:
-        return x.replace('Ctrl','Cmd')
-    else:
-        return x
-
-def _strip(x):
-    return x.replace(' ','_').replace('-','_').replace('&& ','').replace('&','').replace('.','').replace('(','').replace(')','')
-    
-def menuWrite(menuBar,f='menu.txt'):
-    labels = []
-    for m in range(menuBar.GetMenuCount()):
-        menu        = menuBar.GetMenu(m)
-        menuLabel   = menuBar.GetLabelTop(m)
-        for item in menu.GetMenuItems():
-            label   = _strip(item.GetLabel())
-            if label:
-                labels.append((menuLabel,item.GetLabel()))
-    #events
-    result = '\tdef __smdi__(self):\n'
-    for label in labels:
-        label = _strip(label[1])
-        result+= '\t\twx.EVT_MENU(self,%s,self.menu_%s)\n'%(label.upper(),label.lower())
-    result+= '\n'
-    for label in labels:
-        result+='\tdef menu_%s(self):\n\t\t"""%s"""\n\t\tpass\n\n'%(_strip(label[1].lower()),'%s > %s'%label)
-    print result
-    print os.getcwd()
-    print f
-    f   = open(f,'w')
-    f.write(result)
-    f.close()
-            
-def test_menuWrite():
-    import menu
-    menuWrite(wxgMenu.Bar())
-    
-####Base
-WX_BITMAP       = wx.Bitmap
-
-class Bitmap:
-    def __init__(self,path,app):
-        self.path = path
-        self.app = app
-    def __call__(self,x,t=wx.BITMAP_TYPE_ANY):
-        path = os.path.join(self.path,os.path.basename(x))
-        #if self.app.DEBUG:
-        #    print 'Bitmap: %s<%s'%(x,path)
-        return WX_BITMAP(path,t)
-        
-class DummyPage(wx.StaticText):
-    """Page to fill the tabs (not meant to be visible)."""
-    def __init__(self,tabs):
-        wx.StaticText.__init__(self, tabs, wx.ID_ANY, "SPE bug: This shouldn't be visible")
-            
-####Foundation Classes
-class Framework:
-    """Foundation class for every frame."""
-    def __init__(self,app,Panel,parentFrame,page='',extra='',**options):
-        #stage
-        self.__before__(app         = app,
-                        Panel       = Panel,
-                        parentFrame = parentFrame,
-                        page        = page,
-                        extra       = extra)
-        self.__stage__(page         = page,
-                       extra        = extra,
-                       **options)
-        self.__after__()
-        ##rest
-        self.__menu__()
-        self.__tool__(app)
-        self.__statusBar__()
-        self.__finish__()
-        self.__events__()
-        #show
-        self.Show(True)
-        
-    #---components
-    def __before__(self,app,Panel,parentFrame,page,extra):
-        """Reference frame attributes (not overwritten)."""
-        self.app            = app
-        self.Panel          = Panel
-        self.parentFrame    = parentFrame
-        self.dead           = False # todo: is this still necessary
-        if not hasattr(self,'isSdiParent'):
-            self.isSdiParent    = False
-        self.page           = page
-        self.extra          = extra
-
-        
-    def __stage__(self,page,extra,**options):
-        """Create notebook (to switch between documents) & panel
-        This is mostly overwritten."""
-        self.panel  = self.Panel(parent=self,**options)
-
-    def __after__(self):
-        """Reference panel attributes  (not overwritten)."""
-        panel               = self.panel
-        panel.app           = self.app
-        panel.frame         = self
-        panel.parentFrame   = self.parentFrame
-        panel.parentPanel   = self.parentFrame.panel
-        panel.changed       = False
-
-    def __menu__(self):
-        """Create: Framework: menu."""
-        if self.app.MenuBar and not self.isMdiChild:
-            if self.app.DEBUG:
-                print """Create: Framework: menu."""
-            if self.app.mdi:
-                frame                   = self.app
-            else:
-                frame                   = self
-            self.menuBar                = self.app.MenuBar(app=self.app,frame=frame)
-            self.SetMenuBar(self.menuBar)
-            #reference
-            self.menuBar.app            = self.app
-            #create
-            self.menuBar.frame          = self
-            self.menuBar.parentFrame    = self.parentFrame
-            self.menuBar.parentPanel    = self.parentFrame.panel
-        else:
-            self.menuBar                = None
-
-    def __tool__(self,app):
-        """Create toolbar
-        
-        Very important: in the custom wx.ToolBar class after the 
-        wx.ToolBar.__init__ the following code must be written:
-            parent.SetToolBar(self)"""
-        if self.app.ToolBar and not (self.isMdiChild or self.isSdiParent):
-            if self.app.DEBUG:
-                print """Create: Framework: toolbar."""
-            #create
-            self.toolBar                = self.app.ToolBar(parent=self, app=app,
-                id=wx.ID_ANY, style=STYLE_TOOLBAR)
-            #self.SetToolBar(self.toolBar)-> do this in toolbar class
-            #reference
-            self.toolBar.app            = self.app
-            self.toolBar.frame          = self
-            if self.menuBar:
-                self.toolBar.menuBar        = self.menuBar
-                self.menuBar.toolBar        = self.toolBar
-        else:
-            self.toolBar = None
-            if self.menuBar:
-                self.menuBar.toolBar        = None
-            
-    def __statusBar__(self):
-        """Create statusbar (to be overwritten)."""
-        if self.isMdiChild:
-            self.panel.SetStatusText    = self.parentFrame.SetStatusText
-        else:
-            self.panel.SetStatusText    = self.SetStatusText
-            if self.app.StatusBar:
-                if self.app.DEBUG:
-                    print """Create: Framework: statusbar."""
-                self.statusBar = self.app.StatusBar(parent=self,id=wx.ID_ANY)
-                self.SetStatusBar(self.statusBar)
-            
-    #---other
-    def __finish__(self):
-        self.setTitle(self.page,self.extra)
-        if hasattr(self.panel,'__finish__'):
-            self.panel.__finish__()
-            
-    def __layoutTabs__(self,parent=None):
-        """Not for mdi children"""
-        if not parent: parent = self
-        #sizer layout
-        sizer = wx.BoxSizer(wx.VERTICAL)
-        sizer.Add(self.tabs, 1, wx.EXPAND, 0)
-        parent.SetAutoLayout(True)
-        parent.SetSizer(sizer)
-        parent.Layout()
-        #events
-        self.bindTabs()
-        
-    #---events
-    def __events__(self):
-        """Initialize events."""
-        eventManager.Register(self.onFrameActivate, wx.EVT_ACTIVATE,    self)
-        eventManager.Register(self.onFrameClose,    wx.EVT_CLOSE,       self)
-        eventManager.Register(self.onFrameMove,     wx.EVT_MOVE,        self)
-        eventManager.Register(self.onFrameSize,     wx.EVT_SIZE,        self)
-        if self.menuBar:    self.menuBar.__events__()
-        if self.toolBar:    self.toolBar.__events__()
-        if hasattr(self.panel,'onIdle'):
-            eventManager.Register(self.onFrameIdle, wx.EVT_IDLE, self)
-        
-    def onFrameActivate(self, event):
-        """Activate event (to be overwritten)."""
-        getActive   = event.GetActive()
-        if self.app.DEBUG: 
-            print 'Event<: Framework: %s.Activate(%s)'%(self.__class__,getActive)
-        if getActive:
-            if hasattr(self.panel,'onActivate'):
-                self.panel.onActivate(event)
-            elif hasattr(self.panel,'onDeactivate'):
-                self.panel.onDeactivate(event)
-        event.Skip()
-        if self.app.DEBUG: 
-            print 'Event>: Framework: %s.Activate(%s)'%(self.__class__,getActive)
-        
-    def onFrameClose(self, event=None, destroy = 1):
-        """Close event (to be overwritten/extended)."""
-        if self.app.DEBUG: 
-            print 'Event<: Framework: %s.Close'%self.__class__
-        if hasattr(self.panel,'onClose'):
-            self.dead = self.panel.onClose()
-        else:
-            self.dead = True
-        if self.dead:
-            if destroy:
-                #eventManager.DeregisterWindow(self)
-                self.Destroy()
-                if event: event.Skip()
-            if self.app.DEBUG: 
-                print 'Event>: Framework: %s.Close returns True'%self.__class__
-            return True
-        else:
-            if self.app.DEBUG: 
-                print 'Event>: Framework: %s.Close returns False'%self.__class__
-            return False
-        
-    def onFrameMove(self, event=None):
-        """Move event (to be overwritten)."""
-        if self.app.DEBUG: 
-            print 'Event<: Framework: %s.Move'%self.__class__
-        if event: event.Skip()
-        #sm.spy.frame(1)
-        if hasattr(self.panel,'onMove'):
-            self.panel.onMove(event)
-        if self.app.DEBUG: 
-            print 'Event>: Framework: %s.Move'%self.__class__
-        
-    def onFrameSize(self, event=None):
-        """Size event (to be overwritten)."""
-        #sm.spy.frame(1)
-        if self.app.DEBUG: 
-            print 'Event<: Framework: %s.Size'%self.__class__
-        if hasattr(self.panel,'onSize'):
-            self.panel.onSize(event)
-        if self.app.DEBUG: 
-            print 'Event>: Framework: %s.Size'%self.__class__
-        if event: event.Skip()
-        
-    def onFrameIdle(self, event):
-        """To be overwritten."""
-        if not self.dead:
-            if hasattr(self.panel,'onIdle'):
-                self.panel.onIdle()
-                
-    def bindTabs(self):
-        """Bind events to notebook tabs (to be overwriten)."""
-        pass
-        
-    def unbindTabs(self):
-        """Unbind events to notebook tabs (to be overwriten)."""
-        pass
-        
-    def getIndex(self):
-        """Get index of current child."""
-        try:
-            return self.app.children.index(self.panel)
-        except ValueError:
-            return -1
-            
-
-class Tabs(Framework):
-    #---events            
-    def bindTabs(self):
-        eventManager.Register(self.onFrameTab, self.app.EVENT_NOTEBOOK, self.tabs)
-        
-    def unbindTabs(self):
-        eventManager.DeregisterWindow(self.tabs)
-        
-#---SDI Platform dependent
-class SdiWin32(Tabs):
-    """SDI Implementation for windows (see also App.SetMdi)"""
-    def onFrameTab(self,event):
-        """When a tab is changed (EVT_MOUSE_LEFT&HitTest)."""
-        mousePos    = event.GetPosition()
-        index, other = self.tabs.HitTest(mousePos)
-        if self.app.DEBUG:
-            print 'Event<: Sdi:   %s.onFrameTab(%s)'%(self.__class__,index)
-        if index == 0:
-            window = self.parentFrame
-        else:
-            window = self.app.children[index-1].frame
-        window.Raise()
-        if self.app.DEBUG:
-            print 'Event>: Sdi:   %s.onFrameTab(%s)'%(self.__class__,index)
-        
-class SdiUnix(Tabs):
-    """SDI Implementation for windows (see also App.SetMdi)"""
-    def onFrameTab(self,event):
-        """When a tab is changed (EVT_NOTEBOOK_CHANGING)."""
-        index       = event.GetSelection()
-        event.Veto()#instead of event.Skip() (don't do this here anyway)
-        if self.app.DEBUG:
-            print 'Event<: Sdi:   %s.onFrameTab(%s)'%(self.__class__,index)
-        if index == 0:
-            window = self.parentFrame
-        else:
-            window = self.app.children[index-1].frame
-        window.Raise()
-        if self.app.DEBUG:
-            print 'Event>: Sdi:   %s.onFrameTab(%s)'%(self.__class__,index)
-        
-if PLATFORM == 'win32':
-    SdiPlatform     = SdiWin32
-else:
-    SdiPlatform     = SdiUnix
-        
-####Parent classes
-class Parent(Framework):
-    #---initialize
-    def __init__(self, app, page = '', **options):
-        self.options            = options
-        self.isMdiChild         = False
-        Framework.__init__(self,
-            app             = app,
-            Panel           = app.ParentPanel,
-            page            = page,
-            parentFrame     = self,
-            **options)
-        
-    def __finish__(self):
-        Framework.__finish__(self)
-        
-    #---events
-    def onFrameClose(self,event=None):
-        self.dead = Framework.onFrameClose(self,event,destroy=0)
-        if not self.dead: return
-        #Avoid event exceptions of child frames
-        for child in self.app.children:
-            eventManager.DeregisterWindow(child.frame)
-            child.dead = 1
-        #Destroy itself
-        self.Destroy()
-        if event: event.Skip()
-
-    #---menu
-    def menu_new(self, event=None):
-        self.child()
-        
-    def menu_close(self,event=None):
-        childActive = self.app.childActive
-        if childActive:
-            childActive.onFrameClose()
-        
-    #---parentPanel
-    def child(self,*args,**keyw):
-        self.ChildFrame(self,*args,**keyw)
-        
-    def maximize(self):
-        i = 0
-        m = 0
-        for child in self.app.children:
-            if child.frame.IsMaximized():
-                return True
-        return False
-    
-    #---other
-    def setTitle(self,page='',extra='',draw=True):
-        if draw:
-            t           = self.app.title
-            if page:
-                t       = '%s - %s'%(page,t)
-            self.SetTitle(t)
-        
-
-class MdiParentFrame(Parent,wx.MDIParentFrame):
-    """Uniformed parent Mdi/Sdi class based on Mdi.
-    
-    self.Panel is defined by joined class"""
-    def __init__(self,app,
-            id      = wx.ID_ANY, 
-            page   = 'parentFrame',
-            parent  = None,
-            size    = SIZE,
-            style   = STYLE_PARENTFRAME,
-            pos     = POS,
-            **options):
-        wx.MDIParentFrame.__init__(self, 
-            id      = id, 
-            name    = page,
-            parent  = parent,
-            size    = size,
-            style   = style | FULL_REPAINT_ON_RESIZE,
-            title   = page,
-            pos     = pos)
-        if style & wx.MAXIMIZE:
-            try: #not working on mandrake9
-                self.Maximize(1)
-            except:
-                pass
-        #This always has to be last!
-        Parent.__init__(self,app=app,page=page,**options)
-        
-    def __stage__(self,page,extra,**options):
-        self.sash           = wx.MDIChildFrame(parent=self,id=wx.ID_ANY)
-        #parentPanel
-        self.panel          = self.Panel(parent=self.sash,**options)
-        eventManager.Register(self.onSashClose, wx.EVT_CLOSE, self.sash)
-        
-    def onSashClose(self,event):
-        pass
-        
-class MdiSashParentFrame(MdiParentFrame):
-    """Uniformed parent Mdi/Sdi class based on Mdi.
-    
-    self.Panel is defined by joined class"""        
-    def __stage__(self,page,extra,**options):
-        """Create tabs to switch between documents as an wx.SashLayoutWindow"""
-        if self.app.DEBUG:
-            print 'Create: Mdi:   %s.tabs'%(self.__class__,)
-        #sash for parentPanel
-        self.sashId = wx.NewId()
-        self.sash = wx.SashLayoutWindow(id=self.sashId,
-              name='sash', parent=self, style=wx.NO_BORDER)
-        self.sash.SetDefaultSize(wx.Size(792, 200))
-        self.sash.SetOrientation(wx.LAYOUT_HORIZONTAL)
-        self.sash.SetAlignment(wx.LAYOUT_BOTTOM)
-        self.sash.SetSashVisible(wx.SASH_TOP, 1)
-        self.sash.SetMinimumSizeY(1)
-        self.sash.Show(True)
-        eventManager.Register(self.onFrameSashDragged, wx.EVT_SASH_DRAGGED, self.sash)
-        #parentPanel
-        self.panel          = self.Panel(parent=self.sash,**options)
-        #layout
-        self.panelSizer     = wx.BoxSizer(wx.VERTICAL)
-        self.panelSizer.Add(self.panel, 1, wx.ALL | wx.EXPAND, 0)
-        self.sash.SetAutoLayout(1)
-        self.sash.SetSizer(self.panelSizer)
-    
-    def __finish__(self):
-        Parent.__finish__(self)
-        wx.LayoutAlgorithm().LayoutMDIFrame(self)
-
-    #---events
-    def onFrameSashDragged(self,event):
-        """Called when the shashwindow is dragged."""
-        if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
-            return
-        eID = event.GetId()
-        if eID == self.sashId:
-            self.sash.SetDefaultSize(wx.Size(1000,event.GetDragRect().height))
-        wx.LayoutAlgorithm().LayoutMDIFrame(self)
-
-    def onFrameSize(self, event):
-        """Overwritten for sash dragging."""
-        Framework.onFrameSize(self)
-        wx.LayoutAlgorithm().LayoutMDIFrame(self)
-
-class MdiSashTabsParentFrame(Tabs,MdiSashParentFrame):
-    def __stage__(self,page,**options):
-        """Create tabs to switch between documents as an wx.SashLayoutWindow"""
-        if self.app.DEBUG:
-            print 'Create: Mdi: %s.tabs'%(self.__class__,)
-        self.tabsSash = wx.SashLayoutWindow(id=wx.ID_ANY,
-              name='tabs', parent=self, style=wx.CLIP_CHILDREN)
-        self.tabsSash.SetOrientation(wx.LAYOUT_HORIZONTAL)
-        self.tabsSash.SetAlignment(wx.LAYOUT_TOP)
-        self.tabsSash.SetDefaultSize(wx.Size(792, TABSASH_HEIGHT))
-        self.tabs = wx.Notebook(id=wx.ID_ANY, parent=self.tabsSash, style=STYLE_NOTEBOOK)
-        self.__layoutTabs__(self.tabsSash)
-        MdiSashParentFrame.__stage__(self,page,**options)
-
-    def onFrameTab(self,event):
-        """When a tab is changed."""
-        index = event.GetSelection()
-        if self.app.DEBUG:
-            print 'Event<: Mdi: %s.onFrameTab(%s)'%(self.__class__,index)
-        event.Skip()
-        self.app.children[index].frame.Raise()
-        if self.app.DEBUG:
-            print 'Event>: Mdi: %s.onFrameTab(%s)'%(self.__class__,index)
-            
-class SdiParentFrame(SdiPlatform,Parent,wx.Frame):
-    """Uniformed parent Mdi/Sdi class based on Sdi."""
-    def __init__(self,app,
-            id      = wx.ID_ANY, 
-            page    = 'parentFrame',
-            parent  = None,
-            size    = SIZE,
-            style   = STYLE_PARENTFRAME,
-            pos     = POS,
-            **options):
-        wx.Frame.__init__(self, 
-            id      = id, 
-            name    = page,
-            parent  = parent, 
-            size    = size,
-            style   = style | FULL_REPAINT_ON_RESIZE,
-            title   = page,
-            pos     = pos)
-        if style & wx.MAXIMIZE:
-            try: #not working on mandrake9
-                self.Maximize(1)
-            except:
-                pass
-        self.isSdiParent    = True
-        #This always has to be last!
-        Parent.__init__(self,app=app,page=page,**options)
-
-    def __stage__(self,page,extra,**options):
-        """Create tabs to switch between documents as an wx.Notebook"""
-        if self.app.DEBUG:
-            print 'Create: Sdi:   %s.tabs'%(self.__class__,)
-        self.tabs   = wx.Notebook(parent=self, id=wx.ID_ANY,
-            style = STYLE_NOTEBOOK )
-        self.panel  = self.Panel(parent=self.tabs,**options)
-        self.tabs.AddPage(self.panel, page)
-        self.__layoutTabs__()
-        
-    def setTitle(self,page='',extra='',draw=True):
-        if draw:
-            self.SetTitle(self.app.title)
-        
-####Child classes
-class Child(Framework):
-    #---initialize
-    def __init__(self,parentFrame,page='',extra='',parent=None,**options):
-        app             = parentFrame.app
-        self.pageTitle  = ''
-        self._pageTitle  = '?'
-        self.extraTitle = ''
-        self._extraTitle = ''
-        Framework.__init__(self,
-            app         = app,
-            Panel       = app.ChildPanel,
-            parentFrame = parentFrame,
-            page        = page,
-            extra       = extra,
-            **options)
-    
-    def __finish__(self):
-        app             = self.app
-        panel           = self.panel
-        app.childActive = panel
-        app.children.append(panel)
-        self.addPageToParent(panel,app.mdi)
-        #finish
-        Framework.__finish__(self)
-        
-    def addPageToParent(self,panel,mdi):
-        """"Add page with childs title to parent
-        Can be overwritten."""
-        parentFrame     = self.parentFrame
-        tabs            = parentFrame.tabs
-        tabs.AddPage(page=DummyPage(tabs), text=self.page,select=mdi)
-
-    #---events
-    def onFrameActivate(self, event):
-        """Activate event."""
-        if event.GetActive():
-            if self.app.DEBUG: 
-                'Event:  Child: %s.Activate'%self.__class__
-            self.app.childActive    = self.panel
-        Framework.onFrameActivate(self,event)
-        
-    def onFrameClose(self, event = None):
-        """Close event."""
-        if self.app.DEBUG: 
-            print 'Event<: Child: %s.Close'%self.__class__
-        self.dead = Framework.onFrameClose(self,destroy=0)
-        if not self.dead:
-            if self.app.DEBUG: 
-                print 'Event>: Child: %s.Close returns False'%self.__class__
-            return False
-        #deregister events
-        eventManager.DeregisterWindow(self)
-        if event: event.Skip()
-        #index
-        mdi     = self.app.mdi
-        index   = self.getIndex()
-        if mdi: delta = 0
-        else:   delta = 1
-        #Update children
-        children    = self.app.children
-        children.remove(self.panel)
-        if children:
-            self.app.childActive = children[0]
-        else:
-            self.app.childActive = None
-        #update rest
-        parentFrame = self.parentFrame
-        if hasattr(parentFrame,'tabs'):
-            #Update childBook tabs 
-            current = index+delta
-            # * parent frame (mdi & sdi)
-            parentFrame.unbindTabs()
-            parentFrame.tabs.DeletePage(current)
-            if not mdi:
-                parentFrame.tabs.SetSelection(0)
-            parentFrame.bindTabs()
-            # * children frames (sdi)
-            if not mdi: #not for mdichild
-                eventManager.DeregisterWindow(self.tabs)
-                c       = 1
-                for child in children:
-                    child.frame.unbindTabs()
-                    tabs   = child.frame.tabs
-                    tabs.DeletePage(current)#remove closed item from other children
-                    if c>=current:
-                        tabs.SetSelection(c)#adapt selection
-                    child.frame.bindTabs()
-                    c += 1
-        self.Destroy()
-        if self.app.DEBUG: 
-            print 'Event>: Child: %s.Close returns True'%self.__class__
-        return True    
-    
-    def getIndexSmdi(self):
-        if self.app.mdi:return self.getIndex()
-        else:           return self.getIndex() + 1
-        
-    def setTitle(self,page='',extra='',new=True,draw=True):
-        if new:
-            #parameters
-            if page:    self.pageTitle  = page
-            if extra:   self.extraTitle = extra
-            #go
-            m               = ['','*'][self.panel.changed]
-            if self.pageTitle:
-                self._pageTitle   =  '%s%s'%(self.pageTitle,m)
-            else:
-                self._pageTitle   =  ''
-        if draw:
-            if self.app.mdiName == SDI or WIN:
-                self.SetTitle(self.extraTitle)
-            else:
-                self.SetTitle(self.pageTitle)
-        
-class MdiTabsChildFrame(Child,wx.MDIChildFrame):
-    def __init__(self,parentFrame,
-        id          = wx.ID_ANY,
-        page        = UNNAMED,
-        extra       = '',
-        style       = STYLE_CHILDFRAME,
-        maximize    = None,
-        **options):
-        self.isMdiChild = True
-        app             = parentFrame.app
-        #debug message
-        if app.DEBUG:
-            print 'Create: Mdi: %s'%self.__class__
-        if maximize == None:
-            maximize = parentFrame.maximize()
-        if maximize:
-            style   |= wx.MAXIMIZE
-        wx.MDIChildFrame.__init__(self,
-            id      = id, 
-            name    = page,
-            parent  = parentFrame,
-            style   = style | FULL_REPAINT_ON_RESIZE, 
-            title   = page)
-        self.Maximize()#if maximize and PLATFORM != 'win32':#sm:seems better to leave this away.
-        self.Raise  = self.Activate #raise doesn't work here
-        #This always has to be last!
-        Child.__init__(self,
-            parentFrame = parentFrame,
-            page        = page,
-            extra       = extra,
-            **options)
-        
-    def __finish__(self):
-        self.tabs       = self.parentFrame.tabs
-        Child.__finish__(self)
-                
-    def setTitle(self,page='',extra='',new=True,draw=True):
-        Child.setTitle(self,page,extra,new,draw)
-        self.parentFrame.setTitle(self._pageTitle,draw=draw)
-        if new and draw:
-            self.tabs.SetPageText(self.getIndex(),self._pageTitle)
-        
-    def onFrameActivate(self, event):
-        if event.GetActive():
-            self.setTitle(new=False)
-        Child.onFrameActivate(self,event)
-        
-class MdiBaseChildFrame(MdiTabsChildFrame, Child):
-    """Mdi Child frame without tabs."""
-    def addPageToParent(self,panel,mdi):
-        pass
-
-    def setTitle(self,page='',extra='',new=True,draw=True):
-        Child.setTitle(self,page,extra,new,draw)
-        self.parentFrame.setTitle(self._pageTitle,draw=draw)
-        
-    def __finish__(self):
-        Child.__finish__(self)
-        
-class SdiChildFrame(SdiPlatform,Child,wx.Frame):
-    def __init__(self,parentFrame,
-        id          = wx.ID_ANY,
-        style       = STYLE_CHILDFRAME,
-        page        = '',
-        extra       = '',
-        maximize    = None,
-        **options):
-        self.isMdiChild = False
-        app             = parentFrame.app
-        #debug message
-        if app.DEBUG:
-            print 'Create: Sdi: %s'%self.__class__,page,extra
-        #maximize&init
-        if maximize == None:
-            maximize = parentFrame.maximize()
-        if maximize:
-            style   |= wx.MAXIMIZE
-        wx.Frame.__init__(self,
-            id      = id, 
-            name    = page,
-            parent  = parentFrame, 
-            size    = wx.Size(600,400),
-            style   = style | FULL_REPAINT_ON_RESIZE, 
-            title   = page)
-        if maximize:
-            if PLATFORM != 'win32':
-                self.Maximize()
-            else:
-                self.SetSize(app.size)
-        #This always has to be last!
-        Child.__init__(self,
-            parentFrame = parentFrame,
-            page        = page,
-            extra       = extra,
-            **options)
-        
-    def __stage__(self,page,extra,**options):
-        """Create tabs to switch between documents as an wx.SashLayoutWindow"""
-        if self.app.DEBUG:
-            print 'Create: Sdi:   %s.tabs'%(self.__class__,)
-        tabs = self.tabs   = wx.Notebook(parent=self, id=wx.ID_ANY,
-            style = STYLE_NOTEBOOK )
-        panel = self.panel = self.Panel(parent=tabs,**options)
-        #Add parent tab to itself
-        tabs.AddPage(page=DummyPage(tabs),text=self.app.title)
-        #Add child tabs to itself and vice versa
-        for child in self.app.children:
-            childTabs   = child.frame.tabs
-            tabs.AddPage(page=DummyPage(tabs),text=child.frame._pageTitle)
-            childTabs.AddPage(page=DummyPage(childTabs),text=page)
-        #Add itself to itself
-        tabs.AddPage(page=panel,text=page,select=True)
-        self.__layoutTabs__()        
-        
-    def setTitle(self,page='',extra='',new=True,draw=True):
-        Child.setTitle(self,page,extra,new)
-        if new and draw:
-            self.tabs.SetPageText(self.getIndex()+1,self._pageTitle)
-        
-####Application
-
-class App(wx.App):
-    def __init__(self, ParentPanel, ChildPanel, MenuBar, ToolBar, StatusBar,
-            mdi=DEFAULT, debug=0, title='name',size=wx.Size(800,400),
-            imagePath = None, pos=wx.Point(wx.ID_ANY,wx.ID_ANY),
-            style=STYLE_PARENTFRAME,**attributes):
-        #passing arguments
-        self.ParentPanel    = ParentPanel
-        self.ChildPanel     = ChildPanel
-        self.MenuBar        = MenuBar
-        self.ToolBar        = ToolBar
-        self.StatusBar      = StatusBar
-        self.SetMdi(mdi)
-        self.DEBUG          = debug
-        self.title          = title
-        self.size           = size
-        self.imagePath      = imagePath
-        self.pos            = pos
-        self.style          = style
-        #initialization
-        self.children       = []
-        self.childActive    = None
-        if self.imagePath:
-            self.bitmap     = wx.Bitmap = Bitmap(imagePath,self)
-        else:
-            self.bitmap     = wx.Bitmap
-        #options
-        self.attributes     = attributes
-        for key in attributes:
-            if hasattr(self,key):
-                print "Warning: Application can't accept attribute '%s'."%key
-            else:
-                setattr(self,key,attributes[key])
-        #start
-        print "Launching application..."
-        wx.App.__init__(self,redirect=not debug)
-        
-    def OnInit(self):
-        wx.InitAllImageHandlers()
-        self.parentFrame = self.ParentFrame(self,
-            size    = self.size,
-            page    = self.title,
-            pos     = self.pos,
-            style   = self.style,
-            **self.attributes)
-        self.parentFrame.Show(True)
-        self.SetTopWindow(self.parentFrame)
-        return True
-        
-    def SetMdi(self,mdiName=DEFAULT):
-        """Defines parent and children frame classes."""
-        self.mdiName     = mdiName
-        if mdiName == DEFAULT:
-            if   WIN:
-                mdiName = MDI_SASH_TABS_WIN
-            elif DARWIN:#mac osx
-                mdiName = SDI_MAC
-            else:
-                mdiName = MDI_SASH_TABS_LINUX
-
-        self.mdi    = DI[mdiName]
-        if      self.mdi == SDI:
-            self.ParentFrame        = SdiParentFrame
-            self.ChildFrame         = SdiChildFrame
-            if WIN:
-                #Under Windows, GetSelection() will return the same value as
-                #GetOldSelection() when called from EVT_NOTEBOOK_PAGE_CHANGING handler and
-                #not the page which is going to be selected
-                #Therefore on Windows a combination of mouse click and hittest must be used.
-                self.EVENT_NOTEBOOK = wx.EVT_LEFT_DOWN
-            else:
-                self.EVENT_NOTEBOOK = wx.EVT_NOTEBOOK_PAGE_CHANGING
-        elif    self.mdi == MDI_SASH:
-            self.ParentFrame        = MdiSashParentFrame
-            self.ChildFrame         = MdiBaseChildFrame
-        elif    self.mdi == MDI_SASH_TABS:
-            self.ParentFrame        = MdiSashTabsParentFrame
-            self.ChildFrame         = MdiTabsChildFrame
-            self.EVENT_NOTEBOOK     = wx.EVT_NOTEBOOK_PAGE_CHANGED
-        elif    self.mdi == MDI:
-            self.ParentFrame        = MdiParentFrame
-            self.ChildFrame         = MdiBaseChildFrame
-
-
-####Test app
-class TestMenuBar(wx.MenuBar):
-    def __init__(self,app,frame,*args,**kwds):
-        wx.MenuBar.__init__(self,*args,**kwds)
-        self.file   = wx.Menu()
-        self.file.Append(wx.ID_NEW, _("&New\tCtrl+N"), "", wx.ITEM_NORMAL)
-        self.file.Append(wx.ID_CLOSE, _("&Close\tCtrl+W"), "", wx.ITEM_NORMAL)
-        self.file.Append(wx.ID_EXIT, _("&Exit\tAlt+F4"), "", wx.ITEM_NORMAL)
-        self.Append(self.file, "&File")
-    def __events__(self):
-        wx.EVT_MENU(self.frame,wx.ID_NEW,self.menu_new)
-        wx.EVT_MENU(self.frame,wx.ID_CLOSE,self.menu_close)
-        wx.EVT_MENU(self.frame,wx.ID_EXIT,self.menu_exit)
-    def menu_new(self,event=None):
-        self.parentPanel.new()
-    def menu_close(self,event=None):
-        self.parentPanel.close()
-    def menu_exit(self,event=None):
-        self.parentFrame.onFrameClose()
-        
-ArtIDs = [ wx.ART_FILE_OPEN,
-           wx.ART_PRINT,
-           wx.ART_ADD_BOOKMARK,
-           wx.ART_REPORT_VIEW,
-           wx.ART_LIST_VIEW,
-           wx.ART_HELP,
-           ]
-
-class TestToolBar(wx.ToolBar):
-    def __init__(self,parent=None,id=wx.ID_ANY,menu=None,app=None,**kwds):
-        self.app = app
-        wx.ToolBar.__init__(self,parent=parent,id=id,**kwds)
-        parent.SetToolBar(self)
-        self.tools = []
-        for id in ArtIDs:
-            toolId = wx.NewId()
-            bmp = wx.ArtProvider_GetBitmap(id, wx.ART_TOOLBAR, (16,16))
-            self.AddLabelTool(toolId, "", bmp, wx.NullBitmap, wx.ITEM_NORMAL, "info", "")
-            self.tools.append(toolId)
-        self.Realize()
-        
-    def __events__(self):
-        for id in self.tools:
-            wx.EVT_TOOL(self,id, self.test)
-    def test(self,event):
-        print 'test seems ok'
-        
-class TestParentPanel(wx.TextCtrl):
-    def __init__(self,parent,**kwds):
-        wx.TextCtrl.__init__(self,parent=parent,id=wx.ID_ANY,value='parent',**kwds)
-        self.test_child = 0
-    def new(self):
-        self.app.ChildFrame(self.frame,page='child%02d'%self.test_child)
-        self.test_child += 1
-    def close(self):
-        active = self.app.childActive
-        if active: active.frame.onFrameClose()
-        
-class TestChildPanel(wx.TextCtrl):
-    def __init__(self,parent,**kwds):
-        wx.TextCtrl.__init__(self,parent=parent,id=wx.ID_ANY,value='child',**kwds)
-                
-def __test__(debug,mdi=MDI):
-    app = App(TestParentPanel,
-              TestChildPanel,
-              TestMenuBar,
-              TestToolBar,
-              wx.StatusBar,
-              mdi=mdi,
-              title='Parent',
-              debug=debug)
-    app.MainLoop()
-    
-if __name__=='__main__': __test__(debug=1,mdi=MDI_WIN)
-    

File sm/wxp/smdi_OLD.py

-####(c)www.stani.be-------------------------------------------------------------
-
-try:
-    import sm
-    INFO=sm.INFO.copy()
-    
-    INFO['title']     = INFO['titleFull'] = 'Sdi/Mdi Framework'
-    
-    INFO['description']=\
-    """Framework which makes it easy to switch between Sdi (Linux/Mac) 
-    and Mdi (Windows).
-    """
-
-    __doc__=INFO['doc']%INFO
-except:
-    __doc__=="Stani's Multiple Document Interface (c)www.stani.be"
-
-"""
-Attributes of Application:
-    - properties:
-        - children
-        - config
-        - DEBUG
-        - imagePath
-        - mdi
-        - title
-        - parentFrame
-        - pos
-        - size
-        - style
-    - methods:
-        - SetMdi
-    - classes:
-        - ChildFrame
-        - ChildPanel
-        - MenuBar
-        - ParentFrame
-        - ParentPanel
-        - StatusBar
-        - ToolBar
-        
-Attributes of Frame:
-    - properties:
-        - app
-        - dead
-        - menuBar
-        - parentFrame
-        - toolBar
-    - methods:
-        - getIndex
-        - (maximize)
-        - setTitle
-        - SetStatusText
-    - events:
-        - bindTabs
-        - unbindTabs
-        - onFrameActivate
-        - onFrameClose
-        - onFrameMove
-        - onFrameSize
-        - (onFrameTab)
-    - classes:
-        - Panel
-        
-Attributes of Panel:
-    - properties:
-        - changed
-        - frame
-        - title
-        - parentFrame
-        - parentPanel
-    - methods:
-    
-Attributes of MenuBar:
-    - properties:
-        - app
-        - frame
-        - parentFrame
-        - parentPanel
-        - toolBar
-
-Attributes of ToolBar:
-    - properties:
-        - app
-        - frame
-        - menuBar
-    
-Todo:
-- icon support
-"""
-
-####Modules
-import  os, sys, pprint
-import  wx
-from    wx.lib.evtmgr import eventManager
-#import sm.spy
-
-####Constants
-SDI         = "single (mac, linux, windows)"
-MDI         = "multiple (linux,windows)"
-MDI_TABS    = "multiple with tabs (windows)"
-DEFAULT     = "<default>"
-DI          = {SDI      : 0,
-               MDI      : 1,
-               MDI_TABS : 2,
-               DEFAULT  : -1}
-
-PLATFORM                    = sys.platform
-WIN                         = PLATFORM.startswith('win')
-DARWIN                      = PLATFORM.startswith('darwin')
-
-#wx related
-FULL_REPAINT_ON_RESIZE      = wx.FULL_REPAINT_ON_RESIZE
-POS                         = (10,10)
-SIZE                        = (600,400)
-STYLE_CHILDFRAME            = wx.DEFAULT_FRAME_STYLE
-STYLE_NOTEBOOK              = FULL_REPAINT_ON_RESIZE|wx.CLIP_CHILDREN|wx.NO_BORDER
-STYLE_PARENTFRAME           = wx.DEFAULT_FRAME_STYLE #| wx.MAXIMIZE 
-STYLE_TOOLBAR               = wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT
-TABSASH_HEIGHT              = 28
-TITLE                       = 'www.stani.be'
-UNNAMED                     = 'unnamed'
-
-####Menu helper function
-def _(x):
-    if DARWIN:
-        return x.replace('Ctrl','Cmd')
-    else:
-        return x
-
-def _strip(x):
-    return x.replace(' ','_').replace('-','_').replace('&& ','').replace('&','').replace('.','').replace('(','').replace(')','')
-    
-def menuWrite(menuBar,f='menu.txt'):
-    labels = []
-    for m in range(menuBar.GetMenuCount()):
-        menu        = menuBar.GetMenu(m)
-        menuLabel   = menuBar.GetLabelTop(m)
-        for item in menu.GetMenuItems():
-            label   = _strip(item.GetLabel())
-            if label:
-                labels.append((menuLabel,item.GetLabel()))
-    #events
-    result = '\tdef __smdi__(self):\n'
-    for label in labels:
-        label = _strip(label[1])
-        result+= '\t\twx.EVT_MENU(self,%s,self.menu_%s)\n'%(label.upper(),label.lower())
-    result+= '\n'
-    for label in labels:
-        result+='\tdef menu_%s(self):\n\t\t"""%s"""\n\t\tpass\n\n'%(_strip(label[1].lower()),'%s > %s'%label)
-    print result
-    print os.getcwd()
-    print f
-    f   = open(f,'w')
-    f.write(result)
-    f.close()
-            
-def test_menuWrite():
-    import menu
-    menuWrite(wxgMenu.Bar())
-    
-####Base
-WX_BITMAP       = wx.Bitmap
-
-class Bitmap:
-    def __init__(self,path,app):
-        self.path = path
-        self.app = app
-    def __call__(self,x,t=wx.BITMAP_TYPE_ANY):
-        path = os.path.join(self.path,os.path.basename(x))
-        #if self.app.DEBUG:
-        #    print 'Bitmap: %s<%s'%(x,path)
-        return WX_BITMAP(path,t)
-        
-class DummyPage(wx.StaticText):
-    """Page to fill the tabs (not meant to be visible)."""
-    def __init__(self,tabs):
-        wx.StaticText.__init__(self, tabs, wx.ID_ANY, "SPE bug: This shouldn't be visible")
-            
-####Foundation Classes
-class Framework:
-    """Foundation class for every frame."""
-    def __init__(self,app,Panel,parentFrame,page='',extra='',**options):
-        #stage
-        self.__before__(app         = app,
-                        Panel       = Panel,
-                        parentFrame = parentFrame,
-