Changeset 4120

Show
Ignore:
Timestamp:
06/08/08 09:41:50 (6 months ago)
Author:
ed
Message:

Removed deprecated use of 'bindfunc' parameter.

Incremental improvement in display stability; still needs work.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ide/MenuBarPanel.py

    r3859 r4120  
    77from MenuDesignerComponents import MenuSaverMixin 
    88from MenuPanel import MenuPanel 
    9  
     9from dabo.lib.utils import dictStringify 
    1010 
    1111 
     
    188188        self.hideAllBut() 
    189189 
    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 
    191217    def quickMenu(self): 
    192218        """This creates a base menu.""" 
  • trunk/ide/MenuDesigner.py

    r3948 r4120  
    22# -*- coding: utf-8 -*- 
    33import os 
     4import sys 
    45import dabo 
    56from dabo.dLocalize import _ 
    67import dabo.dEvents as dEvents 
    78import dabo.lib.xmltodict as xtd 
     9dabo.ui.loadUI("wx") 
    810from MenuDesignerForm import MenuDesignerForm 
    911 
    10 if __name__ == "__main__": 
    11     dabo.ui.loadUI("wx") 
     12def 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     
    1228 
    1329 
    1430if __name__ == "__main__": 
    15     app = dabo.dApp()        
    16     app.MainFormClass = MenuDesignerForm 
    17     app.start() 
     31    main() 
    1832 
  • trunk/ide/MenuDesignerForm.py

    r3861 r4120  
    8888        self.menubar.clear() 
    8989        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 = firstMenu 
    98           firstMenu.PanelVisible = True 
    99       except IndexError: 
    100           # No such menu 
    101           pass 
     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 = firstMenu 
     98#             firstMenu.PanelVisible = True 
     99#         except IndexError: 
     100#             # No such menu 
     101#             pass 
    102102         
    103103     
     
    150150 
    151151 
    152     def openClass(self, pth): 
     152    def openFile(self, pth): 
    153153        if not os.path.exists(pth): 
    154154            dabo.ui.stop("The file '%s' does not exist" % pth) 
     
    158158            dct = xtd.xmltodict(xml) 
    159159        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() 
    161164         
    162165     
  • trunk/ide/MenuPanel.py

    r3859 r4120  
    9191 
    9292    def append(self, caption, key=None, picture=None, help=None,  
    93             bindfunc=None, separator=False): 
     93            separator=False): 
    9494        return self.insert(None, caption, key=None, picture=picture,  
    95                 help=help, bindfunc=bindfunc, separator=separator) 
     95                help=help, separator=separator) 
    9696     
    9797     
    9898    def insert(self, pos, caption, key=None, picture=None, help=None,  
    99             bindfunc=None, separator=False): 
     99            separator=False): 
    100100        if pos is None: 
    101101            # Called from append 
     
    110110            itm.isMenuItem = True 
    111111            # 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} 
    114113            if picture: 
    115114                itm.Picture = picture