Changeset 3060

Show
Ignore:
Timestamp:
04/13/2007 05:14:16 PM (2 years ago)
Author:
paul
Message:

Removed IconBundle? property from dFormMixin. Added the ability to set Form.Icon
to a sequence of filenames which Dabo will convert to a wx.IconBundle?
automatically.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dApp.py

    r3054 r3060  
    977977         
    978978    Icon = property(_getIcon, _setIcon, None, 
    979             _("""Specifies the icon to use on all forms and dialogs by default.""")) 
     979            _("""Specifies the icon to use on all forms and dialogs by default. 
     980 
     981            The value passed can be a binary icon bitmap, a filename, or a 
     982            sequence of filenames. Providing a sequence of filenames pointing to 
     983            icons at expected dimensions like 16, 22, and 32 px means that the 
     984            system will not have to scale the icon, resulting in a much better 
     985            appearance.""")) 
    980986 
    981987    MainForm = property(_getMainForm, _setMainForm, None, 
  • trunk/dabo/ui/uiwx/dFormMixin.py

    r3054 r3060  
    573573    def _getIcon(self): 
    574574        try: 
    575             return self._Icon 
     575            return self._icon 
    576576        except AttributeError: 
    577577            return None 
     
    579579    def _setIcon(self, val): 
    580580        if self._constructed(): 
     581            setIconFunc = self.SetIcon 
    581582            if val is None: 
    582583                ico = wx.NullIcon 
     
    584585                ico = val 
    585586            else: 
    586                 iconPath = dabo.icons.getIconFileName(val) 
    587                 if iconPath and os.path.exists(iconPath): 
    588                     ext = os.path.splitext(iconPath)[1].lower() 
    589                     if ext == ".png": 
    590                         bitmapType = wx.BITMAP_TYPE_PNG 
    591                     elif ext == ".ico": 
    592                         bitmapType = wx.BITMAP_TYPE_ICO 
     587                setIconFunc = self.SetIcons 
     588                if isinstance(val, basestring): 
     589                    icon_strs = (val,) 
     590                else: 
     591                    icon_strs = val 
     592                ico = wx.IconBundle() 
     593                for icon_str in icon_strs: 
     594                    iconPath = dabo.icons.getIconFileName(icon_str) 
     595                    if iconPath and os.path.exists(iconPath): 
     596                        ext = os.path.splitext(iconPath)[1].lower() 
     597                        if ext == ".png": 
     598                            bitmapType = wx.BITMAP_TYPE_PNG 
     599                        elif ext == ".ico": 
     600                            bitmapType = wx.BITMAP_TYPE_ICO 
     601                        else: 
     602                            # punt: 
     603                            bitmapType = wx.BITMAP_TYPE_ANY 
     604                        single_ico = wx.Icon(iconPath, bitmapType) 
    593605                    else: 
    594                         # punt, but only ico will work on Windows 
    595                         bitmapType = wx.BITMAP_TYPE_ANY 
    596                     ico = wx.Icon(iconPath, bitmapType) 
    597                 else: 
    598                     val = None 
    599                     ico = wx.NullIcon 
    600 #                   raise ValueError, "Invalid icon specified." 
    601  
     606                        single_ico = wx.NullIcon 
     607                    ico.AddIcon(single_ico) 
    602608            # wx doesn't provide GetIcon() 
    603             self._Icon = val 
    604             self.SetIcon(ico) 
     609            self._icon = val 
     610            setIconFunc(ico) 
    605611 
    606612        else: 
    607613            self._properties["Icon"] = val 
    608614 
    609  
    610     def _getIconBundle(self): 
    611         try: 
    612             return self._Icons 
    613         except: 
    614             return None 
    615              
    616     def _setIconBundle(self, val): 
    617         if self._constructed(): 
    618             self.SetIcons(val) 
    619             self._Icons = val       # wx doesn't provide GetIcons() 
    620         else: 
    621             self._properties["Icons"] = val 
    622              
    623615 
    624616    def _getMDI(self): 
     
    923915     
    924916    Icon = property(_getIcon, _setIcon, None,  
    925             _("Specifies the icon for the form. (wxIcon)")) 
    926  
    927     IconBundle = property(_getIconBundle, _setIconBundle, None, 
    928             _("Specifies the set of icons for the form. (wxIconBundle)")) 
     917            _("""Specifies the icon for the form. 
     918 
     919            The value passed can be a binary icon bitmap, a filename, or a 
     920            sequence of filenames. Providing a sequence of filenames pointing to 
     921            icons at expected dimensions like 16, 22, and 32 px means that the 
     922            system will not have to scale the icon, resulting in a much better 
     923            appearance.""")) 
    929924 
    930925    MDI = property(_getMDI, None, None, 
     
    10131008    DynamicFloatOnParent = makeDynamicProperty(FloatOnParent) 
    10141009    DynamicIcon = makeDynamicProperty(Icon) 
    1015     DynamicIconBundle = makeDynamicProperty(IconBundle) 
    10161010    DynamicMenuBar = makeDynamicProperty(MenuBar) 
    10171011    DynamicShowCaption = makeDynamicProperty(ShowCaption)