Changeset 4132

Show
Ignore:
Timestamp:
06/14/08 08:30:34 (4 months ago)
Author:
ed
Message:

Incorporated changes from the trunk into this branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ed-ide/components/ClassDesigner/ClassDesigner.py

    r4061 r4132  
    139139                {"name" : "DropdownList", "class" : dui.dDropdownList, "order" : 70}, 
    140140                {"name" : "EditBox", "class" : dui.dEditBox, "order" : 80}, 
     141                {"name" : "HtmlBox", "class" : dui.dHtmlBox, "order" : 85}, 
    141142                {"name" : "Gauge", "class" : dui.dGauge, "order" : 90}, 
    142143                {"name" : "Grid", "class" : dui.dGrid, "order" : 100}, 
     
    344345                "ListEvent", "MenuEvent", "MouseEvent", "SashEvent", 
    345346                "CalendarEvent", "TreeEvent") 
    346         classes = (dui.dBox, dui.dBitmap, dui.dBitmapButton, dui.dButton, dui.dCheckBox, 
    347                 dui.dComboBox, dui.dDateTextBox, dui.dDialog, dui.dDropdownList, 
    348                 dui.dEditBox, dui.dEditor, dui.dForm, dui.dDockForm, dui.dGauge, dui.dGrid, dui.dImage,  
    349                 dui.dLabel, dui.dLine, dui.dListBox, dui.dListControl, dui.dOkCancelDialog, 
    350                 dui.dPanel, dui.dPage, dui.dScrollPanel, dui.dPage, dui.dPageFrame, 
    351                 dui.dPageList, dui.dPageSelect, dui.dPageFrameNoTabs, dui.dRadioList, 
    352                 dui.dSlider, dui.dSpinner, dui.dSplitter, dui.dTextBox, dui.dToggleButton, 
    353                 dui.dTreeView, dlgs.Wizard, dlgs.WizardPage) 
     347        classes = (dui.dBox, dui.dBitmap, dui.dBitmapButton, dui.dButton, dui.dCheckBox,  
     348                dui.dComboBox, dui.dDateTextBox, dui.dDialog, dui.dDropdownList, dui.dEditBox,  
     349                dui.dEditor, dui.dForm, dui.dDockForm, dui.dGauge, dui.dGrid, dui.dHtmlBox, dui.dImage,  
     350                dui.dLabel, dui.dLine, dui.dListBox, dui.dListControl, dui.dOkCancelDialog, dui.dPanel,  
     351                dui.dPage, dui.dScrollPanel, dui.dPage, dui.dPageFrame, dui.dPageList, dui.dPageSelect, 
     352                dui.dPageFrameNoTabs, dui.dRadioList, dui.dSlider, dui.dSpinner, dui.dSplitter, dui.dTextBox,  
     353                dui.dToggleButton, dui.dTreeView, dlgs.Wizard, dlgs.WizardPage) 
    354354 
    355355        def evtsForClass(cls): 
    356             ret = [] 
    357             for kk, vv in dEvents.__dict__.items(): 
    358                 if kk in baseEvents: 
    359                     # These are superclasses of individual events. 
    360                     continue 
     356            def safeApplies(itm, cls): 
    361357                try: 
    362                     if vv.appliesToClass(cls): 
    363                         ret.append("on%s" % kk) 
    364                 except: 
    365                     pass 
     358                    return itm.appliesToClass(cls) 
     359                except (AttributeError, NameError): 
     360                    return False 
     361            ret = ["on%s" % k for k,v in dEvents.__dict__.items()  
     362                    if safeApplies(v,cls)] 
    366363            ret.sort() 
    367364            return ret 
     
    808805                slots = int(self._extractKey(atts, "SlotCount", "1")) 
    809806                useBox, boxCaption = None, None 
     807#               defSpacing = int(self._extractKey(atts, "DefaultSpacing", "0")) 
    810808                if clsname == "LayoutBorderSizer": 
    811809                    useBox = True 
     
    815813                szCont = sz.ControllingSizer 
    816814                itm = sz.ControllingSizerItem 
    817  
     815#               if defSpacing: 
     816#                   # Need to set this *after* the design has been created, or else 
     817#                   # it will create non-Designer spacers that will confuse things. 
     818#                   def setLater(sz, spc): 
     819#                       sz.DefaultSpacing = spc 
     820#                   dabo.ui.callAfter(setLater, sz, defSpacing) 
    818821                is2D = isinstance(szCont, dabo.ui.dGridSizer) 
    819822                defaults = {True: szItemDefaults[2], 
     
    17111714                        "PageNoTabs", "Box", "Bitmap", "BitmapButton", "Button", "CheckBox", 
    17121715                        "ComboBox", "DateTextBox", "DropdownList", "EditBox", "Editor", 
    1713                         "Gauge", "Grid", "Image", "Label", "Line", "ListBox", "ListControl", "Page", 
     1716                        "Gauge", "Grid", "HtmlBox", "Image", "Label", "Line", "ListBox", "ListControl", "Page", 
    17141717                        "RadioList", "Slider", "Spinner", "Splitter", "TextBox", "ToggleButton", 
    17151718                        "TreeView"] 
     
    17191722                        dui.dBox, dui.dBitmap, dui.dBitmapButton, dui.dButton, dui.dCheckBox, 
    17201723                        dui.dComboBox, dui.dDateTextBox, dui.dDropdownList, dui.dEditBox, 
    1721                         dui.dEditor, dui.dGauge, dui.dGrid, dui.dImage, dui.dLabel, dui.dLine, 
     1724                        dui.dEditor, dui.dGauge, dui.dGrid, dui.dHtmlBox, dui.dImage, dui.dLabel, dui.dLine, 
    17221725                        dui.dListBox, dui.dListControl, dui.dPage, dui.dRadioList, dui.dSlider, 
    17231726                        dui.dSpinner, dui.dSplitter, dui.dTextBox, dui.dToggleButton, 
     
    20482051                if adding: 
    20492052                    prop = data["propName"] 
    2050                 if not self._classPropDict.has_key(obj): 
     2053                try: 
     2054                    self._classPropDict["obj"] 
     2055                except KeyError: 
    20512056                    self._classPropDict[obj] = {} 
    20522057                # Make sure that there are no single quotes in the comment 
     
    25332538            props["ColumnClass"] = self.getControlClass(dui.dColumn) 
    25342539            newCols = None 
    2535             if not props.has_key("ColumnCount"): 
     2540            try: 
     2541                props["ColumnCount"] 
     2542            except KeyError: 
    25362543                try: 
    25372544                    newCols = int(dui.getString(_("How many columns?"), 
    25382545                            _("New Grid Control"), "3")) 
    2539                 except
     2546                except ValueError
    25402547                    newCols = 3 
    25412548 
     
    28742881            pop.append(_("Add EditBox"), OnHit=self.onNewEditBox) 
    28752882            pop.append(_("Add Grid"), OnHit=self.onNewGrid) 
     2883            pop.append(_("Add HtmlBox"), OnHit=self.onNewHtmlBox) 
    28762884            pop.append(_("Add ListBox"), OnHit=self.onNewListBox) 
    28772885            pop.append(_("Add ListControl"), OnHit=self.onNewListControl) 
     
    30873095    def onNewGrid(self, evt): 
    30883096        dui.callAfter(self.addNewControl, None, dui.dGrid) 
     3097    def onNewHtmlBox(self, evt): 
     3098        dui.callAfter(self.addNewControl, None, dui.dHtmlBox) 
    30893099    def onNewImage(self, evt): 
    30903100        dui.callAfter(self.addNewControl, None, dui.dImage) 
     
    38693879                    (_("Gauge"), dui.dGauge), 
    38703880                    (_("Grid"), dui.dGrid), 
     3881                    (_("HtmlBox"), dui.dHtmlBox), 
    38713882                    (_("Image"), dui.dImage), 
    38723883                    (_("Label"), dui.dLabel), 
  • branches/ed-ide/components/ClassDesigner/ClassDesignerComponents.py

    r4061 r4132  
    6161                try: 
    6262                    myID = self.classID.split("-")[1] 
    63                 except
     63                except IndexError
    6464                    myID = abs(self.__hash__()) 
    6565                if classID is None: 
     
    6767                    try: 
    6868                        classID = self.Parent.classID.split("-")[0] 
    69                     except
     69                    except IndexError
    7070                        # Try the sizer 
    7171                            try: 
    7272                                classID = self.ControllingSizer.classID.split("-")[0] 
    73                             except
     73                            except IndexError
    7474                                classID = "?????" 
    7575                ra["classID"] = "%s-%s" % (classID, myID) 
     
    107107            ra["designerClass"] = self.getClassName() 
    108108 
    109 #       hasSizer = not isClass and (hasattr(self, "ControllingSizerItem") and self.ControllingSizerItem) 
    110         hasSizer = (hasattr(self, "ControllingSizerItem") and self.ControllingSizerItem) 
     109        hasSizer = bool(hasattr(self, "ControllingSizerItem") and self.ControllingSizerItem) 
    111110        # We want to include some props whether they are the 
    112111        # default or not. 
     
    179178            # If it hasn't changed from the default, skip it 
    180179            if not allProps: 
    181                 if defVals.has_key(prop): 
    182                     if prop not in propsToInclude: 
    183                         dv = defVals[prop] 
    184                         if not isinstance(val, basestring) and isinstance(dv, basestring): 
    185                             # Try to convert 
    186                             if isinstance(val, bool): 
    187                                 dv = (dv.lower() == "true") 
    188                             elif isinstance(val, int): 
    189                                 dv = int(dv) 
    190                             elif isinstance(val, long): 
    191                                 dv = long(dv) 
    192                             elif isinstance(val, float): 
    193                                 dv = float(dv) 
    194                             elif isinstance(val, (list, tuple, dict)): 
    195                                 dv = eval(dv) 
    196                             elif dv == "None": 
    197                                 dv = None 
    198                         if dv == val: 
    199                             continue 
     180                try: 
     181                    defVals[prop] 
     182                except KeyError: 
     183                    continue 
     184                if prop not in propsToInclude: 
     185                    dv = defVals[prop] 
     186                    if not isinstance(val, basestring) and isinstance(dv, basestring): 
     187                        # Try to convert 
     188                        if isinstance(val, bool): 
     189                            dv = (dv.lower() == "true") 
     190                        elif isinstance(val, int): 
     191                            dv = int(dv) 
     192                        elif isinstance(val, long): 
     193                            dv = long(dv) 
     194                        elif isinstance(val, float): 
     195                            dv = float(dv) 
     196                        elif isinstance(val, (list, tuple, dict)): 
     197                            dv = eval(dv) 
     198                        elif dv == "None": 
     199                            dv = None 
     200                    if dv == val: 
     201                        continue 
    200202 
    201203            if isinstance(val, basestring): 
     
    208210            itmProps = self.ControllingSizer.getItemProps(self.ControllingSizerItem) 
    209211            if insideClass: 
    210                 itmDiffProps = self._diffSizerItemProps(itmProps, classDict
     212                itmDiffProps = self._diffSizerItemProps(itmProps, classDict, direct=True
    211213            else: 
    212214                itmDiffProps = self._diffSizerItemProps(itmProps, self.ControllingSizer) 
    213 #               try: 
    214 #                   defProps = self.Controller.getDefaultSizerProps(self.superControl) 
    215 #                   itmDiffProps = self._diffSizerItemProps(itmProps, defProps, direct=True) 
    216 #               except: 
    217 #                   itmDiffProps = self._diffSizerItemProps(itmProps, self.ControllingSizer) 
    218215            ret["attributes"]["sizerInfo"] = itmDiffProps 
    219216        except AttributeError: 
     
    236233    def _diffSizerItemProps(self, dct, szOrDict, direct=False): 
    237234        """Remove all of the default values from the sizer item props.""" 
    238         # First, what type of sizer is it? 
    239         is2D = isinstance(szOrDict, dabo.ui.dGridSizer) 
    240         defaults = {True: szItemDefaults[2], False: szItemDefaults[1]}[is2D].copy() 
     235        if direct: 
     236            defaults = szOrDict 
     237        else: 
     238            # First, what type of sizer is it? 
     239            is2D = isinstance(szOrDict, dabo.ui.dGridSizer) 
     240            defaults = {True: szItemDefaults[2], False: szItemDefaults[1]}[is2D].copy() 
    241241        if isinstance(self, LayoutPanel): 
    242242            defaults["Expand"] = True 
     
    377377                                if cd["attributes"]["classID"] == kidID][0] 
    378378                    except StandardError, e: 
    379                         kidDict = None 
    380                 except
    381                     pass 
     379                        kidDict = {} 
     380                except AttributeError
     381                    kidDict = {} 
    382382 
    383383            ret.append(kid.getDesignerDict(itemNum=numItems, 
     
    420420                                if cd["attributes"]["classID"] == szID][0] 
    421421                    except StandardError, e: 
    422                         szDict = None 
    423                 except
    424                     pass 
     422                        szDict = {} 
     423                except AttributeError
     424                    szDict = {} 
    425425            ret.append(sz.getDesignerDict(itemNum=len(ret), classDict=szDict)) 
    426426        return ret 
     
    496496        try: 
    497497            self._defaultSizerProps = self.ControllingSizer.getItemProps(self) 
    498         except
     498        except AttributeError
    499499            self._defaultSizerProps = {} 
    500500         
     
    886886        try: 
    887887            sizerAtts = self.getDesignerDict()["attributes"]["sizerInfo"] 
    888         except
     888        except KeyError
    889889            sizerAtts = None 
    890890        cs.remove(self) 
     
    946946class LayoutSizerMixin(LayoutSaverMixin): 
    947947    def __init__(self, *args, **kwargs): 
     948        self.isDesignerSizer = True 
    948949        super(LayoutSizerMixin, self).__init__(*args, **kwargs) 
    949950 
     
    998999                defProps = self.Controller.getDefaultSizerProps(kidItem.superControl) 
    9991000                itmDiffDict = self._diffSizerItemProps(itmDict, defProps, direct=True) 
    1000             except
     1001            except AttributeError
    10011002                itmDiffDict = self._diffSizerItemProps(itmDict, self) 
    10021003            if kidItem in self.ChildWindows: 
     
    10091010                                    if cd["attributes"]["classID"] == winID][0] 
    10101011                        except StandardError, e: 
    1011                             winDict = None 
    1012                     except
    1013                         pass 
     1012                            winDict = {} 
     1013                    except AttributeError
     1014                        winDict = {} 
    10141015                kidDict = kidItem.getDesignerDict(itemNum=numItems, 
    10151016                        classDict=winDict) 
     
    10241025                                    if cd["attributes"]["classID"] == szrID][0] 
    10251026                        except StandardError, e: 
    1026                             szrDict = None 
    1027                     except
    1028                         pass 
     1027                            szrDict = {} 
     1028                    except AttributeError
     1029                        szrDict = {} 
    10291030                kidDict = kidItem.getDesignerDict(itemNum=numItems, 
    10301031                        classDict=szrDict) 
     
    10361037                else: 
    10371038                    pos = 0 
    1038                 spc = kidItem.Spacing 
     1039                try: 
     1040                    spc = kidItem.Spacing 
     1041                except AttributeError: 
     1042                    spc = 0 
    10391043                kidDict = {"name" : "Spacer", 
    10401044                    "attributes" : {"size" : spc, "Name" : "spacer"}, 
     
    11641168                "DefaultBorderTop": {"type" : bool, "readonly" : False}, 
    11651169                "DefaultBorderBottom": {"type" : bool, "readonly" : False}, 
     1170                "DefaultSpacing": {"type" : int, "readonly" : False}, 
    11661171                "SlotCount" : {"type": int, "readonly" : False}} 
    11671172        # Add the controlling sizer props, if applicable 
     
    15291534            except StandardError, e: 
    15301535                ret = None 
    1531         except
     1536        except AttributeError
    15321537            pass 
    15331538        return ret 
  • branches/ed-ide/components/ClassDesigner/ClassDesignerControlMixin.py

    r4061 r4132  
    746746        imageProps = {"ScaleMode" : {"type" : list, "readonly" : False, 
    747747                    "values" : ["Clip", "Proportional", "Stretch"]}} 
     748        labelProps = {"AutoResize": {"type" : bool, "readonly" : False}} 
    748749        multiSelectProps = {"MultipleSelect": {"type" : bool, "readonly" : False}} 
    749750        nodeProps = {"Image": {"type" : "path", "readonly" : False,  
    750751                    "customEditor": "editStdPicture"}} 
    751         panelProps = {"Buffered" : {"type" : bool, "readonly" : False}, 
    752                 "AlwaysResetSizer": {"type" : bool, "readonly" : False}} 
     752        panelProps = {"AlwaysResetSizer": {"type" : bool, "readonly" : False}, 
     753                "Buffered" : {"type" : bool, "readonly" : False}, 
     754                "MinSizerHeight": {"type" : int, "readonly" : False}, 
     755                "MinSizerWidth": {"type" : int, "readonly" : False}} 
    753756        pictureProps = {"Picture": {"type" : "path", "readonly" : False,  
    754757                    "customEditor": "editStdPicture"}} 
     
    775778                "Min": {"type" : int, "readonly" : False}, 
    776779                "ShowLabels" : {"type" : bool, "readonly" : False}} 
    777         splitterProps = {  "MinimumPanelSize": {"type" : int, "readonly" : False}, 
     780        splitterProps = {"MinimumPanelSize": {"type" : int, "readonly" : False}, 
    778781                "Orientation": {"type" : list, "readonly" : False, 
    779782                    "values" : ["Horizontal", "Vertical"]}, 
     
    792795                    "values" : ["Upper", "Lower", "Title", "None"]},         
    793796                "ReadOnly" : {"type" : bool, "readonly" : False}} 
     797        htmlTextProps = {"Page": {"type" : unicode, "readonly" : False}, 
     798                "RespondToLinks": {"type" : bool, "readonly" : False}, 
     799                "ShowScrollBars": {"type" : bool, "readonly" : False}, 
     800                "Source": {"type" : unicode, "readonly" : False}} 
     801        scrollProps = {"HorizontalScroll": {"type" : bool, "readonly" : False}, 
     802                "VerticalScroll": {"type" : bool, "readonly" : False}} 
    794803        treeProps = {"Editable" : {"type" : bool, "readonly" : False}, 
    795804                "MultipleSelect" : {"type" : bool, "readonly" : False}, 
     
    878887            ret.update(imageProps) 
    879888        elif isinstance(self, dabo.ui.dLabel): 
     889            ret.update(labelProps) 
    880890            ret.update(colorProps) 
    881891            ret.update(captionProps) 
     
    937947        elif isinstance(self, dabo.ui.dScrollPanel): 
    938948            ret.update(panelProps) 
     949            ret.update(scrollProps) 
    939950            ret.update(colorProps) 
    940951        elif isinstance(self, dabo.ui.dPanel): 
     
    960971                ret.update({"PasswordEntry" : {"type" : bool, "readonly" : False}, 
    961972                        "TextLength" : {"type" : int, "readonly" : False}}) 
     973        elif isinstance(self, dabo.ui.dHtmlBox): 
     974            ret.update(htmlTextProps) 
     975            ret.update(scrollProps) 
    962976        elif isinstance(self, dabo.ui.dTimer): 
    963977            pass 
  • branches/ed-ide/components/ClassDesigner/ClassDesignerFormMixin.py

    r4063 r4132  
    484484        # IOErrorrror that the calling method can catch. 
    485485        open(fname, "wb").write(xml) 
    486         if not singleFile: 
    487             # Now write out the code file 
    488             cfName = "%s-code.py" % os.path.splitext(fname)[0] 
     486        cfName = "%s-code.py" % os.path.splitext(fname)[0] 
     487        if singleFile: 
     488            # Delete the code file if present. 
     489            if os.path.exists(cfName): 
     490                os.remove(cfName) 
     491        else: 
     492            # Write out the code file 
    489493            open(cfName, "wb").write(self._createDesignerCode(codeDict)) 
    490494        if currForm: 
     
    10021006        if ctl is None: 
    10031007            return 
    1004         if self.handles.has_key(ctl)
     1008        try
    10051009            hnd = self.handles[ctl] 
    1006            for nm,h in hnd.items()
    1007                h.Visible = False 
    1008                if release
    1009                    h.release() 
     1010        except KeyError
     1011            return 
     1012        for nm,h in hnd.items()
     1013            h.Visible = False 
    10101014            if release: 
    1011                 del self.handles[ctl] 
     1015                h.release() 
     1016        if release: 
     1017            del self.handles[ctl] 
    10121018 
    10131019 
  • branches/ed-ide/components/ClassDesigner/ClassDesignerPropSheet.py

    r4061 r4132  
    319319            dabo.ui.stop(_("Could not set property '%s' to value '%s'\nReason: '%s'")  
    320320                    % (prop, val, e)) 
    321             self.updateGridValues()         
     321            self.updateGridValues()  
    322322 
    323323