- Timestamp:
- 06/14/08 08:30:34 (5 months ago)
- Files:
-
- branches/ed-ide/components/ClassDesigner/ClassDesigner.py (modified) (11 diffs)
- branches/ed-ide/components/ClassDesigner/ClassDesignerComponents.py (modified) (17 diffs)
- branches/ed-ide/components/ClassDesigner/ClassDesignerControlMixin.py (modified) (6 diffs)
- branches/ed-ide/components/ClassDesigner/ClassDesignerFormMixin.py (modified) (2 diffs)
- branches/ed-ide/components/ClassDesigner/ClassDesignerPropSheet.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ed-ide/components/ClassDesigner/ClassDesigner.py
r4061 r4132 139 139 {"name" : "DropdownList", "class" : dui.dDropdownList, "order" : 70}, 140 140 {"name" : "EditBox", "class" : dui.dEditBox, "order" : 80}, 141 {"name" : "HtmlBox", "class" : dui.dHtmlBox, "order" : 85}, 141 142 {"name" : "Gauge", "class" : dui.dGauge, "order" : 90}, 142 143 {"name" : "Grid", "class" : dui.dGrid, "order" : 100}, … … 344 345 "ListEvent", "MenuEvent", "MouseEvent", "SashEvent", 345 346 "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) 354 354 355 355 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): 361 357 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)] 366 363 ret.sort() 367 364 return ret … … 808 805 slots = int(self._extractKey(atts, "SlotCount", "1")) 809 806 useBox, boxCaption = None, None 807 # defSpacing = int(self._extractKey(atts, "DefaultSpacing", "0")) 810 808 if clsname == "LayoutBorderSizer": 811 809 useBox = True … … 815 813 szCont = sz.ControllingSizer 816 814 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) 818 821 is2D = isinstance(szCont, dabo.ui.dGridSizer) 819 822 defaults = {True: szItemDefaults[2], … … 1711 1714 "PageNoTabs", "Box", "Bitmap", "BitmapButton", "Button", "CheckBox", 1712 1715 "ComboBox", "DateTextBox", "DropdownList", "EditBox", "Editor", 1713 "Gauge", "Grid", " Image", "Label", "Line", "ListBox", "ListControl", "Page",1716 "Gauge", "Grid", "HtmlBox", "Image", "Label", "Line", "ListBox", "ListControl", "Page", 1714 1717 "RadioList", "Slider", "Spinner", "Splitter", "TextBox", "ToggleButton", 1715 1718 "TreeView"] … … 1719 1722 dui.dBox, dui.dBitmap, dui.dBitmapButton, dui.dButton, dui.dCheckBox, 1720 1723 dui.dComboBox, dui.dDateTextBox, dui.dDropdownList, dui.dEditBox, 1721 dui.dEditor, dui.dGauge, dui.dGrid, dui.d Image, dui.dLabel, dui.dLine,1724 dui.dEditor, dui.dGauge, dui.dGrid, dui.dHtmlBox, dui.dImage, dui.dLabel, dui.dLine, 1722 1725 dui.dListBox, dui.dListControl, dui.dPage, dui.dRadioList, dui.dSlider, 1723 1726 dui.dSpinner, dui.dSplitter, dui.dTextBox, dui.dToggleButton, … … 2048 2051 if adding: 2049 2052 prop = data["propName"] 2050 if not self._classPropDict.has_key(obj): 2053 try: 2054 self._classPropDict["obj"] 2055 except KeyError: 2051 2056 self._classPropDict[obj] = {} 2052 2057 # Make sure that there are no single quotes in the comment … … 2533 2538 props["ColumnClass"] = self.getControlClass(dui.dColumn) 2534 2539 newCols = None 2535 if not props.has_key("ColumnCount"): 2540 try: 2541 props["ColumnCount"] 2542 except KeyError: 2536 2543 try: 2537 2544 newCols = int(dui.getString(_("How many columns?"), 2538 2545 _("New Grid Control"), "3")) 2539 except :2546 except ValueError: 2540 2547 newCols = 3 2541 2548 … … 2874 2881 pop.append(_("Add EditBox"), OnHit=self.onNewEditBox) 2875 2882 pop.append(_("Add Grid"), OnHit=self.onNewGrid) 2883 pop.append(_("Add HtmlBox"), OnHit=self.onNewHtmlBox) 2876 2884 pop.append(_("Add ListBox"), OnHit=self.onNewListBox) 2877 2885 pop.append(_("Add ListControl"), OnHit=self.onNewListControl) … … 3087 3095 def onNewGrid(self, evt): 3088 3096 dui.callAfter(self.addNewControl, None, dui.dGrid) 3097 def onNewHtmlBox(self, evt): 3098 dui.callAfter(self.addNewControl, None, dui.dHtmlBox) 3089 3099 def onNewImage(self, evt): 3090 3100 dui.callAfter(self.addNewControl, None, dui.dImage) … … 3869 3879 (_("Gauge"), dui.dGauge), 3870 3880 (_("Grid"), dui.dGrid), 3881 (_("HtmlBox"), dui.dHtmlBox), 3871 3882 (_("Image"), dui.dImage), 3872 3883 (_("Label"), dui.dLabel), branches/ed-ide/components/ClassDesigner/ClassDesignerComponents.py
r4061 r4132 61 61 try: 62 62 myID = self.classID.split("-")[1] 63 except :63 except IndexError: 64 64 myID = abs(self.__hash__()) 65 65 if classID is None: … … 67 67 try: 68 68 classID = self.Parent.classID.split("-")[0] 69 except :69 except IndexError: 70 70 # Try the sizer 71 71 try: 72 72 classID = self.ControllingSizer.classID.split("-")[0] 73 except :73 except IndexError: 74 74 classID = "?????" 75 75 ra["classID"] = "%s-%s" % (classID, myID) … … 107 107 ra["designerClass"] = self.getClassName() 108 108 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) 111 110 # We want to include some props whether they are the 112 111 # default or not. … … 179 178 # If it hasn't changed from the default, skip it 180 179 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 200 202 201 203 if isinstance(val, basestring): … … 208 210 itmProps = self.ControllingSizer.getItemProps(self.ControllingSizerItem) 209 211 if insideClass: 210 itmDiffProps = self._diffSizerItemProps(itmProps, classDict )212 itmDiffProps = self._diffSizerItemProps(itmProps, classDict, direct=True) 211 213 else: 212 214 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)218 215 ret["attributes"]["sizerInfo"] = itmDiffProps 219 216 except AttributeError: … … 236 233 def _diffSizerItemProps(self, dct, szOrDict, direct=False): 237 234 """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() 241 241 if isinstance(self, LayoutPanel): 242 242 defaults["Expand"] = True … … 377 377 if cd["attributes"]["classID"] == kidID][0] 378 378 except StandardError, e: 379 kidDict = None380 except :381 pass379 kidDict = {} 380 except AttributeError: 381 kidDict = {} 382 382 383 383 ret.append(kid.getDesignerDict(itemNum=numItems, … … 420 420 if cd["attributes"]["classID"] == szID][0] 421 421 except StandardError, e: 422 szDict = None423 except :424 pass422 szDict = {} 423 except AttributeError: 424 szDict = {} 425 425 ret.append(sz.getDesignerDict(itemNum=len(ret), classDict=szDict)) 426 426 return ret … … 496 496 try: 497 497 self._defaultSizerProps = self.ControllingSizer.getItemProps(self) 498 except :498 except AttributeError: 499 499 self._defaultSizerProps = {} 500 500 … … 886 886 try: 887 887 sizerAtts = self.getDesignerDict()["attributes"]["sizerInfo"] 888 except :888 except KeyError: 889 889 sizerAtts = None 890 890 cs.remove(self) … … 946 946 class LayoutSizerMixin(LayoutSaverMixin): 947 947 def __init__(self, *args, **kwargs): 948 self.isDesignerSizer = True 948 949 super(LayoutSizerMixin, self).__init__(*args, **kwargs) 949 950 … … 998 999 defProps = self.Controller.getDefaultSizerProps(kidItem.superControl) 999 1000 itmDiffDict = self._diffSizerItemProps(itmDict, defProps, direct=True) 1000 except :1001 except AttributeError: 1001 1002 itmDiffDict = self._diffSizerItemProps(itmDict, self) 1002 1003 if kidItem in self.ChildWindows: … … 1009 1010 if cd["attributes"]["classID"] == winID][0] 1010 1011 except StandardError, e: 1011 winDict = None1012 except :1013 pass1012 winDict = {} 1013 except AttributeError: 1014 winDict = {} 1014 1015 kidDict = kidItem.getDesignerDict(itemNum=numItems, 1015 1016 classDict=winDict) … … 1024 1025 if cd["attributes"]["classID"] == szrID][0] 1025 1026 except StandardError, e: 1026 szrDict = None1027 except :1028 pass1027 szrDict = {} 1028 except AttributeError: 1029 szrDict = {} 1029 1030 kidDict = kidItem.getDesignerDict(itemNum=numItems, 1030 1031 classDict=szrDict) … … 1036 1037 else: 1037 1038 pos = 0 1038 spc = kidItem.Spacing 1039 try: 1040 spc = kidItem.Spacing 1041 except AttributeError: 1042 spc = 0 1039 1043 kidDict = {"name" : "Spacer", 1040 1044 "attributes" : {"size" : spc, "Name" : "spacer"}, … … 1164 1168 "DefaultBorderTop": {"type" : bool, "readonly" : False}, 1165 1169 "DefaultBorderBottom": {"type" : bool, "readonly" : False}, 1170 "DefaultSpacing": {"type" : int, "readonly" : False}, 1166 1171 "SlotCount" : {"type": int, "readonly" : False}} 1167 1172 # Add the controlling sizer props, if applicable … … 1529 1534 except StandardError, e: 1530 1535 ret = None 1531 except :1536 except AttributeError: 1532 1537 pass 1533 1538 return ret branches/ed-ide/components/ClassDesigner/ClassDesignerControlMixin.py
r4061 r4132 746 746 imageProps = {"ScaleMode" : {"type" : list, "readonly" : False, 747 747 "values" : ["Clip", "Proportional", "Stretch"]}} 748 labelProps = {"AutoResize": {"type" : bool, "readonly" : False}} 748 749 multiSelectProps = {"MultipleSelect": {"type" : bool, "readonly" : False}} 749 750 nodeProps = {"Image": {"type" : "path", "readonly" : False, 750 751 "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}} 753 756 pictureProps = {"Picture": {"type" : "path", "readonly" : False, 754 757 "customEditor": "editStdPicture"}} … … 775 778 "Min": {"type" : int, "readonly" : False}, 776 779 "ShowLabels" : {"type" : bool, "readonly" : False}} 777 splitterProps = { "MinimumPanelSize": {"type" : int, "readonly" : False},780 splitterProps = {"MinimumPanelSize": {"type" : int, "readonly" : False}, 778 781 "Orientation": {"type" : list, "readonly" : False, 779 782 "values" : ["Horizontal", "Vertical"]}, … … 792 795 "values" : ["Upper", "Lower", "Title", "None"]}, 793 796 "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}} 794 803 treeProps = {"Editable" : {"type" : bool, "readonly" : False}, 795 804 "MultipleSelect" : {"type" : bool, "readonly" : False}, … … 878 887 ret.update(imageProps) 879 888 elif isinstance(self, dabo.ui.dLabel): 889 ret.update(labelProps) 880 890 ret.update(colorProps) 881 891 ret.update(captionProps) … … 937 947 elif isinstance(self, dabo.ui.dScrollPanel): 938 948 ret.update(panelProps) 949 ret.update(scrollProps) 939 950 ret.update(colorProps) 940 951 elif isinstance(self, dabo.ui.dPanel): … … 960 971 ret.update({"PasswordEntry" : {"type" : bool, "readonly" : False}, 961 972 "TextLength" : {"type" : int, "readonly" : False}}) 973 elif isinstance(self, dabo.ui.dHtmlBox): 974 ret.update(htmlTextProps) 975 ret.update(scrollProps) 962 976 elif isinstance(self, dabo.ui.dTimer): 963 977 pass branches/ed-ide/components/ClassDesigner/ClassDesignerFormMixin.py
r4063 r4132 484 484 # IOErrorrror that the calling method can catch. 485 485 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 489 493 open(cfName, "wb").write(self._createDesignerCode(codeDict)) 490 494 if currForm: … … 1002 1006 if ctl is None: 1003 1007 return 1004 if self.handles.has_key(ctl):1008 try: 1005 1009 hnd = self.handles[ctl] 1006 for nm,h in hnd.items():1007 h.Visible = False1008 if release:1009 h.release()1010 except KeyError: 1011 return 1012 for nm,h in hnd.items(): 1013 h.Visible = False 1010 1014 if release: 1011 del self.handles[ctl] 1015 h.release() 1016 if release: 1017 del self.handles[ctl] 1012 1018 1013 1019 branches/ed-ide/components/ClassDesigner/ClassDesignerPropSheet.py
r4061 r4132 319 319 dabo.ui.stop(_("Could not set property '%s' to value '%s'\nReason: '%s'") 320 320 % (prop, val, e)) 321 self.updateGridValues() 321 self.updateGridValues() 322 322 323 323
