Changeset 3808

Show
Ignore:
Timestamp:
12/17/07 17:09:47 (1 year ago)
Author:
ed
Message:

Added support for Datetime and Date values.

Added a custom PrefDialog? subclass.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ide/PrefEditor.cdxml

    r3668 r3808  
    9696    else: 
    9797        typDict = {"String": str, "Unicode": unicode, "Integer": int, "Float": float,  
    98                 "Boolean": bool, "List": list, "Tuple": tuple, "Dict": dict} 
     98                "Boolean": bool, "List": list, "Tuple": tuple, "Dict": dict,  
     99                "Datetime": datetime.datetime, "Date": datetime.date} 
    99100        self.pref.addKey(newkey, typDict[typ], typDict[typ]()) 
    100101]]> 
     
    118119        </updatePref> 
    119120        <importStatements><![CDATA[ 
     121import datetime 
    120122from dabo.dLocalize import _ 
    121123]]> 
     
    151153    ctls = ((_("Preference Name?"), unicode, "prefname"),  
    152154            (_("Type:"), ["String", "Unicode", "Integer",  
    153             "Float", "Boolean", "List", "Tuple", "Dict"], "typ") ) 
     155            "Float", "Boolean", "List", "Tuple", "Dict", "Datetime", "Date"], "typ") ) 
    154156    dlg = dabo.ui.dOkCancelDialog(self, Caption=_("Add Child Key")) 
    155157    dlg.addControlSequence(ctls) 
     
    214216                                        </dTextBox> 
    215217                                        <dTextBox sizerInfo="{'Proportion': 0, 'ColExpand': True, 'Expand': True, 'RowExpand': False}" Name="dTextBox11" rowColPos="(0, 1)" ReadOnly="True" designerClass="controlMix" RegID="txtPrefName"></dTextBox> 
    216                                         <dDropdownList sizerInfo="{'Proportion': 0, 'ColExpand': True, 'Expand': True, 'RowExpand': False}" Name="dDropdownList1" rowColPos="(2, 1)" Choices="[u&apos;-None-&apos;, u&apos;String&apos;, u&apos;Unicode&apos;, u&apos;Integer&apos;, u&apos;Float&apos;, u&apos;Boolean&apos;, u&apos;List&apos;, u&apos;Tuple&apos;, u&apos;Dict&apos;]" designerClass="controlMix" RegID="ddType"> 
     218                                        <dDropdownList sizerInfo="{'Proportion': 0, 'ColExpand': True, 'Expand': True, 'RowExpand': False}" Name="dDropdownList1" rowColPos="(2, 1)" Choices="[u&apos;-None-&apos;, u&apos;String&apos;, u&apos;Unicode&apos;, u&apos;Integer&apos;, u&apos;Float&apos;, u&apos;Boolean&apos;, u&apos;List&apos;, u&apos;Tuple&apos;, u&apos;Dict&apos;, u&apos;Datetime&apos;, u&apos;Date&apos;]" designerClass="controlMix" RegID="ddType"> 
    217219                                            <code> 
    218220                                                <afterInit><![CDATA[ 
    219221def afterInit(self): 
    220     self.Keys = [type(None), str, unicode, int, float, bool, list, tuple, dict
     222    self.Keys = [type(None), str, unicode, int, float, bool, list, tuple, dict, datetime.datetime, datetime.date
    221223    self.ValueMode = "Key" 
    222224]]> 
  • trunk/ide/PrefEditor.py

    r3515 r3808  
     1#!/usr/bin/env python 
    12# -*- coding: utf-8 -*- 
    23import os 
    34import inspect 
    45import dabo 
     6dabo.ui.loadUI("wx") 
     7from dabo.dLocalize import _ 
     8from dabo.ui.dialogs.PreferenceDialog import PreferenceDialog 
     9 
     10 
     11class PrefEditorPrefDialog(PreferenceDialog): 
     12    def addPages(self): 
     13        dayMins = 24*60 
     14        pm = self.PreferenceManager 
     15        updKey = pm.web_update 
     16        self.preferenceKeys.append(updKey) 
     17        upPage = self.addCategory(_("Web Updates")) 
     18 
     19        sz = upPage.Sizer = dabo.ui.dSizer("v") 
     20        hsz = dabo.ui.dSizer("h") 
     21        chkUpdateCheck = dabo.ui.dCheckBox(upPage, OnHit=self.onChkUpdate,  
     22                Caption=_("Check for Preference Editor updates"), RegID="chkForPrefManUpdates", 
     23                DataSource=updKey, DataField="web_update",  
     24                ToolTipText="Should we check for updates to the Preference Editor?") 
     25        btnCheckNow = dabo.ui.dButton(upPage, Caption=_("Check now..."), 
     26                OnHit=self.onCheckNow, ToolTipText="Check the Dabo server for updates") 
     27        hsz.append(chkUpdateCheck, valign="middle") 
     28        hsz.appendSpacer(8) 
     29        hsz.append(btnCheckNow, valign="middle") 
     30        sz.append(hsz, halign="center", border=20) 
     31         
     32        radFrequency = dabo.ui.dRadioList(upPage, Orientation="Vertical",  
     33                Caption=_("Check every..."), RegID="radWebUpdateFrequency",  
     34                Choices=[_("Every time an app is run"), _("Once a day"), _("Once a week"), _("Once a month")], 
     35                Keys = [0, dayMins, dayMins*7,dayMins*30], 
     36                ValueMode="Keys", DataSource=updKey, DataField="update_interval", 
     37                ToolTipText=_("How often should we check for updates?"), 
     38                DynamicEnabled = lambda: self.chkForPrefManUpdates.Value) 
     39        sz.append(radFrequency, halign="center") 
     40     
     41     
     42    def onChkUpdate(self, evt): 
     43        self.update() 
     44         
     45         
     46    def onCheckNow(self, evt): 
     47        ret = self.Application.checkForUpdates(project="prf") 
     48 
     49 
     50         
    551 
    652def main(): 
    7     app = dabo.dApp() 
     53    app = dabo.dApp(BasePrefKey="PrefEditor", MainFormClass="PrefEditor.cdxml", 
     54            PreferenceDialogClass=PrefEditorPrefDialog) 
    855    curdir = os.getcwd() 
    956    # Get the current location's path 
    10     fname = inspect.getfile(main) 
    11     pth = os.path.split(fname)[0] 
    12     if pth: 
    13         # Switch to that path 
    14         os.chdir(pth) 
    15     app.MainFormClass = "PrefEditor.cdxml" 
     57    fname = os.path.abspath(inspect.getfile(main)) 
     58    pth = os.path.dirname(fname) 
     59    # Switch to that path 
     60    os.chdir(pth) 
    1661    app.start() 
    1762     
    1863    # Return to the original location 
    1964    os.chdir(curdir) 
    20      
    2165 
    22 if __name__ == '__main__': 
     66 
     67 
     68if __name__ == "__main__": 
    2369    main()