daboide Commit Revision 304 Date: 2005-12-31 12:38:15 -0800 (Sat, 31 Dec 2005) Author: ed
Changed: U trunk/Designer.py U trunk/DesignerControlMixin.py U trunk/DesignerEditor.py U trunk/DesignerFormMixin.py U trunk/DesignerMenu.py U trunk/DesignerPemForm.py U trunk/DesignerPropSheet.py
Log: Began laying some basic stuff (menu, etc.) for saving a Designer session as a class; i.e., as a reusable component. None of it works yet, so don't be surprised.
Added additional props to the Grid object in the Designer. Added the 'Choices' property to several list-based controls, but right now I don't yet have an editor for it.
Filtered the event superclasses out of the 'on<Event>' method lists.
Diff: Modified: trunk/Designer.py =================================================================== --- trunk/Designer.py 2005-12-31 00:35:11 UTC (rev 303) +++ trunk/Designer.py 2005-12-31 20:38:15 UTC (rev 304) @@ -146,6 +146,9 @@ def _initClassEvents(self): """Create a dict by baseclass of all applicable events.""" self._classEvents = {} + baseEvents = ("DataEvent", "EditorEvent", "GridEvent", "KeyEvent", + "ListEvent", "MenuEvent", "MouseEvent", "SashEvent", + "CalendarEvent", "TreeEvent") classes = (dui.dBox, dui.dBitmap, dui.dBitmapButton, dui.dButton, dui.dCheckBox, dui.dComboBox, dui.dDateTextBox, dui.dDialog, dui.dDropdownList, dui.dEditBox, dui.dForm, dui.dGauge, dui.dGrid, @@ -158,9 +161,12 @@ def evtsForClass(cls): ret = [] for kk, vv in dEvents.__dict__.items(): + if kk in baseEvents: + # These are superclasses of individual events. + continue try: if vv.appliesToClass(cls): - ret.append(kk) + ret.append("on%s" % kk) except: pass ret.sort() @@ -427,17 +433,21 @@ def onSaveDesign(self, evt): self.currentForm.onSaveDesign(evt) + + def onSaveClassDesign(self, evt): + self.currentForm.onSaveClassDesign(evt) + + def onRunDesign(self, evt): + self.currentForm.onRunDesign(evt) + + def onOpenDesign(self, evt): ff = dui.getFile("cdxml") if ff: self.openClass(ff) - def onRunDesign(self, evt): - self.currentForm.onRunDesign(evt) - - def onSaveRunnable(self, evt): self.currentForm.onSaveDesign(evt) nm = self.currentForm.getClassFile()
Modified: trunk/DesignerControlMixin.py =================================================================== --- trunk/DesignerControlMixin.py 2005-12-31 00:35:11 UTC (rev 303) +++ trunk/DesignerControlMixin.py 2005-12-31 20:38:15 UTC (rev 304) @@ -265,6 +265,8 @@ "Height": {"type" : int, "readonly" : True}, "Width": {"type" : int, "readonly" : True}} captionProps = {"Caption": {"type" : str, "readonly" : False}} + choiceProps = {"Choices": {"type" : "choice", "readonly" : False, + "customEditor": "editChoice"}} colorProps = {"BackColor": {"type" : "color", "readonly" : False, "customEditor": "editColor"}, "ForeColor": {"type" : "color", "readonly" : False, @@ -286,7 +288,8 @@ "FontFace": {"type" : str, "readonly" : False}, "FontItalic": {"type" : bool, "readonly" : False}, "FontSize": {"type" : int, "readonly" : False}} - gridProps = {"ColumnCount" : {"type" : int, "readonly" : False}, + gridProps = {"AlternateRowColoring" : {"type" : bool, "readonly" : False}, + "ColumnCount" : {"type" : int, "readonly" : False}, "DataSource" : {"type" : str, "readonly" : False}, "Editable": {"type" : bool, "readonly" : False}, "HeaderBackgroundColor": {"type" : "color", "readonly" : False, @@ -298,8 +301,18 @@ "values" : ["Left", "Center", "Right"]}, "HeaderVerticalAlignment": {"type" : list, "readonly" : False, "values" : ["Top", "Middle", "Bottom"]}, + "RowColorEven": {"type" : "color", "readonly" : False, + "customEditor": "editColor"}, + "RowColorOdd": {"type" : "color", "readonly" : False, + "customEditor": "editColor"}, "RowHeight" : {"type" : int, "readonly" : False}, "Searchable": {"type" : bool, "readonly" : False}, + "SelectionBackColor": {"type" : "color", "readonly" : False, + "customEditor": "editColor"}, + "SelectionForeColor": {"type" : "color", "readonly" : False, + "customEditor": "editColor"}, + "SelectionMode": {"type" : list, "readonly" : False, + "values" : ["Cell", "Row", "Column"]}, "Sortable": {"type" : bool, "readonly" : False}, "ShowRowLabels" : {"type" : bool, "readonly" : False}} imageProps = {"ScaleMode" : {"type" : list, "readonly" : False, @@ -358,9 +371,11 @@ elif isinstance(self, dabo.ui.dComboBox): ret.update(colorProps) ret.update(fontProps) + ret.update(choiceProps) elif isinstance(self, dabo.ui.dDropdownList): ret.update(colorProps) ret.update(fontProps) + ret.update(choiceProps) elif isinstance(self, dabo.ui.dGauge): pass elif isinstance(self, dabo.ui.dGrid): @@ -380,6 +395,7 @@ elif isinstance(self, dabo.ui.dListBox): ret.update(colorProps) ret.update(fontProps) + ret.update(choiceProps) elif isinstance(self, dabo.ui.dListControl): ret.update(colorProps) ret.update(fontProps)
Modified: trunk/DesignerEditor.py =================================================================== --- trunk/DesignerEditor.py 2005-12-31 00:35:11 UTC (rev 303) +++ trunk/DesignerEditor.py 2005-12-31 20:38:15 UTC (rev 304) @@ -242,7 +242,7 @@ else: chc.append(mthd) for evt in evts: - nm = "on%s" % evt + nm = evt if nm in codeKeys: continue chc.append(nm)
Modified: trunk/DesignerFormMixin.py =================================================================== --- trunk/DesignerFormMixin.py 2005-12-31 00:35:11 UTC (rev 303) +++ trunk/DesignerFormMixin.py 2005-12-31 20:38:15 UTC (rev 304) @@ -162,6 +162,14 @@ open(self._classFile, "w").write(dicttoxml(propDict)) + def onSaveClassDesign(self, evt): + """Save the contents of the designer, excluding the outer form, + as a separate class that can be used in other designs. + """ + raise NotImplementedError, "Coming soon..." + pass + + def onRunDesign(self, evt): # First, make sure that it's been saved self.onSaveDesign(None)
Modified: trunk/DesignerMenu.py =================================================================== --- trunk/DesignerMenu.py 2005-12-31 00:35:11 UTC (rev 303) +++ trunk/DesignerMenu.py 2005-12-31 20:38:15 UTC (rev 304) @@ -57,8 +57,10 @@ fm.prependSeparator() fm.prepend(_("Save Runnable App"), bindfunc=app.onSaveRunnable, help=_("Create a mini app to run your form")) + fm.prepend(_("Save as C&lass\tCtrl+L"), bindfunc=app.onSaveClassDesign, + help=_("Save the Designer contents as a class")) fm.prepend(_("&Save\tCtrl+S"), bindfunc=app.onSaveDesign, - help=_("Save your changes")) + help=_("Save the Designer contents as a form")) fm.prepend(_("&Open\tCtrl+O"), bindfunc=app.onOpenDesign, help=_("Open a saved design file"))
Modified: trunk/DesignerPemForm.py =================================================================== --- trunk/DesignerPemForm.py 2005-12-31 00:35:11 UTC (rev 303) +++ trunk/DesignerPemForm.py 2005-12-31 20:38:15 UTC (rev 304) @@ -142,10 +142,6 @@ self.txtObj.Value = lbl self.PropSheet.select(obj) self.MethodList.clear() -# if isSlot or isSizer: -# # These are not objects that have runtime code -# self.propPage.Expanded = True -# return # Get the events evts = ob.DesignerEvents
Modified: trunk/DesignerPropSheet.py =================================================================== --- trunk/DesignerPropSheet.py 2005-12-31 00:35:11 UTC (rev 303) +++ trunk/DesignerPropSheet.py 2005-12-31 20:38:15 UTC (rev 304) @@ -252,7 +252,13 @@ self.propGrid.CurrentValue = newVal + def editChoice(self, objs, prop, val=[]): + # Create a list of choices. 'val' may be a list of existing choices + obj = objs[0] + raise NotImplementedError, "Gonna do this soon..." + + class PropertyGrid(dabo.ui.dGrid): def afterInit(self): self._handler = None
©2005 Ed Leafe |
|