dabo Commit
Revision 4433
Date: 2008-08-21 14:03:58 -0700 (Thu, 21 Aug 2008)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/4433

Changed:
U   trunk/dabo/ui/uiwx/__init__.py
A   trunk/dabo/ui/uiwx/dCheckList.py
D   trunk/dabo/ui/uiwx/dCheckListBox.py
U   trunk/ide/ClassDesignerPropSheet.py
U   trunk/ide/wizards/AppWizard/AppWizard.py

Log:
Changed the name of dCheckListBox to dCheckList, which is consistent with
dRadioList. Deprecated the old name, and fixed all references.



Diff:
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py      2008-08-21 19:11:01 UTC (rev 4432)
+++ trunk/dabo/ui/uiwx/__init__.py      2008-08-21 21:03:58 UTC (rev 4433)
@@ -74,7 +74,7 @@
 from dCalendar import dCalendar
 from dCalendar import dExtendedCalendar
 from dCheckBox import dCheckBox
-from dCheckListBox import dCheckListBox
+from dCheckList import dCheckList
 from dColorDialog import dColorDialog
 from dComboBox import dComboBox
 from dDateTextBox import dDateTextBox
@@ -161,11 +161,16 @@
        def __init__(self, *args, **kwargs):
                warnings.warn(_("'dFoldPanelBar' is a deprecated name. Use 
'dSlidePanelControl' instead"), DeprecationWarning)
                super(dFoldPanelBar, self).__init__(*args, **kwargs)
+
 class dFoldPanel(dSlidePanel):
        def __init__(self, *args, **kwargs):
                warnings.warn(_("'dFoldPanel' is a deprecated name. Use 
'dSlidePanel' instead"), DeprecationWarning)
                super(dFoldPanel, self).__init__(*args, **kwargs)
 
+class dCheckListBox(dCheckList):
+       def __init__(self, *args, **kwargs):
+               warnings.warn(_("'dCheckListBox' is a deprecated name. Use 
'dCheckList' instead"), DeprecationWarning)
+               super(dCheckListBox, self).__init__(*args, **kwargs)
 
 artConstants = {}
 for item in (it for it in dir(wx) if it.startswith("ART_")):

Copied: trunk/dabo/ui/uiwx/dCheckList.py (from rev 4422, 
trunk/dabo/ui/uiwx/dCheckListBox.py)
===================================================================
--- trunk/dabo/ui/uiwx/dCheckList.py                            (rev 0)
+++ trunk/dabo/ui/uiwx/dCheckList.py    2008-08-21 21:03:58 UTC (rev 4433)
@@ -0,0 +1,113 @@
+# -*- coding: utf-8 -*-
+import wx
+import dabo
+if __name__ == "__main__":
+       dabo.ui.loadUI("wx")
+import dControlItemMixin as dcm
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+
+
+class dCheckList(dcm.dControlItemMixin, wx.CheckListBox):
+       """Creates a listbox, allowing the user to choose one or more items
+       by checking/unchecking each one.
+       """
+       def __init__(self, parent, properties=None, attProperties=None, *args, 
**kwargs):
+               self._baseClass = dCheckList
+               self._choices = []
+               preClass = wx.PreCheckListBox
+               dcm.dControlItemMixin.__init__(self, preClass, parent, 
properties, 
+                               attProperties, *args, **kwargs)
+
+                       
+       def _initEvents(self):
+               super(dCheckList, self)._initEvents()
+               self.Bind(wx.EVT_CHECKLISTBOX, self._onWxHit)
+       
+       
+       def GetSelections(self):
+               # Need to override the native method, as this reports the 
+               # line with focus, not the checked items.
+               ret = []
+               for cnt in xrange(self.Count):
+                       if self.IsChecked(cnt):
+                               ret.append(cnt)
+               return ret
+               
+               
+       def selectAll(self):
+               """Set all items to checked."""
+               for cnt in xrange(self.Count):
+                       self.Check(cnt, True)
+
+
+       def clearSelections(self):
+               """Set all items to unchecked."""
+               for cnt in xrange(self.Count):
+                       self.Check(cnt, False)
+       # Just to keep the naming consistent
+       selectNone = clearSelections
+
+
+       def invertSelections(self):
+               """Switch all the items from False to True, and vice-versa."""
+               for cnt in xrange(self.Count):
+                       self.Check(cnt, not self.IsChecked(cnt))
+       
+
+       def setSelection(self, index):
+               if self.Count > index:
+                       self.Check(index, True)
+               else:
+                       ## pkm: The user probably set the Value property from 
inside initProperties(),
+                       ##      and it is getting set before the Choice 
property has been applied.
+                       ##      If this is the case, callAfter is the ticket.
+                       dabo.ui.callAfter(self.Check, index, True)
+       
+       
+       def _getMultipleSelect(self):
+               return True
+
+
+       MultipleSelect = property(_getMultipleSelect, None, None,
+                       _("MultipleSelect for dCheckList is always True."))
+       
+       
+       
+class _dCheckList_test(dCheckList):
+       def initProperties(self):
+               # Simulate a database:
+               actors = ({"lname": "Jason Leigh", "fname": "Jennifer", "iid": 
42},
+                       {"lname": "Cates", "fname": "Phoebe", "iid": 23},
+                       {"lname": "Reinhold", "fname": "Judge", "iid": 13})
+                       
+               choices = []
+               keys = {}
+
+               for actor in actors:
+                       choices.append("%s %s" % (actor['fname'], 
actor['lname']))
+                       keys[actor["iid"]] = len(choices) - 1
+
+               self.Choices = choices
+               self.Keys = keys
+               self.ValueMode = 'Key'
+               self.Value = 23
+
+       def onHit(self, evt):
+               print "HIT:"
+               print "\tKeyValue: ", self.KeyValue
+               print "\tPositionValue: ", self.PositionValue
+               print "\tStringValue: ", self.StringValue
+               print "\tValue: ", self.Value
+               print "\tCount: ", self.Count
+       
+       def onMouseLeftDoubleClick(self, evt):
+               print "double click"
+
+       def onMouseLeftDown(self, evt):
+               print "mousedown"       
+
+if __name__ == "__main__":
+       import test
+       test.Test().runTest(_dCheckList_test)
+

Deleted: trunk/dabo/ui/uiwx/dCheckListBox.py

Modified: trunk/ide/ClassDesignerPropSheet.py
===================================================================
--- trunk/ide/ClassDesignerPropSheet.py 2008-08-21 19:11:01 UTC (rev 4432)
+++ trunk/ide/ClassDesignerPropSheet.py 2008-08-21 21:03:58 UTC (rev 4433)
@@ -568,7 +568,7 @@
                                                Caption=_("Select the sides to 
which the border will apply:"))
                                self.Sizer.append(lbl, halign="center")
                                choices = ["All", "Top", "Bottom", "Left", 
"Right", "None"]
-                               self.editor = dabo.ui.dCheckListBox(self, 
Choices=choices,
+                               self.editor = dabo.ui.dCheckList(self, 
Choices=choices,
                                                ValueMode="String", Height=200)
                                self.editor.bindEvent(dEvents.Hit, 
self.onSidesChanged)
                                self.editor.Value = self._currVal = val

Modified: trunk/ide/wizards/AppWizard/AppWizard.py
===================================================================
--- trunk/ide/wizards/AppWizard/AppWizard.py    2008-08-21 19:11:01 UTC (rev 
4432)
+++ trunk/ide/wizards/AppWizard/AppWizard.py    2008-08-21 21:03:58 UTC (rev 
4433)
@@ -335,7 +335,7 @@
 Please check all tables you want included in 
 your application.""")
                lbl = dLabel(self, Caption=txt)
-               clb = self.addObject(dabo.ui.dCheckListBox, 
Name="clbTableSelection")
+               clb = self.addObject(dabo.ui.dCheckList, 
Name="clbTableSelection")
                self.Sizer.append(lbl)
                self.Sizer.append1x(clb)
                hsz = dabo.ui.dSizer("h")




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to