Changeset 4120
- Timestamp:
- 06/08/08 09:41:50 (6 months ago)
- Files:
-
- trunk/ide/MenuBarPanel.py (modified) (2 diffs)
- trunk/ide/MenuDesigner.py (modified) (1 diff)
- trunk/ide/MenuDesignerForm.py (modified) (3 diffs)
- trunk/ide/MenuPanel.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ide/MenuBarPanel.py
r3859 r4120 7 7 from MenuDesignerComponents import MenuSaverMixin 8 8 from MenuPanel import MenuPanel 9 9 from dabo.lib.utils import dictStringify 10 10 11 11 … … 188 188 self.hideAllBut() 189 189 190 190 191 def restore(self, dct): 192 """Takes a dictionary created by xmltodict from a saved .mnxml file, 193 and re-creates the saved menu. 194 """ 195 self.clear() 196 self.Form.lockDisplay() 197 for kid in dct["children"]: 198 atts = kid["attributes"] 199 mn = self.appendMenu(atts["Caption"], atts["MRU"]) 200 mitems = kid["children"] 201 for mitem in mitems: 202 if mitem["name"] == "SeparatorPanel": 203 mn.appendSeparator() 204 else: 205 itm = mn.append("xx") 206 itm.Visible = False 207 itmAtts = dictStringify(mitem["attributes"]) 208 for att, val in itmAtts.items(): 209 setattr(itm, att, val) 210 for kid in self.Children: 211 kid.Visible = True 212 self.layout() 213 self.fitToSizer() 214 self.Form.unlockDisplay() 215 216 191 217 def quickMenu(self): 192 218 """This creates a base menu.""" trunk/ide/MenuDesigner.py
r3948 r4120 2 2 # -*- coding: utf-8 -*- 3 3 import os 4 import sys 4 5 import dabo 5 6 from dabo.dLocalize import _ 6 7 import dabo.dEvents as dEvents 7 8 import dabo.lib.xmltodict as xtd 9 dabo.ui.loadUI("wx") 8 10 from MenuDesignerForm import MenuDesignerForm 9 11 10 if __name__ == "__main__": 11 dabo.ui.loadUI("wx") 12 def main(): 13 files = sys.argv[1:] 14 app = dabo.dApp() 15 app.BasePrefKey = "ide.MenuDesigner" 16 app.setAppInfo("appName", _("Dabo Menu Designer")) 17 app.setAppInfo("appShortName", _("MenuDesigner")) 18 # app._persistentMRUs = {_("File") : onFileMRU} 19 app.MainFormClass = None 20 app.setup() 21 22 frm = app.MainForm = MenuDesignerForm() 23 for file in files: 24 frm.openFile(file) 25 frm.show() 26 app.start() 27 12 28 13 29 14 30 if __name__ == "__main__": 15 app = dabo.dApp() 16 app.MainFormClass = MenuDesignerForm 17 app.start() 31 main() 18 32 trunk/ide/MenuDesignerForm.py
r3861 r4120 88 88 self.menubar.clear() 89 89 self.mainPanel.clear() 90 self.menubar.quickMenu()91 self.layout() 92 dabo.ui.callAfterInterval(500, self.foo)93 def foo(self):94 try:95 firstMenu = self.menubar.Menus[0]96 # self.menubar.hideAllBut(firstMenu)97 self.Selection = firstMenu98 firstMenu.PanelVisible = True99 except IndexError:100 # No such menu101 pass90 # self.menubar.quickMenu() 91 self.layout() 92 # dabo.ui.callAfterInterval(500, self.foo) 93 # def foo(self): 94 # try: 95 # firstMenu = self.menubar.Menus[0] 96 # # self.menubar.hideAllBut(firstMenu) 97 # self.Selection = firstMenu 98 # firstMenu.PanelVisible = True 99 # except IndexError: 100 # # No such menu 101 # pass 102 102 103 103 … … 150 150 151 151 152 def open Class(self, pth):152 def openFile(self, pth): 153 153 if not os.path.exists(pth): 154 154 dabo.ui.stop("The file '%s' does not exist" % pth) … … 158 158 dct = xtd.xmltodict(xml) 159 159 except: 160 raise IOError, _("This does not appear to be a valid class file.") 160 raise IOError, _("This does not appear to be a valid menu file.") 161 return 162 self.menubar.restore(dct) 163 self.layout() 161 164 162 165 trunk/ide/MenuPanel.py
r3859 r4120 91 91 92 92 def append(self, caption, key=None, picture=None, help=None, 93 bindfunc=None,separator=False):93 separator=False): 94 94 return self.insert(None, caption, key=None, picture=picture, 95 help=help, bindfunc=bindfunc,separator=separator)95 help=help, separator=separator) 96 96 97 97 98 98 def insert(self, pos, caption, key=None, picture=None, help=None, 99 bindfunc=None,separator=False):99 separator=False): 100 100 if pos is None: 101 101 # Called from append … … 110 110 itm.isMenuItem = True 111 111 # Add the item to the dict 112 self.itemDict[itm] = {"caption": caption, "key": key, "picture": picture, 113 "bindfunc": bindfunc} 112 self.itemDict[itm] = {"caption": caption, "key": key, "picture": picture} 114 113 if picture: 115 114 itm.Picture = picture
