dabo Commit
Revision 4120
Date: 2008-06-08 09:41:50 -0700 (Sun, 08 Jun 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4120
Changed:
U trunk/ide/MenuBarPanel.py
U trunk/ide/MenuDesigner.py
U trunk/ide/MenuDesignerForm.py
U trunk/ide/MenuPanel.py
Log:
Removed deprecated use of 'bindfunc' parameter.
Incremental improvement in display stability; still needs work.
Diff:
Modified: trunk/ide/MenuBarPanel.py
===================================================================
--- trunk/ide/MenuBarPanel.py 2008-06-08 16:39:13 UTC (rev 4119)
+++ trunk/ide/MenuBarPanel.py 2008-06-08 16:41:50 UTC (rev 4120)
@@ -6,9 +6,9 @@
import dabo.dEvents as dEvents
from MenuDesignerComponents import MenuSaverMixin
from MenuPanel import MenuPanel
+from dabo.lib.utils import dictStringify
-
class MenuBarPanel(MenuSaverMixin, dabo.ui.dPanel):
"""This panel represents the menu bar. It contains the
top-level menus.
@@ -187,7 +187,33 @@
"""Hides 'em all"""
self.hideAllBut()
-
+
+ def restore(self, dct):
+ """Takes a dictionary created by xmltodict from a saved .mnxml
file,
+ and re-creates the saved menu.
+ """
+ self.clear()
+ self.Form.lockDisplay()
+ for kid in dct["children"]:
+ atts = kid["attributes"]
+ mn = self.appendMenu(atts["Caption"], atts["MRU"])
+ mitems = kid["children"]
+ for mitem in mitems:
+ if mitem["name"] == "SeparatorPanel":
+ mn.appendSeparator()
+ else:
+ itm = mn.append("xx")
+ itm.Visible = False
+ itmAtts =
dictStringify(mitem["attributes"])
+ for att, val in itmAtts.items():
+ setattr(itm, att, val)
+ for kid in self.Children:
+ kid.Visible = True
+ self.layout()
+ self.fitToSizer()
+ self.Form.unlockDisplay()
+
+
def quickMenu(self):
"""This creates a base menu."""
self.Form.lockDisplay()
Modified: trunk/ide/MenuDesigner.py
===================================================================
--- trunk/ide/MenuDesigner.py 2008-06-08 16:39:13 UTC (rev 4119)
+++ trunk/ide/MenuDesigner.py 2008-06-08 16:41:50 UTC (rev 4120)
@@ -1,18 +1,32 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
+import sys
import dabo
from dabo.dLocalize import _
import dabo.dEvents as dEvents
import dabo.lib.xmltodict as xtd
+dabo.ui.loadUI("wx")
from MenuDesignerForm import MenuDesignerForm
-if __name__ == "__main__":
- dabo.ui.loadUI("wx")
+def main():
+ files = sys.argv[1:]
+ app = dabo.dApp()
+ app.BasePrefKey = "ide.MenuDesigner"
+ app.setAppInfo("appName", _("Dabo Menu Designer"))
+ app.setAppInfo("appShortName", _("MenuDesigner"))
+# app._persistentMRUs = {_("File") : onFileMRU}
+ app.MainFormClass = None
+ app.setup()
+ frm = app.MainForm = MenuDesignerForm()
+ for file in files:
+ frm.openFile(file)
+ frm.show()
+ app.start()
+
+
if __name__ == "__main__":
- app = dabo.dApp()
- app.MainFormClass = MenuDesignerForm
- app.start()
+ main()
Modified: trunk/ide/MenuDesignerForm.py
===================================================================
--- trunk/ide/MenuDesignerForm.py 2008-06-08 16:39:13 UTC (rev 4119)
+++ trunk/ide/MenuDesignerForm.py 2008-06-08 16:41:50 UTC (rev 4120)
@@ -87,18 +87,18 @@
# print "INITLAY"
self.menubar.clear()
self.mainPanel.clear()
- self.menubar.quickMenu()
+# self.menubar.quickMenu()
self.layout()
- dabo.ui.callAfterInterval(500, self.foo)
- def foo(self):
- try:
- firstMenu = self.menubar.Menus[0]
-# self.menubar.hideAllBut(firstMenu)
- self.Selection = firstMenu
- firstMenu.PanelVisible = True
- except IndexError:
- # No such menu
- pass
+# dabo.ui.callAfterInterval(500, self.foo)
+# def foo(self):
+# try:
+# firstMenu = self.menubar.Menus[0]
+# # self.menubar.hideAllBut(firstMenu)
+# self.Selection = firstMenu
+# firstMenu.PanelVisible = True
+# except IndexError:
+# # No such menu
+# pass
def afterSetMenuBar(self):
@@ -149,7 +149,7 @@
open(self._menuFile, "wb").write(xml)
- def openClass(self, pth):
+ def openFile(self, pth):
if not os.path.exists(pth):
dabo.ui.stop("The file '%s' does not exist" % pth)
return
@@ -157,7 +157,10 @@
try:
dct = xtd.xmltodict(xml)
except:
- raise IOError, _("This does not appear to be a valid
class file.")
+ raise IOError, _("This does not appear to be a valid
menu file.")
+ return
+ self.menubar.restore(dct)
+ self.layout()
def updatePropVal(self, prop, val, typ):
Modified: trunk/ide/MenuPanel.py
===================================================================
--- trunk/ide/MenuPanel.py 2008-06-08 16:39:13 UTC (rev 4119)
+++ trunk/ide/MenuPanel.py 2008-06-08 16:41:50 UTC (rev 4120)
@@ -90,13 +90,13 @@
def append(self, caption, key=None, picture=None, help=None,
- bindfunc=None, separator=False):
+ separator=False):
return self.insert(None, caption, key=None, picture=picture,
- help=help, bindfunc=bindfunc,
separator=separator)
+ help=help, separator=separator)
def insert(self, pos, caption, key=None, picture=None, help=None,
- bindfunc=None, separator=False):
+ separator=False):
if pos is None:
# Called from append
pos = len(self.itemList.Children)
@@ -109,8 +109,7 @@
itm._commonName = "Menu Item"
itm.isMenuItem = True
# Add the item to the dict
- self.itemDict[itm] = {"caption": caption, "key": key,
"picture": picture,
- "bindfunc": bindfunc}
+ self.itemDict[itm] = {"caption": caption, "key": key,
"picture": picture}
if picture:
itm.Picture = picture
_______________________________________________
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]