If you are looking at implementing plugins, you might take a look at the way Editra handles it's plugins. It's pure wx but can be easily converted.
On Mon, May 12, 2008 at 7:47 AM, Ed Leafe <[EMAIL PROTECTED]> wrote: > dabo Commit > Revision 4081 > Date: 2008-05-12 06:47:58 -0700 (Mon, 12 May 2008) > Author: Ed > Trac: http://svn.dabodev.com/trac/dabo/changeset/4081 > > Changed: > U branches/ed-ide/Studio.py > U branches/ed-ide/components/ClassDesigner/__init__.py > U branches/ed-ide/components/TextEditor/__init__.py > > Log: > incremental commit. Nothing earth-shattering yet, but began fleshing out > support for components and plugins. > > Diff: > Modified: branches/ed-ide/Studio.py > =================================================================== > --- branches/ed-ide/Studio.py 2008-05-12 13:42:49 UTC (rev 4080) > +++ branches/ed-ide/Studio.py 2008-05-12 13:47:58 UTC (rev 4081) > @@ -8,6 +8,7 @@ > dabo.ui.loadUI("wx") > from dabo.dLocalize import _ > import dabo.dEvents as dEvents > +import components > from components.ClassDesigner import ClassDesigner > from components.CxnEditor import CxnEditor > from components.MenuDesigner import MenuDesigner > @@ -38,7 +39,6 @@ > > def onEditFile(self, evt): > if not self._context: > - print "WASSIP with dat?" > return > nd = self._context["node"] > pth = self._context["filepath"] > @@ -46,31 +46,92 @@ > self.controller.editFile(pth) > > > +class StudioToolBar(dabo.ui.dToolBar): > + """Overrides the _appendInsertButton() method, so that we get actual > Dabo > + dBitmapButton or dToggleButton controls instead of the default > wx.ToolBarItem > + buttons that are difficult to work with. > + """ > + def _appendInsertButton(self, pos, caption, pic, bindfunc, toggle, > tip, help, *args, **kwargs): > + buttonClass = {True: dabo.ui.dToggleButton, False: > dabo.ui.dBitmapButton}[toggle] > + if not toggle: > + kwargs["AutoSize"] = True > + ctl = buttonClass(self, Caption=caption, Picture=pic, > ToolTipText=tip, *args, **kwargs) > + # Don't show the caption if there is an image > + def _dyncap(obj): > + if obj.Picture: > + return "" > + else: > + return obj._caption > + ctl.DynamicCaption = (_dyncap, ctl) > + return self.insertControl(pos, ctl, bindfunc=bindfunc) > > -class StudioForm(dabo.ui.dSplitForm): > + > +class StudioForm(dabo.ui.dDockForm): > def initProperties(self): > self.Caption = _("Dabo Developer Studio") > self.Orientation = "h" > > > def afterInit(self): > - dabo.ui.setAfter(self.Splitter, "SashPercent", 30) > - pnl1 = self.Panel1 > - pnl1.Sizer.Orientation = "v" > - btn = dabo.ui.dButton(pnl1, Caption="Open Project", > OnHit=self.onOpenProject) > - pnl1.Sizer.append(btn, halign="center", border=30) > - self.tree = ProjectTree(pnl1) > + treePnl = self.projectTreePanel = > self.addPanel(Caption=_("Projects"), Docked=True, > + DockSide="Left", ShowPinButton=True) > + sz = self.projectTreePanel.Sizer = dabo.ui.dSizer("v") > + btn = dabo.ui.dButton(treePnl, Caption="Open Project", > OnHit=self.onOpenProject) > + sz.append(btn, halign="center", border=30) > + self.tree = ProjectTree(treePnl) > self.tree.controller = self > - pnl1.Sizer.append1x(self.tree) > - pnl2 = self.Panel2 > - self.pgfEditors = dabo.ui.dPageFrame(pnl2, PageCount=0) > - pnl2.Sizer.append1x(self.pgfEditors) > + sz.append1x(self.tree) > + > + self.toolbar = self.addPanel(Toolbar=True, Docked=True, > DockSide="Top", > + ShowCaption=False, ShowGripper=True, > BottomDockable=False, > + LeftDockable=False, RightDockable=False) > + self.toolbar.Sizer = dabo.ui.dSizer("h") > + cp = self.CenterPanel > + csz = cp.Sizer = dabo.ui.dSizer("v") > +# self.toolbar = self.ToolBar = StudioToolBar(self) > +# csz.append(self.toolbar) > + self._toolSets = {None: []} > + self._currentToolBar = None > + self.pgfEditors = dabo.ui.dPageFrame(self.CenterPanel, > PageCount=0) > + csz.append1x(self.pgfEditors) > + > + # Enable the various parts of the IDE. > + self.registerComponents() > + self.registerPlugins() > > + # Make sure that all components are visible > + dabo.ui.callAfter(self._showAllPanels) > > + > + def _showAllPanels(self): > + self.toolbar.Visible = self.projectTreePanel.Visible = True > + self.toolbar.Show() > + self._refreshState() > + > + def registerComponents(self): > + import types > + comps = [getattr(components, comp) for comp in > dir(components) > + if isinstance(getattr(components, comp), > types.ModuleType)] > + for comp in comps: > + try: > + comp.register(self) > + except AttributeError: > + dabo.errorLog.write(_("Component '%s' lacks > a 'register()' method.") % comp) > + > + > + def registerPlugins(self): > + pass > + > + > + def setToolBarGroup(self, key, grp): > + self._toolSets[key] = grp > + > + > def editFile(self, pth): > pg = self.pgfEditors.appendPage(TextEditorPage) > pg.openFile(pth) > self.pgfEditors.SelectedPage = pg > + self.CurrentToolBar = "TextEditor" > > > def onOpenProject(self, evt): > @@ -84,8 +145,41 @@ > self.tree.getRootNode().Expanded = True > > > + def _getCurrentToolBar(self): > + return self._currentToolBar > + > + def _setCurrentToolBar(self, val): > + if self._constructed(): > + if val == self._currentToolBar: > + return > + if val not in self._toolSets: > + dabo.errorLog.write(_("Invalid toolbar > specified: '%s'") % val) > + > + print self._toolSets.keys() > + return > + # Hide all visible buttons > + for btn in self.toolbar.Children[::-1]: > + self.toolbar.remove(btn, False) > + self._currentToolBar = val > + # Show the new button set > + for btn in self._toolSets[self._currentToolBar]: > + try: > + self.toolbar.appendItem(btn) > + except AttributeError: > + # A control, not a tool item > + btn.Visible = True > + else: > + self._properties["CurrentToolBar"] = val > + > + > + CurrentToolBar = property(_getCurrentToolBar, _setCurrentToolBar, > None, > + _("Name of the current toolbar to display. Changing > this will change the buttons that are visible in the editing area. (str)")) > + > + > + > def main(): > app = dabo.dApp() > + app.BasePrefKey = "DeveloperStudio" > app.MainFormClass = StudioForm > app.start() > > > Modified: branches/ed-ide/components/ClassDesigner/__init__.py > =================================================================== > --- branches/ed-ide/components/ClassDesigner/__init__.py 2008-05-12 > 13:42:49 UTC (rev 4080) > +++ branches/ed-ide/components/ClassDesigner/__init__.py 2008-05-12 > 13:47:58 UTC (rev 4081) > @@ -1,36 +1,13 @@ > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > -# from ClassDesignerPropSheet import PropSheet > -# from ClassDesignerPropSheet import PropertyGrid > -# from ClassDesignerComponents import LayoutSaverMixin > -# from ClassDesignerComponents import LayoutPanel > -# from ClassDesignerComponents import LayoutSpacerPanel > -# from ClassDesignerComponents import LayoutSizerMixin > -# from ClassDesignerComponents import LayoutSizer > -# from ClassDesignerComponents import LayoutBorderSizer > -# from ClassDesignerComponents import LayoutGridSizer > -# from ClassDesignerComponents import LayoutBasePanel > -# from ClassDesignerComponents import NoSizerBasePanel > -# from ClassDesignerTreeSheet import TreeSheet > -# from ClassDesignerObjectPropertySheet import ObjectPropertySheet > -# from ClassDesignerCustomPropertyDialog import > ClassDesignerCustomPropertyDialog > -# from ClassDesignerControlMixin import ClassDesignerControlMixin > -# from ClassDesignerFormMixin import ClassDesignerFormMixin > -# from ClassDesignerEditor import EditorControl > -# from ClassDesignerEditor import EditorForm > -# from ClassDesignerPemForm import PemForm > -# from ClassDesignerMethodSheet import MethodSheet > -# from ClassDesignerSizerPalette import ContentBoxSizerPanel > -# from ClassDesignerSizerPalette import ContentGridSizerPanel > -# from ClassDesignerSizerPalette import BoxSizerSelfPanel > -# from ClassDesignerSizerPalette import GridSizerSelfPanel > -# from ClassDesignerSizerPalette import SizerInfoFrame > -# from ClassDesignerSizerPalette import SizerContentFrame > -# from ClassDesignerSizerPalette import SizerSelfFrame > -# from ClassDesignerSizerPalette import AbstractSizerPanel > -# from ClassDesignerSizerPalette import SizerContentPanel > -# from ClassDesignerSizerPalette import SizerSelfPanel > -# from ClassDesignerSizerPalette import SizerPaletteForm > from ClassDesigner import ClassDesigner > from ClassDesignerExceptions import PropertyUpdateException > + > + > +def register(master): > + print "Class Designer is registered" > +# toolbar > +# editor class > +# extensions > + > > Modified: branches/ed-ide/components/TextEditor/__init__.py > =================================================================== > --- branches/ed-ide/components/TextEditor/__init__.py 2008-05-12 13:42:49 > UTC (rev 4080) > +++ branches/ed-ide/components/TextEditor/__init__.py 2008-05-12 13:47:58 > UTC (rev 4081) > @@ -1,4 +1,48 @@ > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > +import dabo > +import dabo.dEvents as dEvents > +from dabo.dLocalize import _ > +import TextEditor > from TextEditor import EditorPage as TextEditorPage > + > +masterForm = None > + > +def register(master): > + global masterForm > + masterForm = master > + tb = master.toolbar > + > + funcBtn = tb.appendButton(_("Functions"), > + dabo.ui.bitmapFromData(TextEditor.funcButtonData()), > + toggle=False, > + OnMouseLeftDown=onFuncButton) > + bmkBtn = tb.appendButton(_("Bookmarks"), > + dabo.ui.bitmapFromData(TextEditor.bmkButtonData()), > + toggle=False, > + OnMouseLeftDown=onBmkButton) > + printBtn = tb.appendButton(_("Print"), > + "print", > + toggle=False, > + OnHit=onPrint) > + lexSelector = dabo.ui.dDropdownList(tb, ValueMode="String", > + Choices = dabo.ui.dEditor.getAvailableLanguages(), > + OnHit = onLexSelect) > + tb.appendControl(lexSelector) > + > + master.setToolBarGroup("TextEditor", [funcBtn, bmkBtn, printBtn, > lexSelector]) > + > + > +def onFuncButton(evt): > + masterForm.Caption = "FUNC BUTT" > +def onBmkButton(evt): > + masterForm.Caption = "BMK BUTT" > +def onPrint(evt): > + masterForm.Caption = "PRINT BUTT" > +def onLexSelect(evt): > + masterForm.Caption = evt.EventObject.Value > + > + def updateLex(self): > + if not self.lexSelector.Choices: > + self.lexSelector.Choices = > self.CurrentEditor.getAvailableLanguages() > > > > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev Searchable Archives: http://leafe.com/archives/search/dabo-dev This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]
