daboide Commit
Revision 712
Date: 2006-12-16 14:29:22 -0800 (Sat, 16 Dec 2006)
Author: Ed

Changed:
U   trunk/wizards/AppWizard/AppWizard.py

Log:
Made the choice of using spaces and the number of spaces per tab in to 
properties. Also made the setting for the convert tabs to persist, since it is 
likely that if someone wants spaces one time, they will want them all the time.


Diff:
Modified: trunk/wizards/AppWizard/AppWizard.py
===================================================================
--- trunk/wizards/AppWizard/AppWizard.py        2006-12-16 22:03:16 UTC (rev 
711)
+++ trunk/wizards/AppWizard/AppWizard.py        2006-12-16 22:29:22 UTC (rev 
712)
@@ -640,18 +640,6 @@
                self.chkSortFieldsAlpha = dabo.ui.dCheckBox(self, 
Caption=_("Sort Fields Alphabetically"))
                self.Sizer.append(self.chkSortFieldsAlpha)
 
-               def _onConvertTabs(evt):
-                       if self.Form.chkConvertTabs.Value:
-                               numSpaces = dabo.ui.getInt(_("Enter the number 
of spaces for each tab:"),
-                                               _("Convert tabs to spaces"), 4)
-                               if numSpaces:
-                                       self.Form._convertTabs = numSpaces
-                               else:
-                                       self.Form.chkConvertTabs.Value = False
-                                       self.Form._convertTabs = False
-                       else:
-                               self.Form._convertTabs = False
-
                self.Sizer.appendSpacer(2)
                ln = dabo.ui.dLine(self, Width=200)
                self.Sizer.append(ln, halign="left")
@@ -659,9 +647,10 @@
                lbl.FontSize -= 1
                self.Sizer.append(lbl)
                chkConvertTabs = dabo.ui.dCheckBox(self, 
RegID="chkConvertTabs", 
-                               Caption=_("Check this if you insist on using 
spaces."))
+                               Caption=_("Check this if you insist on using 
spaces."),
+                               DataSource=self.Form, DataField="ConvertTabs",
+                               SaveRestoreValue=True)
                chkConvertTabs.FontSize -= 1
-               chkConvertTabs.bindEvent(dabo.dEvents.Hit, _onConvertTabs)
                self.Sizer.append(chkConvertTabs, valign="bottom")
        
 
@@ -810,6 +799,8 @@
                # Field specs are deprecated; all references will eventually
                # be removed, but for now we need to set this reference
                self.useFieldSpecs = False
+               self._convertTabs = False
+               self._spacesPerTab = 4
                self.usePKUI = True
                self.sortFieldsAlpha = False
                
@@ -973,7 +964,12 @@
                        os.chdir("..")
 
                        # convert to spaces if user requested it:
-                       self._convertTabsToSpaces()
+                       if self.ConvertTabs:
+                               numSpaces = dabo.ui.getInt(_("Enter the number 
of spaces for each tab:"),
+                                               _("Convert tabs to spaces"), 
self.SpacesPerTab)
+                               if numSpaces:
+                                       self.SpacesPerTab = numSpaces
+                               self._convertTabsToSpaces()
                        return True
 
                else:
@@ -982,13 +978,11 @@
 
 
        def _convertTabsToSpaces(self):
-               if self._convertTabs:
-                       def func(arg, dirname, fnames):
-                               for fname in fnames:
-                                       if fname[-3:] == ".py":
-                                               untabify(os.path.join(dirname, 
fname), self._convertTabs)
-                                               ### post 0.7: 
untabify(os.path.join(dirname, fname), self._convertTabs, saveBackup=False)
-                       os.path.walk(".", func, None)
+               def func(arg, dirname, fnames):
+                       for fname in fnames:
+                               if fname[-3:] == ".py":
+                                       untabify(os.path.join(dirname, fname), 
self.SpacesPerTab, saveBackup=False)
+               os.path.walk(".", func, None)
 
 
        def getFileOpenMenu(self, tables):
@@ -1384,7 +1378,46 @@
                return open(os.path.join(self.Application.HomeDirectory, 
                                "spec-sampleReport.rfxml")).read() % locals()
 
+       def _onConvertTabs(evt):
+               if self.Form.chkConvertTabs.Value:
+                       numSpaces = dabo.ui.getInt(_("Enter the number of 
spaces for each tab:"),
+                                       _("Convert tabs to spaces"), 4)
+                       if numSpaces:
+                               self.Form._convertTabs = numSpaces
+                       else:
+                               self.Form.chkConvertTabs.Value = False
+                               self.Form._convertTabs = False
+               else:
+                       self.Form._convertTabs = False
+       
+       def _getConvertTabs(self):
+               return self._convertTabs
 
+       def _setConvertTabs(self, val):
+               if self._constructed():
+                       self._convertTabs = val
+               else:
+                       self._properties["ConvertTabs"] = val
+
+
+       def _getSpacesPerTab(self):
+               return self._spacesPerTab
+
+       def _setSpacesPerTab(self, val):
+               if self._constructed():
+                       self._spacesPerTab = val
+               else:
+                       self._properties["SpacesPerTab"] = val
+
+
+       ConvertTabs = property(_getConvertTabs, _setConvertTabs, None,
+                       _("Do we convert tabs to spaces? Default=False  
(bool)"))
+       
+       SpacesPerTab = property(_getSpacesPerTab, _setSpacesPerTab, None,
+                       _("When converting tabs, the number of spaces to use 
per tab. Default=4  (int)"))
+       
+
+
 def relationSpecs(relaDict):
        ret = """<?xml version="1.0" encoding="%s" standalone="no"?>
 <daboRelationSpecs>




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to